jQuery.noConflict(); 

jQuery(document).ready(function() {
   
jQuery("#coffebeanbgexp").animate({ width: "463", height:"451"},1000 );   
jQuery("#growbeavvert").animate({height:"451"},1000 );   
jQuery("#closebtnanime").animate({height:"17", width:"52"},1000 );   

   
}); 

function hoverImage(imagetochange, image) {
    document.getElementById(imagetochange).src = image;
}

function showEnquiryForm() {
    document.getElementById('contactForm').style.display = '';
    //document.getElementById('thankyou').style.display = 'none';
    document.getElementById('OuterEnquiryWrapper').style.display = '';
}

function hideEnquiryForm() {
    document.getElementById('OuterEnquiryWrapper').style.display = 'none';
}

function clickTab(value) {

    //content divs
    var profile = document.getElementById('editDetails');
    var orderHistory = document.getElementById('order_history');
    var futureOrders = document.getElementById('future_orders');
    var myUsual = document.getElementById('my_usual');
    var giveagift = document.getElementById('give_a_gift');

    // tab buttons
    var profileTab = document.getElementById('profile_tab');
    var orderHistoryTab = document.getElementById('order_history_tab');
    var futureOrdersTab = document.getElementById('future_order_tab');
    var myUsualTab = document.getElementById('usual_tab');
    var giveagiftTab = document.getElementById('give_gift');

    switch (value) {
        case 1:
            //change tab status
            profileTab.src = 'images/buttons/tab-profile-on.gif';
            orderHistoryTab.src = 'images/buttons/tab-order-history-off.gif';
            futureOrdersTab.src = 'images/buttons/tab-future-order-off.gif';
            myUsualTab.src = 'images/buttons/tab-usual-off.gif';
            giveagiftTab.src = 'images/buttons/tab-gift-off.gif';
            // change div status
            profile.style.display = 'block';
            orderHistory.style.display = 'none';
            futureOrders.style.display = 'none';
            myUsual.style.display = 'none';
            giveagift.style.display = 'none';  
            document.getElementById('ctl00_MyAccount_pnlEditDetailsForm').style.display = 'block';
            document.getElementById('ctl00_MyAccount_pnlThankYou').style.display = 'none';  
            document.getElementById('Editpage1buttons').style.display = 'block';
            document.getElementById('Editpage2buttons').style.display = 'None';
            document.getElementById('Editpage3buttons').style.display = 'None';     
            document.getElementById('EditfirstFormDetails').style.display = 'block';
            document.getElementById('EditsecondFormDetails').style.display = 'none';
            document.getElementById('EditthirdFormDetails').style.display = 'none';
            break;

        case 2:
            //change tab status
            profileTab.src = 'images/buttons/tab-profile-off.gif';
            orderHistoryTab.src = 'images/buttons/tab-order-history-on.gif';
            futureOrdersTab.src = 'images/buttons/tab-future-order-off.gif';
            myUsualTab.src = 'images/buttons/tab-usual-off.gif';
            giveagiftTab.src = 'images/buttons/tab-gift-off.gif';
            // change div status
            profile.style.display = 'none';
            orderHistory.style.display = 'block';
            futureOrders.style.display = 'none';
            myUsual.style.display = 'none';
            giveagift.style.display = 'none';
            break;

        case 3:
            //change tab status
            profileTab.src = 'images/buttons/tab-profile-off.gif';
            orderHistoryTab.src = 'images/buttons/tab-order-history-off.gif';
            futureOrdersTab.src = 'images/buttons/tab-future-order-on.gif';
            myUsualTab.src = 'images/buttons/tab-usual-off.gif';
            giveagiftTab.src = 'images/buttons/tab-gift-off.gif';
            // change div status
            profile.style.display = 'none';
            orderHistory.style.display = 'none';
            futureOrders.style.display = 'block';
            myUsual.style.display = 'none';
            giveagift.style.display = 'none';
            break;

        case 4:
            //change tab status
            profileTab.src = 'images/buttons/tab-profile-off.gif';
            orderHistoryTab.src = 'images/buttons/tab-order-history-off.gif';
            futureOrdersTab.src = 'images/buttons/tab-future-order-off.gif';
            myUsualTab.src = 'images/buttons/tab-usual-on.gif';
            giveagiftTab.src = 'images/buttons/tab-gift-off.gif';
            // change div status
            profile.style.display = 'none';
            orderHistory.style.display = 'none';
            futureOrders.style.display = 'none';
            myUsual.style.display = 'block';
            giveagift.style.display = 'none';
            break;

        case 5:
            //change tab status
            profileTab.src = 'images/buttons/tab-profile-off.gif';
            orderHistoryTab.src = 'images/buttons/tab-order-history-off.gif';
            futureOrdersTab.src = 'images/buttons/tab-future-order-off.gif';
            myUsualTab.src = 'images/buttons/tab-usual-off.gif';
            giveagiftTab.src = 'images/buttons/tab-gift-on.gif';
            // change div status
            profile.style.display = 'none';
            orderHistory.style.display = 'none';
            futureOrders.style.display = 'none';
            myUsual.style.display = 'none';
            giveagift.style.display = 'block';
            break;
    }

}

function setStep(step) {
    var count = 1;
    while (count < 4) {
        if (count == step) {
            document.getElementById('stage' + step).src = 'images/registration/step' + step + '-on.jpg';
        }
        else {
            document.getElementById('stage' + count).src = 'images/registration/step' + count + '-off.jpg';
        }
        count++;
    }
}

function registerStepOne(ControlToFocus, mode) {

    document.getElementById(mode + 'firstFormDetails').style.display = 'block';
    document.getElementById(mode + 'secondFormDetails').style.display = 'none';
    document.getElementById(mode + 'thirdFormDetails').style.display = 'none';
    document.getElementById(mode + 'page1buttons').style.display = 'block';
    document.getElementById(mode + 'page2buttons').style.display = 'None';
    document.getElementById(mode + 'page3buttons').style.display = 'None';
    if (mode == "Register") {
        setStep(1);
    }
    document.getElementById(ControlToFocus).focus();
}

function registerStepTwo(ControlToFocus, mode, validatorSummaryId, customValidatorId, TextBoxEmailId) {
    var emailAddress = document.getElementById(TextBoxEmailId).value;
    CustomValidator(validatorSummaryId, customValidatorId, mode, ControlToFocus, emailAddress);
}

function registerStepTwoBackwards(ControlToFocus, mode) {

    document.getElementById(mode + 'firstFormDetails').style.display = 'none';
    document.getElementById(mode + 'secondFormDetails').style.display = 'block';
    document.getElementById(mode + 'thirdFormDetails').style.display = 'none';
    document.getElementById(mode + 'page1buttons').style.display = 'None';
    document.getElementById(mode + 'page2buttons').style.display = 'block';
    document.getElementById(mode + 'page3buttons').style.display = 'None';
    if (mode == "Register") {
        setStep(2);
    }
    document.getElementById(ControlToFocus).focus();
}

function registerStepThree(ControlToFocus, mode, validatorSummaryId) {

    var validated = Page_ClientValidate(mode + 'ValidationPage2');
    if (validated) {
        document.getElementById(mode + 'firstFormDetails').style.display = 'none';
        document.getElementById(mode + 'secondFormDetails').style.display = 'None';
        document.getElementById(mode + 'thirdFormDetails').style.display = 'block';
        document.getElementById(mode + 'page1buttons').style.display = 'None';
        document.getElementById(mode + 'page2buttons').style.display = 'None';
        document.getElementById(mode + 'page3buttons').style.display = '';
        if (mode == "Register") {
            setStep(3);
        }
        document.getElementById(ControlToFocus).focus();
    }
    else {
        document.getElementById(validatorSummaryId).style.display = 'block';
        document.getElementById(validatorSummaryId).style.visibility = 'visible';
    }
}

/*Change Tip Text*/

function tipText(displayMessage, mode) {
    document.getElementById(mode + 'tipText').style.display = '';
    document.getElementById(mode + 'tipText').innerHTML = displayMessage + '<br /><br />';

}

function submitCartForm(product, quantity) {
    document.cartForm.product.value = product;
    document.cartForm.quantity.value = quantity;
    document.cartForm.submit();
}

function showSubMenu(subID, menuItem) {
    var subMenu = document.getElementById('sub_' + subID);
    if (menuItem) {
        subMenu.style.left = (findLeft(menuItem) - 50) + 'px';
        subMenu.style.top = (findTop(menuItem) + menuItem.clientHeight - 22) + 'px';
        //alert(menuItem.clientHeight);
    }
    subMenu.style.visibility = 'visible';
}

function hideSubMenu(subID) {
    document.getElementById('sub_' + subID).style.visibility = 'hidden';
}

function hideDropdown(subID, parent1, parent2) {
    document.getElementById('sub_' + subID).style.visibility = 'hidden';
    if (parent1) hideSubMenu(parent1);
    if (parent2) hideSubMenu(parent2);
}

function showDropdown(subID, menuItem, parent1, parent2) {
    var subMenu = document.getElementById('sub_' + subID);
    if (menuItem) {
        subMenu.style.left = (findLeft(menuItem) + menuItem.offsetWidth) + 'px';
        subMenu.style.top = findTop(menuItem) + 'px';
    }
    if (parent1 && parent1 > 7) showSubMenu(parent1);
    if (parent2 && parent2 > 7) showSubMenu(parent2);
    subMenu.style.visibility = 'visible';
}

function findLeft(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft;
        while (obj = obj.offsetParent) curleft += obj.offsetLeft;
    }
    return curleft;
}

function findTop(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) { curtop += obj.offsetTop }
    }
    return curtop;
}

var newImage, imageList, preloadCount, preloadInterval;
var preloadCount = 0;
imageList = new Array();

function addPreloadImage(url) {
    imageList[imageList.length] = url;
}

function startPreloading() {
    if (imageList.length != 0) {
        newImage = new Image;
        newImage.src = imageList[0]
        preloadInterval = setInterval('preloadCheck()', 1000);

    }
}

function preloadCheck() {
    if (newImage.complete) {
        preloadCount += 1;
        if (preloadCount < imageList.length) {
            newImage.src = imageList[preloadCount];
            clearInterval(preloadInterval);
            preloadInterval = setInterval('preloadCheck()', 1000);
        }
        else {
            clearInterval(preloadInterval);
        }
    }
}

function imageSwap(key, url) {
    eval('document.' + key + '.src = \'' + url + '\'');
}

function mailto(recipient) {
    document.location.href = 'mailto:' + recipient + '@andmeuk.com?subject=Website Enquiry';
}

function goTo(url) {
    document.location.href = url;
}

function openWindow(url, width, height, sizeable) {
    if (sizeable) sizeable = ',resizable,scrollbars'
    else sizeable = '';
    var openWin = window.open(url, '_blank', 'width=' + width + ',height=' + height + ',screenX=' + ((screen.availWidth - width) / 2) + ',left=' + ((screen.availWidth - width) / 2) + ',screenY=' + ((screen.availHeight - height) / 2) + ',top=' + ((screen.availHeight - height) / 2) + sizeable);
    openWin.focus();
}




function openPopup(divtoShow) {
    document.getElementById(divtoShow).style.display = 'block';
    

    if (divtoShow = 'RegistrationPopupWrapper')
    {
       closePopup('bigBeanWrapper'); 
    }
    //document.getElementById('bodyCol_Rht').style.display='none'

    //This counters the firefox inaccessible content bug
    //		document.getElementById('bodyCol_Rht').style.position='static';
    //		document.getElementById('bodyCol_Rht').zIndex='';
    //		document.getElementById('bodyCol_Center').style.position='static';
    //		document.getElementById('bodyCol_Center').zIndex='';


}

function closePopup(divtoHide) {

    if(document.getElementById(divtoHide) != null)
    {
        document.getElementById(divtoHide).style.display = 'none';
    }

    //    //This counters the firefox inaccessible content bug
    //    document.getElementById('bodyCol_Rht').style.position = 'relative';
    //    document.getElementById('bodyCol_Rht').zIndex = '20001';
    //    if (menuIsOpen == 0) {
    //        document.getElementById('bodyCol_Center').style.position = 'relative';
    //        document.getElementById('bodyCol_Center').zIndex = '20001';
    //        //alert(menuIsOpen)
    //    }
    //    if (menuIsOpen == 1) {
    //        document.getElementById('bodyCol_Center').style.position = 'static';
    //        document.getElementById('bodyCol_Center').zIndex = '';
    //        //alert(menuIsOpen)
    //    }

}

function closePopupConfirmation(divtoHide) {
    var answer = confirm("If you close this window all of your information will be lost, are you sure you want to quit?");

    if (answer) {
        document.getElementById(divtoHide).style.display = 'none';

        //This counters the firefox inaccessible content bug
        document.getElementById('bodyCol_Rht').style.position = 'relative';
        document.getElementById('bodyCol_Rht').zIndex = '20001';
        if (menuIsOpen == 0) {
            document.getElementById('bodyCol_Center').style.position = 'relative';
            document.getElementById('bodyCol_Center').zIndex = '20001';
            //alert(menuIsOpen)
        }
        if (menuIsOpen == 1) {
            document.getElementById('bodyCol_Center').style.position = 'static';
            document.getElementById('bodyCol_Center').zIndex = '';
            //alert(menuIsOpen)
        }
    }







}


function get_cookie(cookie_name) {
    var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');

    if (results)
        return (unescape(results[2]));
    else
        return null;
}

function growBean() {

    Effect.Grow('bigBeanWrapper', { direction: 'center', transition: Effect.Transitions.linear, from: 0.2, to: 1.0 });
    Effect.Grow('innerbean', { direction: 'center', transition: Effect.Transitions.linear, from: 0.2, to: 1.0 });

}
		


	
	
