var validationControlsArray = "";
var validationIsDateOfBirthValid = true;
var guidedNavLIToSelectID = "ctl00_cphMain_ctl00_moduleGuidedNavRedoute1980_hidLIToSelect";
var guidedNavLIToSelectColourID = "ctl00_cphMain_ctl00_moduleGuidedNavRedoute1980_hidLIToSelectColour";
var loginDivLoginID = "ctl00_cphMain_ctl00_divLogin";
var loginDivForgotPasswordID = "ctl00_cphMain_ctl00_divForgotPassword";
var loginLnkLoginID = "ctl00_cphMain_ctl00_lnkLogin";
var loginLnkForgotPassID = "ctl00_cphMain_ctl00_lnkForgotPass";
var changeImageTimer;
var currentBigImage;
var isImageSwitching = 0;
var tryChangeImageTimer;
var sendToFriendEmailArray;
var arr;

/*---------------------/
/*  Theseus Functions  /
/*--------------------*/

function SwitchLanguage(curLang)
{
    var userLang = (navigator.language) ? navigator.language : navigator.userLanguage;

    $.ajax({
        url: "/logging/ajax.aspx?method=setlanguage&clientLang=" + userLang + "&curLang=" + curLang,
        dataType: "text",
        async: true,
        cache: true,
        success: function (res)
        {
            if (res != "" && res != " ")
                window.location = res;
        }
    }
	);
}

function SetSession(sessionVar, sessionValue) {
    var userLang = (navigator.language) ? navigator.language : navigator.userLanguage;

    $.ajax({
        url: "/logging/ajax.aspx?method=setsession&sessionVar=" + sessionVar + "&sessionValue=" + sessionValue,
        dataType: "text",
        async: false,
        cache: false,
        success: null
    }
	);
}


function HideBrokenImage(image)
{
	$(image).hide();
	image.onerror = "";
	return true;
}


function TrimString(str)
{
    while (str.substring(0,1) == ' ') // check for white spaces from beginning
        str = str.substring(1, str.length);

    while (str.substring(str.length-1, str.length) == ' ') // check white space from end
        str = str.substring(0,str.length-1);

    return str;
}


function RemoveAccents(str)
{
	var s=str;

	var rExps=[ /[\xC0-\xC2]/g, /[\xE0-\xE2]/g,
	/[\xC8-\xCA]/g, /[\xE8-\xEB]/g,
	/[\xCC-\xCE]/g, /[\xEC-\xEE]/g,
	/[\xD2-\xD4]/g, /[\xF2-\xF4]/g,
	/[\xD9-\xDB]/g, /[\xF9-\xFB]/g ];

	var repChar=['A','a','E','e','I','i','O','o','U','u'];

	for(var i=0; i<rExps.length; i++)
	s=s.replace(rExps[i],repChar[i]);

	return s;
}


function getInternetExplorerVersion()
{

	var rv = -1; // Return value assumes failure.

	if (navigator.appName == 'Microsoft Internet Explorer')
	{

		var ua = navigator.userAgent;
		var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

		if (re.exec(ua) != null)
			rv = parseFloat(RegExp.$1);
    }
    
    return rv;

}


function LogVisit(sessionGUID,sessionID,source,customerCode)
{

    /*
    var b_lang = navigator.userLanguage;
    var os = navigator.oscpu;
    var resolution = screen.width + " x " + screen.height;
    */
    
    var browser = navigator.userAgent;
    var refer = document.referrer;
    var currentURL = document.location.pathname+document.location.search; //page+query string
    currentURL=URLEscape(currentURL);
    refer=URLEscape(refer);
    port="";
    if (document.location.port)
    {
        port=":"+document.location.port;
    }
    var logURL= "http://"+document.domain+port+"/logging/visitlog.aspx?ran="+Math.random();
    if (port == "") {
        logURL= "/logging/visitlog.aspx?ran="+Math.random();
    }
    var qstring = "&uastring="+browser+"&referrer="+refer+"&currentPage="+currentURL+"&sessionid="+sessionID+"&visitorGuid="+sessionGUID+"&source="+source+"&customerCode="+customerCode;

    var img = new Image(0,0);
    img.src=logURL+qstring;
    
}


function URLEscape(url)
{    
    return url.replace(/\?/g, "$**$").replace(/&/g,"$*$");
}


function GetElement(tagName,id)
{
	
	var elements = document.getElementsByTagName(tagName);
	
	var i =0;
	
	for ( i = 0; i < elements.length; i++)
	{        
		var element = elements[i];
	
		if(element.id.match(id+"$"))
			return element;
	}

	return null;

}


function ScrollToTop()
{
	$(document).ready
	(
		function ()
		{
			window.scrollTo(0, 0);
		}
	);
}


function ScrollToBottom()
{
	$(document).ready
	(
		function ()
		{
			window.scrollTo(0, 1500);
		}
	);
}


function TrimString(str)
{
    while (str.substring(0,1) == ' ') // check for white spaces from beginning
        str = str.substring(1, str.length);

    while (str.substring(str.length-1, str.length) == ' ') // check white space from end
        str = str.substring(0,str.length-1);

    return str;
}


function RemoveAccents(str)
{
	var s=str;

	var rExps=[ /[\xC0-\xC2]/g, /[\xE0-\xE2]/g,
	/[\xC8-\xCA]/g, /[\xE8-\xEB]/g,
	/[\xCC-\xCE]/g, /[\xEC-\xEE]/g,
	/[\xD2-\xD4]/g, /[\xF2-\xF4]/g,
	/[\xD9-\xDB]/g, /[\xF9-\xFB]/g ];

	var repChar=['A','a','E','e','I','i','O','o','U','u'];

	for(var i=0; i<rExps.length; i++)
	s=s.replace(rExps[i],repChar[i]);

	return s;
}


function ChangeBackgroundColor(element, colour)
{
	$(element).css("background-color", colour);
}


function isMouseLeaveOrEnter(e, handler)
{

	//-- http://www.dynamic-tools.net/toolbox/isMouseLeaveOrEnter/ --//
	if (e.type != 'mouseout' && e.type != 'mouseover')
		return false;
		
	var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;
	
	while (reltg && reltg != handler)
		reltg = reltg.parentNode;
		
	return (reltg != handler);

}


function SetUniqueRadioButton(nameregex, current)
{

   re = new RegExp(nameregex);
   
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
   
      elm = document.forms[0].elements[i]
      
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
            elm.checked = false;
      }
   
   }

   current.checked = true;

}


/*--------------/
/*  Validation  /
/*-------------*/

function ValidateOnClientSide(groupType)
{

	//-- Initialize --//
	validationControlsArray = "";
	thereIsNoError = true;
    
	//-- Loop ALL controls having rel="[groupType]" --//
	$("[rel=" + groupType + "]").each
	(

		function (intIndex) {

		    //-- Skip the spans, only go on for valid controls --//
		    if ((($(this).attr("type") == "text") || ($(this).attr("type") == "password")) && ($(this).attr("disabled") == false) && ($(this).attr("id").indexOf("txtMobile") == -1) && ($(this).attr("id").indexOf("txtBusiness") == -1)) {

		        //-- Call the ValidationBlur function, just in case the Submit button was clicked without any control change - the second parameter is the Group, stored in the TextBox's "tag" attribute --//
		        if ($(this).attr("id").indexOf("txtEmailAddressConfirm") != -1)
		            ValidationBlur($(this), $(this).attr("tag"), 'txtEmailAddress', groupType);
		        else if ($(this).attr("id").indexOf("txtRegEmailAddressConfirm") != -1)
		            ValidationBlur($(this), $(this).attr("tag"), 'txtRegEmailAddress', groupType);
		        else if ($(this).attr("id").indexOf("txtPasswordConfirm") != -1)
		            ValidationBlur($(this), $(this).attr("tag"), 'txtPassword', groupType);
		        else if ($(this).attr("id").indexOf("txtRegPasswordConfirm") != -1)
		            ValidationBlur($(this), $(this).attr("tag"), 'txtRegPassword', groupType);
		        else
		            ValidationBlur($(this), $(this).attr("tag"), '', groupType);

		        //-- Split array containing errors, skip if a previous error was found --//
		        var validationControls = validationControlsArray.split("|");

		        //-- Loop items in array --//
		        for (i = 0; i < validationControls.length; i++) {

		            //-- If the ID of the control is in the array in a way, it means we cannot proceed. Example: Control is "txtPassword" and there is an error "txtPasswordEmpty" --//
		            if (validationControls[i].indexOf(ValidationGetProperID($(this).attr("id"))) != -1) {
		                
                        //-- Focus on the first field which has an error --//
                        if(thereIsNoError)
		                    $(this).focus();
		                thereIsNoError = false;
		                break;
		            }

		        }

		    }

		}
	);

	return thereIsNoError;

}


function ValidationGetProperID(idToProper)
{

	//-- Return control ID without ASP.NET's ctl00_ctl01, etc. --//
	return idToProper.substr(idToProper.lastIndexOf("_") + 1, idToProper.length - idToProper.lastIndexOf("_"));

}


function ValidationShowErrors(groupType)
{

	if (validationControlsArray != "")
	{

		var validationControls = validationControlsArray.split("|");

		for (i = 0; i < validationControls.length; i++)
		{

			if ( validationControls[i] != "")
			{

				//-- Show THIS Error --//
				if ($("#" + validationControls[i]).attr("rel") == groupType)
				{

				    $("#" + validationControls[i]).show();
				    $("#" + validationControls[i]).focus();
			
					//-- E-Mail --//
					$("#" + (validationControls[i].replace("Empty", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValEmail")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValMatch")).hide();
					$("#" + (validationControls[i].replace("ValEmail", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValEmail", "") + "Empty")).hide();
					$("#" + (validationControls[i].replace("ValMatch", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValMatch", "") + "Empty")).hide();

					//-- E-Mail or Customer Code --//
					$("#" + (validationControls[i].replace("Empty", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValEmailCustomerCode")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValMatch")).hide();
					$("#" + (validationControls[i].replace("ValEmailCustomerCode", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValEmailCustomerCode", "") + "Empty")).hide();

					//-- Password --//
					$("#" + (validationControls[i].replace("Empty", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValPassword")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValMatch")).hide();
					$("#" + (validationControls[i].replace("ValPassword", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValPassword", "") + "Empty")).hide();
					$("#" + (validationControls[i].replace("ValMatch", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValMatch", "") + "Empty")).hide();

					//-- Customer Number --//
					$("#" + (validationControls[i].replace("Empty", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValCustNumber")).hide();
					$("#" + (validationControls[i].replace("ValCustNumber", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValCustNumber", "") + "Empty")).hide();

					//-- First Four --//
					$("#" + (validationControls[i].replace("Empty", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValFirstFour")).hide();
					$("#" + (validationControls[i].replace("ValFirstFour", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValFirstFour", "") + "Empty")).hide();

					//-- Name --//
					$("#" + (validationControls[i].replace("Empty", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValName")).hide();
					$("#" + (validationControls[i].replace("ValName", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValName", "") + "Empty")).hide();

					//-- Just Empty --//
					$("#" + (validationControls[i].replace("Empty", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValJustEmpty")).hide();
					$("#" + (validationControls[i].replace("ValJustEmpty", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValJustEmpty", "") + "Empty")).hide();

					//-- Landline Phone --//
					$("#" + (validationControls[i].replace("Empty", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValLandlinePhone")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValAtLeastOnePhone")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValDOB")).hide();
					$("#" + (validationControls[i].replace("ValLandlinePhone", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValLandlinePhone", "") + "Empty")).hide();
					$("#" + (validationControls[i].replace("ValAtLeastOnePhone", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValAtLeastOnePhone", "") + "Empty")).hide();
					$("#" + (validationControls[i].replace("ValDOB", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValDOB", "") + "Empty")).hide();
					
					//-- Mobile Phone --//
					$("#" + (validationControls[i].replace("Empty", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValMobilePhone")).hide();
					$("#" + (validationControls[i].replace("ValMobilePhone", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValMobilePhone", "") + "Empty")).hide();

					//-- Phone Numbers: FRENCH --//
					$("#" + (validationControls[i].replace("Empty", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValPhoneNumbersFR")).hide();
					$("#" + (validationControls[i].replace("Empty", "") + "ValAtLeastOnePhone")).hide();
					$("#" + (validationControls[i].replace("ValPhoneNumbersFR", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValPhoneNumbersFR", "") + "Empty")).hide();
					$("#" + (validationControls[i].replace("ValAtLeastOnePhone", "") + "Help")).hide();
					$("#" + (validationControls[i].replace("ValAtLeastOnePhone", "") + "Empty")).hide();

				}

			}

		}
	}

}


function ValidationBlur(controlToValidate, validationType, controlToValidateAgainst, groupType)
{


	$(".spanMessage").hide();

	//-- E-Mail Validation --//
	if (validationType == "Email")
	{

		//-- E-Mail is Empty --//
		if (ValidateEmpty($(controlToValidate).val()))
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtEmailAddressEmpty. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Empty").show();

			
		}
		
		//-- E-Mail not Validated --//
		else if ( !ValidateEmail($(controlToValidate).val()) )
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtEmailAddressValEmail. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValEmail" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValEmail" + "|";
			
			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValEmail").show();

			
		}

		//-- E-Mail not same as other control, we are sending the value of OUR control and the value of the control to validate against. Since the latter is running at server, we have to find it by using JQuery's "$" selector, hence ending with alongside its ClientID --//
		else if ( (controlToValidateAgainst != "") && (!CompareControl($(controlToValidate).val(), $("[id$=" + controlToValidateAgainst + "]").val())) )
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtRegEmailAddressValMatch. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValEmail" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch").show();

			
		}

		//-- E-Mail Validated --//
		else
		{
			
			//-- Remove THIS validator ID from the "|" delimited string --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValEmail" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch" + "|", "");
			
			//-- And hide both the ToolTip and the Error Message SPANs --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Help").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValEmail").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch").hide();
			
		}

	}

	//-- E-Mail or Customer Code Validation --//
	if (validationType == "EmailCustomerCode")
	{

		//-- E-Mail is Empty --//
		if (ValidateEmpty($(controlToValidate).val()))
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtEmailAddressEmpty. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Empty").show();

			
		}
		
		//-- E-Mail or Customer Code not Validated --//
		else if ( !ValidateEmailCustomerCode($(controlToValidate).val()) )
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtEmailAddressValEmail. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValEmailCustomerCode" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValEmailCustomerCode" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValEmailCustomerCode").show();

			
		}

		//-- E-Mail Validated --//
		else
		{
			
			//-- Remove THIS validator ID from the "|" delimited string --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValEmailCustomerCode" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch" + "|", "");
			
			//-- And hide both the ToolTip and the Error Message SPANs --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Help").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValEmailCustomerCode").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch").hide();
			
		}

	}

	//-- Password Validation --//
	else if (validationType == "Password")
	{

		//-- Password is Empty --//
		if (ValidateEmpty($(controlToValidate).val()))
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtPasswordEmpty. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Empty").show();

			
		}
		
		//-- Password not Validated --//
		else if ( !ValidatePassword($(controlToValidate).val()) )
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtPasswordValPassword. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValPassword" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValPassword" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValPassword").show();

			
		}

		//-- Password not same as other control, we are sending the value of OUR control and the value of the control to validate against. Since the latter is running at server, we have to find it by using JQuery's "$" selector, hence ending with alongside its ClientID --//
		else if ( (controlToValidateAgainst != "") && (!CompareControl($(controlToValidate).val(), $("[id$=" + controlToValidateAgainst + "]").val())) )
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtRegEmailAddressValMatch. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValPassword" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValPassword").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch").show();

			
		}

		//-- Password Validated --//
		else
		{

			//-- Remove THIS validator ID from the "|" delimited string --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValPassword" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch" + "|", "");
			
			//-- And hide both the ToolTip and the Error Message SPANs --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Help").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValPassword").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValMatch").hide();
			
		}

	}

	//-- Customer Number Validation --//
	else if (validationType == "CustomerNumber")
	{

		//-- Customer Number is Empty --//
		if (ValidateEmpty($(controlToValidate).val()))
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtCreatePassCustomerNumberEmpty. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Empty").show();

			
		}
		
		//-- Customer Number not Validated --//
		else if ( !ValidateCustomerNumber($(controlToValidate).val()) )
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtCreatePassCustomerNumberValCustNumber. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValCustNumber" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValCustNumber" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValCustNumber").show();

			
		}

		//-- Customer Number Validated --//
		else
		{
			
			//-- Remove THIS validator ID from the "|" delimited string --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValCustNumber" + "|", "");
			
			//-- And hide both the ToolTip and the Error Message SPANs --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Help").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValCustNumber").hide();
			
		}

	}

	//-- Last Name First Four Validation --//
	else if (validationType == "FirstFour")
	{

		//-- Last Name First Four is Empty --//
		if (ValidateEmpty($(controlToValidate).val()))
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtCreatePassFirstFourEmpty. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Empty").show();

			
		}
		
		//-- Last Name First Four not Validated --//
		else if ( !ValidateFirstFour($(controlToValidate).val()) )
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtCreatePassFirstFourValFirstFour. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValFirstFour" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValFirstFour" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValFirstFour").show();

			
		}

		//-- Last Name First Four Validated --//
		else
		{
			
			//-- Remove THIS validator ID from the "|" delimited string --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValFirstFour" + "|", "");
			
			//-- And hide both the ToolTip and the Error Message SPANs --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Help").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValFirstFour").hide();
			
		}

	}

	//-- Name Validation --//
	if (validationType == "Name")
	{

		//-- Name is Empty --//
		if (ValidateEmpty($(controlToValidate).val()))
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtPartOfAddressFirstName. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Empty").show();

			
		}
		
		//-- Name not Validated --//
		else if ( !ValidateName($(controlToValidate).val()) )
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtPartOfAddressFirstNameValName. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValName" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValName" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValName").show();
			
		}

		//-- Name Validated --//
		else
		{
			
			//-- Remove THIS validator ID from the "|" delimited string --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValName" + "|", "");
			
			//-- And hide both the ToolTip and the Error Message SPANs --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Help").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValName").hide();
			
		}

	}

	//-- Control that should not be empty Validation --//
	if (validationType == "JustEmpty")
	{

		//-- Control that should not be empty is Empty --//
		if (ValidateEmpty($(controlToValidate).val()))
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtPartOfAddressHouseNumber. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Empty").show();
			
		}

		//-- Control that should not be empty Validated --//
		else
		{
			
			//-- Remove THIS validator ID from the "|" delimited string --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValJustEmpty" + "|", "");
			
			//-- And hide both the ToolTip and the Error Message SPANs --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Help").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValJustEmpty").hide();
			
		}

	}

	//-- Landline Phone Number Validation --//
	if (validationType == "LandlinePhone")
	{

		//-- Landline Phone Number not Validated --//
		validateLandlinePhone = ValidateLandlinePhone($(controlToValidate).val());
				
		if (validateLandlinePhone != "0")
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtLandline. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValLandlinePhone" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValAtLeastOnePhone" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValDOB" + "|", "");
			
			if (validateLandlinePhone == "1")
			{
				validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValAtLeastOnePhone" + "|";
				$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValAtLeastOnePhone").show();
			}
			else if (validateLandlinePhone == "2")
			{
				validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValLandlinePhone" + "|";
				$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValLandlinePhone").show();
			}
			else if (validateLandlinePhone == "3")
			{
				validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValAtLeastOnePhone" + "|";
				validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValDOB" + "|";
				$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValAtLeastOnePhone").show();
				$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValDOB").show();
			}
			else if (validateLandlinePhone == "4")
			{
				validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValLandlinePhone" + "|";
				validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValDOB" + "|";
				$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValLandlinePhone").show();
				$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValDOB").show();
			}
			else if (validateLandlinePhone == "5")
			{
				validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValDOB" + "|";
				$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValDOB").show();
			}
			
		}

		//-- Landline Phone Number Validated --//
		else
		{
			
			//-- Remove THIS validator ID from the "|" delimited string --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValLandlinePhone" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValAtLeastOnePhone" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValDOB" + "|", "");
			
			//-- And hide both the ToolTip and the Error Message SPANs --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Help").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValLandlinePhone").hide();
			
		}

	}

	//-- Mobile Phone Number Validation --//
	if (validationType == "MobilePhone")
	{

		//-- Mobile Phone Number not Validated --//
		if ( !ValidateMobilePhone($(controlToValidate).val()) )
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtMobile. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValMobilePhone" + "|", "");
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValMobilePhone" + "|";

			//-- And show it! --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValMobilePhone").show();
			
		}

		//-- Mobile Phone Number Validated --//
		else
		{
			
			//-- Remove THIS validator ID from the "|" delimited string --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "Empty" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValMobilePhone" + "|", "");
			
			//-- And hide both the ToolTip and the Error Message SPANs --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Help").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValMobilePhone").hide();
			
		}

	}

	//-- Phone Numbers: FRENCH --//
	if (validationType == "PhoneNumberFR")
	{

		validationControlsArray = validationControlsArray.replace("txtPhoneHomeValAtLeastOnePhone|", "");
		validationControlsArray = validationControlsArray.replace("txtMobilePhoneValAtLeastOnePhone|", "");
		validationControlsArray = validationControlsArray.replace("txtBusinessPhoneValAtLeastOnePhone|", "");
		validationControlsArray = validationControlsArray.replace("txtLandlineValDOB|", "");

		//-- Validate ALL Phones --//
		validatePhonesFrench = ValidatePhoneNumbersFrench($(controlToValidate).attr("id"));

		//-- 0 = Validated --//
		if (validatePhonesFrench != "0")
		{

			//-- Store the ID of the SPAN in the "|" delimited string, ex: txtLandline. This is not running at server so the ID has no ctl00, etc. --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValPhoneNumbersFR" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValAtLeastOnePhone" + "|", "");
			
			if (validatePhonesFrench == "1")
			{
				validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValAtLeastOnePhone" + "|";
				$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValAtLeastOnePhone").show();
			}
			else if (validatePhonesFrench == "2")
			{
				validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValPhoneNumbersFR" + "|";
				$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValPhoneNumbersFR").show();
			}
			
		}

		//-- Landline Phone Number Validated --//
		else
		{
			
			//-- Remove THIS validator ID from the "|" delimited string --//
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValAtLeastOnePhone" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValPhoneNumbersFR" + "|", "");
			validationControlsArray = validationControlsArray.replace(ValidationGetProperID($(controlToValidate).attr("id")) + "ValDOB" + "|", "");
			
			//-- And hide both the ToolTip and the Error Message SPANs --//
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "Help").hide();
			$("#" + ValidationGetProperID($(controlToValidate).attr("id")) + "ValPhoneNumbersFR").hide();
			
		}

		if (!validationIsDateOfBirthValid)
		{
			validationControlsArray += ValidationGetProperID($(controlToValidate).attr("id")) + "ValDOB" + "|";
			$("[id$=ValDOB]").show();
		}

	}

	//-- If the "|" delimited string is NOT empty, show errors --//
	ValidationShowErrors(groupType);

}


function ValidationFocus(textBoxID, groupType)
{
	
	$(".spanMessage").hide();
	$("#" + textBoxID + "Help").show();

	//-- If the "|" delimited string is NOT empty, show errors --//
	ValidationShowErrors(groupType);

}


function ValidateEmail(value)
{		
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	return reg.test(value);
}


function ValidateEmailCustomerCode(value)
{	
	
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	if ( value.length <= 10 && !isNaN(value) )
		return true;
	else
		return reg.test(value);

}


function ValidateName(value)
{	
	return value.length >= 2;
}


function ValidateLandlinePhone(value)
{	

	//-- Legend --//
	//-- 1: Date of Birth is valid but both phone numbers are empty --//
	//-- 2: Date of Birth is valid, landline has a value and it's not correct --//
	//-- 3: Date of Birth is NOT valid and both phone numbers are empty --//
	//-- 4: Date of Birth is NOT valid, landline has a value and it's not correct --//
	//-- 5: Date of Birth is NOT valid but phone numbers are --//

	//-- Start with the date of birth, this is a small hack to validate the date as well --//
	day = controlToValidateAgainstValue = $("[id$=cmbDOBDay]").val();
	month = controlToValidateAgainstValue = $("[id$=cmbDOBMonth]").val();
	year = controlToValidateAgainstValue = $("[id$=cmbDOBYear]").val();
	dateOfBirth = day + "/" + month + "/" + year;

	//-- If in the Modify Details scree, the drop downs are not available, so ignore the date --//
	if (day == undefined)
		isDateOfBirthValid = true;
	else
		isDateOfBirthValid = ValidateDate(dateOfBirth);

	//-- Get value of mobile phone textbox --//
	controlToValidateAgainstValue = $("[id$=txtMobile]").val();

	//-- Now, if landline and mobile are BOTH empty, return "1" --//
	if (ValidateEmpty(value) && ValidateEmpty(controlToValidateAgainstValue))
	{
		if (isDateOfBirthValid)
			return "1";
		else
			return "3";
	}
	else
	{

		//-- If the landline has a value, validate it --//
		if (jQuery.trim(value).length != 0)
		{
			if (value.length != 11)
			{
				if (isDateOfBirthValid)
					return "2";
				else
					return "4";
			}
			else
			{
				firstTwo = value.substring(0, 2);

				if ((firstTwo != "01") && (firstTwo != "02"))
				{
					if (isDateOfBirthValid)
						return "2";
					else
						return "4";
				}
			}
		}
	}

	//-- If we reached this code, it means that phone numbers validated, so check the date --//
	if (isDateOfBirthValid)
		return "0";
	else
		return "5";

}


function ValidateMobilePhone(value)
{

	if (jQuery.trim(value).length != 0)
	{
		if (value.length != 11)
			return false;
		else
		{
			firstTwo = value.substring(0, 2);

			if (firstTwo != "07")
				return false;
		}
	}

	return true;

}


function ValidatePhoneNumbersFrench(controlToValidateID)
{	

	//-- Legend --//
	//-- 0: All validated --//
	//-- 1: All phone numbers are empty --//
	//-- 2: Number did not validate --//
	
	//-- Start with the date of birth, this is a small hack to validate the date as well --//
	day = controlToValidateAgainstValue = $("[id$=cmbDOBDay]").val();
	month = controlToValidateAgainstValue = $("[id$=cmbDOBMonth]").val();
	year = controlToValidateAgainstValue = $("[id$=cmbDOBYear]").val();
	dateOfBirth = day + "/" + month + "/" + year;

	//-- If in the Modify Details screen, the drop downs are not available, so ignore the date --//
	if (day == undefined)
		validationIsDateOfBirthValid = true;
	else
		validationIsDateOfBirthValid = ValidateDate(dateOfBirth);

	//-- Get value of mobile and business phone textbox --//
	homePhoneValue = $("[id$=txtPhoneHome]").val();
	homePhoneValue = homePhoneValue.replace("+", "");
	mobilePhoneValue = $("[id$=txtMobilePhone]").val();
	mobilePhoneValue = mobilePhoneValue.replace("+", "");
	businessPhoneValue = $("[id$=txtBusinessPhone]").val();
	businessPhoneValue = businessPhoneValue.replace("+", "");

	//-- Now, if landline,  mobile and business are ALL empty, return "1" --//
	if (ValidateEmpty(homePhoneValue) && ValidateEmpty(mobilePhoneValue) && ValidateEmpty(businessPhoneValue))
		return "1";
	else
	{

		//-- Home Number --//
		if (controlToValidateID.indexOf("txtPhone") != -1)
		{
			if (homePhoneValue.length == 0)
				return "0";

			if (homePhoneValue.length > 20)
				return "2";
			else
				return "0";
		}

		//-- Mobile Phone Number --//
		if (controlToValidateID.indexOf("txtMobilePhone") != -1)
		{
			if (mobilePhoneValue.length == 0)
				return "0";

			if (mobilePhoneValue.length > 20)
				return "2";
			else
			{
				firstTwo = mobilePhoneValue.substring(0, 2);

				if ((firstTwo != "06") && (firstTwo != "07"))
					return "2";
				else
					return "0";
			}

		}

		//-- Business Number --//
		if (controlToValidateID.indexOf("txtBusiness") != -1)
		{
			if (businessPhoneValue.length == 0)
				return "0";

			if (businessPhoneValue.length > 20)
				return "2";
			else
				return "0";
		}

	}

	return "";

}


function ValidatePassword(value)
{
	return ( (value.length>=4) && (value.length<=16) ); 
}


function ValidateEmpty(value)
{
	return jQuery.trim(value).length == 0;
}


function ValidateCustomerNumber(value)
{
    return value.length = 9 && value.match(/[0-9]/);
}


function ValidateFirstFour(value)
{
    return value.length <= 4 && value.match(/[A-Za-z]/);
}


function CompareControl(originalControlValue, controlToValidateAgainstValue)
{
    originalControlValue = originalControlValue.toLowerCase();
    controlToValidateAgainstValue = controlToValidateAgainstValue.toLowerCase();

    return originalControlValue == controlToValidateAgainstValue;
}


// Original JavaScript code by Chirp Internet: www.chirp.com.au
// Please acknowledge use of this code by including this header.
function ValidateDate(value)
{

    var minYear = 1902;
    var maxYear = (new Date()).getFullYear();
    var errorMsg = "";

    // regular expression to match required date format
    re = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
    
    if(value != '')
	{
		if(regs = value.match(re))
		{
			if(regs[1] < 1 || regs[1] > 31)
				errorMsg = "Invalid value for day: " + regs[1];
			else if(regs[2] < 1 || regs[2] > 12)
				errorMsg = "Invalid value for month: " + regs[2];
			else if(regs[3] < minYear || regs[3] > maxYear)
				errorMsg = "Invalid value for year: " + regs[3] + " - must be between " + minYear + " and " + maxYear;
		}
		else
			errorMsg = "Invalid date format: " + value;
	}
    
    if (errorMsg != "")
		return false;
    
    return true;

}


/*--------------/
/*  Front Page  /
/*-------------*/

function OpenFrontPageCountrySelector(e)
{
	countryWindow = dhtmlmodal.open('CountrySelector', 'iframe', '/countrySelector.aspx', '', 'width=802px,height=552px,top=0,left=0,center=1,resize=0,scrolling=1')	
}


/*----------/
/*  Header  /
/*---------*/

function HeadValidateSearch(searchTextBoxID, defaultText, notEnoughCharactersText)
{

	if (document.getElementById(searchTextBoxID).value != defaultText)
	{

		textToSearch = RemoveAccents(document.getElementById(searchTextBoxID).value);
		textToSearch = textToSearch.replace("/", " ");
		textToSearch = textToSearch.replace("+", " ");

		if (textToSearch.length < 3)
			document.getElementById(searchTextBoxID).value = notEnoughCharactersText;
		else
		{
			searchQuery = TrimString(textToSearch);
			searchQuery = searchQuery.replace(/\s\s+/g, ' ');
			searchQuery = searchQuery.replace(' ', "-").replace(' ', "-").replace(' ', "-");
			window.location = "/rechercher/results/" + searchQuery + ".aspx";
		}

	}
		
}


function HeadNewsletterRegister(txtNewsLetterClientID)
{
	newsletterWindow = dhtmlmodal.open('Newsletter', 'iframe', '/newsletterProcess.aspx?email=' + $("#" + txtNewsLetterClientID).val(), '', 'width=435px,height=100px,top=0,left=0,center=1,resize=0,scrolling=1')
}


function HeadMyAccountShow()
{
	$(".divMyAccountOpen").show();
}


function HeadMyAccountHide()
{
	$(".divMyAccountOpen").hide();
}


function HeadBasketShow()
{
	$(".divBasketOpen").show();
}


function HeadBasketHide()
{
	$(".divBasketOpen").hide();
}


function DeliveryBarShowPriceChoiceBox()
{
	$(".divPriceOpen").show();	
}


function DeliveryBarPriceHighlight()
{
	$("#divPriceChoiceInside").children(".divTitle").css("color", "#000000");
	$("#divPriceChoiceInside").css("background-color", "#FFFFFF");
}


function DeliveryBarPriceDeHighlight()
{
	$("#divPriceChoiceInside").css("background-color", "transparent");
	$("#divPriceChoiceInside").children(".divTitle").css("color", "#999999");
	$(".divPriceOpen").hide();
}


/*--------------------/
/*  Country Selector  /
/*-------------------*/

function DeliveryBarShowLanguageChoiceBox()
{
	$(".divDeliveryOpen").show();
	$(".divLBLeft").css("background-color", "#FFFFFF");
	$(".divLBLeft").css("backgroundImage", "none");
}


function DeliveryBarHighlight(divToHighlight)
{
	$(divToHighlight).children(".divText strong:first").css("color", "#000000");
	$(divToHighlight).children(".divFlags").css("color", "#333333");
}


function DeliveryBarDeHighlight(divToHighlight)
{
	$(divToHighlight).children(".divText strong:first").css("color", "#666666");
	$(divToHighlight).children(".divFlags").css("color", "#999999");
	$(".divDeliveryOpen").hide();
	$(".divLBLeft").css("backgroundImage", "url('/images/mainOptions/barBack.gif')");
}


function DeliveryBarShowContinent(continent)
{

	//-- Switch them all Off --//
	$("#divContinentAfrica").removeClass();
	$("#divContinentAfrica").addClass("divDelAfrica");
	$("#tableAfrica").hide();

	$("#divContinentAmerica").removeClass();
	$("#divContinentAmerica").addClass("divDelAmerica");
	$("#tableAmerica").hide();

	$("#divContinentAsia").removeClass();
	$("#divContinentAsia").addClass("divDelAsia");
	$("#tableAsia").hide();

	$("#divContinentEurope").removeClass();
	$("#divContinentEurope").addClass("divDelEurope");
	$("#tableEurope").hide();

	$("#divContinentOceania").removeClass();
	$("#divContinentOceania").addClass("divDelOceania");
	$("#tableOceania").hide();

	classToUse = $("#divContinent" + continent).attr("class");
	$("#divContinent" + continent).removeClass();	
	$("#divContinent" + continent).addClass(classToUse + "On");
	$("#table" + continent).fadeIn();

}


function DeliveryBarShowDaysCost(dayFrom, dayTo, fee, websiteLink, country)
{
	if (websiteLink == "")
	{
		
		//-- Country has no website --//
		$("#" + divWebsiteHasCountryClientID).hide();
		$("#" + divWebsiteHasNoCountryClientID).show();
		$(".divCountryLayerTop").css("padding-left", "172px");
		
		//-- Délai de livraison : --> 1 to 7 <-- --//
		$("#" + spanCountryDeliveryFromValueClientID).text(dayFrom);
		$("#" + spanCountryDeliveryToValueClientID).text(dayTo);

		//-- 1 --> to <-- 7 jours <-- --//
		$("#" + spanCountryDeliveryToClientID).text(toText);

		//-- 1 to 7 --> jours <-- --//
		$("#" + spanCountryDeliveryDaysClientID).text(daysText);
		
		//-- Coût de livraison : $ 25.90 --//
		$("#" + spanCountryDeliveryCostValueClientID).text(fee);

	}
	else
	{

		//-- Country has a website --//
		$("#" + divWebsiteHasCountryClientID).show();
		$("#" + divWebsiteHasNoCountryClientID).hide();
		$("#spanCountryDeliveryWebsite").text(websiteLink);
		$("#spanCountryDeliveryCountry").text(country);
		$(".divCountryLayerTop").css("padding-left", "70px");

	}
}


function DeliveryBarHideDaysCost(textToShow)
{
	
	//-- Country has NO website reset --//	
	$("#" + divWebsiteHasCountryClientID).hide();
	$("#" + divWebsiteHasNoCountryClientID).show();
	$(".divCountryLayerTop").css("padding-left", "172px");

	//-- Délai de livraison : --> 1 to 7 <-- --//
	$("#" + spanCountryDeliveryFromValueClientID).text("");
	$("#" + spanCountryDeliveryToValueClientID).text("");
	$("#" + spanCountryDeliveryToClientID).text("");
	$("#" + spanCountryDeliveryDaysClientID).text(pleaseChooseCountryText);

	//-- Coût de livraison : $ 25.90 --//
	$("#" + spanCountryDeliveryCostValueClientID).text(pleaseChooseCountryText);

}


/*----------------/
/*  Main Options  /
/*---------------*/

function HighlightMMOption(li)
{
	$(".divLevel2").hide();
	$(".liOther").css("border-top", "0px");
	$(".liOther").css("padding-top", "7px");
	$(li).css("border-top", "1px dotted #B0B0B0");
	$(li).css("padding-top", "6px");
	$(li).children(".divLevel2").show();
}


function DeHighlightMMOption(li)
{
	$(li).css("border-top", "0px");
	$(li).css("padding-top", "7px");
	$(".divLevel2").hide();		
}


/*----------/
/*  Footer  /
/*---------*/

function FooterHighlightItem(divToHighlight)
{
	
	//-- Switch On --//
	$(divToHighlight).css("backgroundImage", "url('/images/footer/colsback-On.png')");	
	$(divToHighlight).children(".divInner").children(".img").attr("src", $(divToHighlight).children(".divInner").children(".img").attr("src").replace("Off", "On"));
	$(divToHighlight).children(".divInner").css("color", "#F93196");

}


function FooterDeHighlightItem(divToHighlight)
{

	//-- Switch Off --//
	$(divToHighlight).css("backgroundImage", "url('/images/footer/colsback-Off.png')");	
	$(divToHighlight).children(".divInner").children(".img").attr("src", $(divToHighlight).children(".divInner").children(".img").attr("src").replace("On", "Off"));
	$(divToHighlight).children(".divInner").css("color", "#85BD49");

}


/*------------------------------/
/*  Module Product Scroll 1980  /
/*-----------------------------*/

function MS1980HighlightBox(divToHighlight)
{
	
	//-- Switch the box on if and only if it is not already selected --//
	if ($(divToHighlight).css("backgroundImage").indexOf("backSelected") == -1)
	{
		$(divToHighlight).css("backgroundImage", "url('/images/moduleScrollable1980/backOn.png')");	
		$(divToHighlight).css("color", "#FFFFFF");
	}

}


function MS1980DeHighlightBox(divToHighlight)
{
	
	//-- Switch the box off if and only if it is not already selected --//
	if ($(divToHighlight).css("backgroundImage").indexOf("backSelected") == -1)
	{
		$(divToHighlight).css("backgroundImage", "url('/images/moduleScrollable1980/backOff.png')");	
		$(divToHighlight).css("color", "#6D6D6D");
	}

}


function MS1980ChangePage(divToHighlight, action)
{

	//-- Switch them all off --//
	$(".divBox").css("backgroundImage", "url('/images/moduleScrollable1980/backOff.png')");	
	$(".divBox").css("color", "#6D6D6D");

	if ( (action != "prev") && (action != "next"))
	{

		//-- Select the box and call the scrollable function to actually change the products --//
		$(divToHighlight).css("backgroundImage", "url('/images/moduleScrollable1980/backSelected.png')");	
		$(divToHighlight).css("color", "#FFFFFF");

	}

}


function MS1980ChangePageByIndex(index)
{

	//-- Switch them all off --//
	$(".divBox").css("backgroundImage", "url('/images/moduleScrollable1980/backOff.png')");	
	$(".divBox").css("color", "#6D6D6D");

	//-- Select the box and call the scrollable function to actually change the products --//
	$("#divScroll-" + index).css("backgroundImage", "url('/images/moduleScrollable1980/backSelected.png')");	
	$("#divScroll-" + index).css("color", "#FFFFFF");

}


function MS1980HighlightImage(imageToHighlight, imageType)
{
	if (imageType == "SHP")
	    imageToHighlight.css('border', '1px solid #F93196').css('width', '178px').css('height', '178px')
	else
	    imageToHighlight.css('border', '1px solid #F93196').css('width', '192px').css('height', '192px')
}


function MS1980DeHighlightImage(imageToHighlight, imageType)
{
	if (imageType == "SHP")
	    imageToHighlight.css('border', '0px solid #F93196').css('width', '180px').css('height', '180px')
	else
	    imageToHighlight.css('border', '0px solid #F93196').css('width', '194px').css('height', '194px')
}


/*---------/
/*  Login  /
/*--------*/

function OpenLogin()
{
	loginWindow = dhtmlmodal.open('Login', 'iframe', '/login/loginLayer.aspx', '', 'width=900px,height=489px,top=0,left=0,center=1,resize=0,scrolling=1')
}


function InitializeLoginHeightForFirstTime()
{
	$(".drag-contentarea", parent.document.body).height(443);
	$("#Login", parent.document.body).height(489);
}


function ChangeLoginHeightAfterErrors()
{
	$(".drag-contentarea", parent.document.body).height(498);
	$("#Login", parent.document.body).height(434);
}


function LoginShowLogin()
{

	//-- Show Login --//
	$("#" + loginDivLoginID).show();
	$(".aForgotPass").show();
	$("#" + loginLnkLoginID).show();

	//-- Hide Forgot Password --//
	$("#" + loginDivForgotPasswordID).hide();
	$("#" + loginLnkForgotPassID).hide();
	$("#aReturnForgotPassword").hide();		

}


function LoginShowForgotPassword()
{

	//-- Hide Login --//
	$("#" + loginDivLoginID).hide();
	$(".aForgotPass").hide();
	$("#" + loginLnkLoginID).hide();

	//-- Show Forgot Password --//
	$("#" + loginDivForgotPasswordID).show();
	$("#" + loginLnkForgotPassID).show();
	$("#aReturnForgotPassword").show();		

}


/*--------------------/
/*  Guided Navigation /
/*-------------------*/

function GuidedNavChecked(liID)
{	
	if ($("#" + liID).attr("class") == "liOff")
	{
		$("#" + liID).removeClass();
		$("#" + liID).addClass("liOn");
	}
	else
	{
		$("#" + liID).removeClass();
		$("#" + liID).addClass("liOff");
	}
}


function GuidedNavCheckedColour(colourCounter)
{

	if ($("#liColour" + colourCounter).attr("class") == "liOn")
	{
		$("#liColour" + colourCounter).removeClass();
		$("#divColour" + colourCounter).removeClass();
	}
	else
	{
		$("#liColour" + colourCounter).addClass("liOn");
		$("#divColour" + colourCounter).addClass("divOn");
	}

	return false;

}


function GuidedNavigationHideNumberOfProducts()
{
	$("[id^=spanNoOfProducts]").hide();
	$(".divColourNoOfProductsTooltip").hide();	
}


function GuidedNavigationShowNumberOfProducts(collectionID)
{
	$("#spanNoOfProducts" + collectionID).show();
}


function GuidedNavigationShowNumberOfProductsColour(divID)
{
	$("#" + divID).show();
}


function GuidedNavigationShowNumberOfProductsOther(spanID)
{
	$("#" + spanID).show();
}


function GuidedNavigationSelectLIs()
{

	var splitString = $("#" + guidedNavLIToSelectID).val().split("|");

	for(i = 0; i < splitString.length; i++)
	{
		if (splitString[i] != "")
			GuidedNavChecked(splitString[i]);
	}

	var splitStringColours = $("#" + guidedNavLIToSelectColourID).val().split("|");

	for(i = 0; i < splitStringColours.length; i++)
	{
		if (splitStringColours[i] != "")
			GuidedNavCheckedColour(splitStringColours[i]);
	}

}


function CGuidedNavPriceRange(from, to, uniqueID, link)
{
    this.from = from;
    this.to = to;
    this.uniqueID = uniqueID;
    this.link = link;
}


function GuidedNavPriceRangeChange()
{

	//-- If the value of the FROM drop down is different than the hidden field, we can proceed --//
	if ($("#cmbPriceRangeFrom").val() != $("#hidPriceRangeFrom").val())
	{
		
		//-- Set the new value of the hidden field --//
		$("#hidPriceRangeFrom").val($("#cmbPriceRangeFrom").val());

		//-- Loop Array --//
		for ( i=0; i < priceRangeArray.length; i++)
		{

			//-- Get Item --//
			priceRange = priceRangeArray[i];

			//-- If the drop downs' from and to match this array element, redirect customer --//
			if ((priceRange.from == $("#cmbPriceRangeFrom").val()) && (priceRange.to == $("#cmbPriceRangeTo").val()))
				window.location = priceRange.link;

		}
		
	}

	//-- If the value of the TO drop down is different than the hidden field, we can proceed --//
	if ($("#cmbPriceRangeTo").val() != $("#hidPriceRangeTo").val())
	{
		
		//-- Set the new value of the hidden field --//
		$("#hidPriceRangeTo").val($("#cmbPriceRangeTo").val());
		
		//-- Loop Array --//
		for ( i=0; i < priceRangeArray.length; i++)
		{
			
			//-- Get Item --//
			priceRange = priceRangeArray[i];

			//-- If the drop downs' from and to match this array element, redirect customer --//
			if ((priceRange.from == $("#cmbPriceRangeFrom").val()) && (priceRange.to == $("#cmbPriceRangeTo").val()))
				window.location = priceRange.link;
		}

	}

}


function GuidedNavigationPreSelectPriceRange(priceRangeID)
{

	if(typeof(priceRangeArray) !== 'undefined' && priceRangeArray != null)
	{

		//-- Loop Array --//
		for (i = 0; i < priceRangeArray.length; i++)
		{

			//-- Get Item --//
			priceRange = priceRangeArray[i];

			//-- Item ID Found! --//
			if (priceRange.uniqueID == priceRangeID)
			{
				$("#cmbPriceRangeFrom").val(priceRange.from);
				$("#cmbPriceRangeTo").val(priceRange.to);
				break;
			}

		}

	}

}


function GuidedNavigationShowAllBrands()
{
	$("#divAllBrands").removeClass();
	$("#divAllBrands").addClass("divAllBrandsSelected");
	$("#divAllBrandsOpen").show();
}


function GuidedNavigationHideAllBrands()
{
	$("#divAllBrands").removeClass();
	$("#divAllBrands").addClass("divAllBrands");
	$("#divAllBrandsOpen").hide();
}


/*--------------/
/*  Quick Zoom  /
/*-------------*/

function OpenQuickZoom(windowTitle, productID, documentID)
{
	quickZoomWindow = dhtmlmodal.open('QuickZoom', 'iframe', '/products/quickZoom.aspx?productID=' + productID + '&documentID=' + documentID, "", 'width=813px,height=575px,top=0,left=0,center=1,resize=0,scrolling=1')
}


/*-----------------------/
/*  Single Product Page  /
/*----------------------*/

function CProduct(reference, friendlySize, basketSize, colour, salePriceBefore, salePriceAfterWhole, salePriceAfter, currencySign, availability, availabilityCode, largeImage, substitute, productID, documentID, discountPercentage, partPaymentCost, partPaymentCostTotal, isMiniPrice, isRed, isGreen)
{
    this.reference = reference;
    this.friendlySize = friendlySize;
    this.basketSize = basketSize;
    this.colour = colour;
    this.salePriceBefore = salePriceBefore;
    this.salePriceAfterWhole = salePriceAfterWhole;
    this.salePriceAfter = salePriceAfter;
    this.currencySign = currencySign;
    this.availability = availability;
    this.availabilityCode = availabilityCode;
    this.largeImage = largeImage;
    this.substitute = substitute;
    this.productID = productID;
    this.documentID = documentID;
    this.discountPercentage = discountPercentage;
    this.partPaymentCost = partPaymentCost;
    this.partPaymentCostTotal = partPaymentCostTotal;
	this.isMiniPrice = isMiniPrice;
	this.isRed = isRed;
	this.isGreen = isGreen;
}


function CDistinctColours(colour)
{
	this.colour = colour;
}


function SPPShowCurrencyChange(pageURL)
{    
	currencyChangeWindow = dhtmlmodal.open('CurrencyChange', 'iframe', '/currencyChange.aspx?comingFrom=' + encodeURIComponent(pageURL), '', 'width=400px,height=150px,top=0,left=0,center=1,resize=0,scrolling=1')
}


function SPPShowZoomImage()
{
	window.open(zoomedImage);
}


function SPPShowLongDescription()
{
	if (longDescriptionShown == "0")
	{
		$("#" + sppLblDescriptionID).html(longDescription);
		longDescriptionShown = "1";
		$("#" + sppLblReadMoreID).html(sppReadLess + " &uarr;");
	}
	else
	{
		$("#" + sppLblDescriptionID).html(longDescriptionTrimmed);
		longDescriptionShown = "0";
		$("#" + sppLblReadMoreID).html(sppReadMore + " &darr;");
	}
}


function SPPSwitchTab(tabNumber)
{

	//-- Switch ALL Tabs Off --//
	$("#divSPPTab1").removeClass();
	$("#divSPPTab1").addClass("divOff");
	$("#divSPPTab2").removeClass();
	$("#divSPPTab2").addClass("divOff");
	$("#divSPPTab3").removeClass();
	$("#divSPPTab3").addClass("divOff");

	//-- And Switch On --//
	$("#divSPPTab" + tabNumber).addClass("On");
	$("#divSPPTabContent").html(eval("tab" + tabNumber + "Content"));

}


function SPPShowLargePhoto(imgID, imagePath)
{

	//-- If there is an image switch in progress, retry later --//
	if( isImageSwitching == 1)
	{
		tryChangeImageTimer = setTimeout(function(){SPPShowLargePhoto(imgID,imagePath)},20);
		return;
	}

	clearTimeout(tryChangeImageTimer);

	if (imagePath != currentBigImage)
	{
		clearTimeout(changeImageTimer);
		currentBigImage = imagePath;
		changeImageTimer = setTimeout(function(){SPPShowLargePhotoTimeOut(imgID, imagePath)}, 300);
	}	

}


function SPPShowLargePhotoTimeOut(imgID, imagePath)
{

	//isImageSwitching = 1;
	isImageSwitching = 0;
	
	$("#" + imgID).ImageSwitch
	(		
		{Type:"FadeIn", Speed:1000, StartLeft: 0, NewImage:imagePath},
		function()
		{
			isImageSwitching = 0;
		}	
	); 

}


function ColourChanged(cmbSizeClientID, selectedColour)
{

    //-- Get the Sizes DropDownList --//
    cmbSize = document.getElementById(cmbSizeClientID);
    cmbColour = document.getElementById(sppCmbColoursID);

    //-- 1 because of the about-to-be-added first item, Please Choose Size --//
    next = 1;

    //-- Before removing all items of the Sizes drop down, save the currently selected sizes so as to re-choose it later on --//
    previouslySelectedSize = cmbSize.value;

    //-- Clear the sizes DropDownList --//
    cmbSize.options.length = 0;

    //-- First of all, create "Please Choose Size" Item --//
    var newOptionFirst = new Option(pleaseChooseSize, "-1");
    cmbSize.options[0] = newOptionFirst;
    firstSize = "-1";

    //-- Loop Items --//
    for (i = 0; i < productsArray.length; i++)
	{

		//-- Get Products --//
        product = productsArray[i];

		//-- Colour Found --//
        if (product.colour == selectedColour)
		{

            //-- Create size item --//
            var newOption = new Option(product.friendlySize, product.basketSize);

            //-- Add size item to sizes DropDownList --//
            cmbSize.options[next] = newOption;

            //-- If the size is the one which was selected when the colour changed, select it for the customer --//
            if (cmbSize.options[next].value == previouslySelectedSize)
			{
                cmbSize.selectedIndex = next;
                firstSize = previouslySelectedSize;
            }

			//-- Set Image --//
			$("#" + sppImgMainPhotoID).attr("src", product.largeImage);    

			//-- Increment size counter --//
            next++;

        }

    }

    //-- Let's say colour "Red" and size 038 are chosen and then I choose colour "Blue" which DOES not have
    //-- colour 038 as part of its selection. This means that SizeChanged has to be called with
    //-- cmbSize.options[0].value so as the size of index 0 is selected automatically.
    //
    //-- But, if both colours have 038, then I will call SizeChanged by passing the value of firstSize, which
    //-- was initialized above, so as size 038 is kept as selection, even after changing colour.
    firstSizeIsActive = false;

    //-- Loop ALL sizes to determine whether size is part of the new colour --//
    for (i = 0; i < cmbSize.options.length; i++)
	{
        if (cmbSize.options[i].value == firstSize)
		{
            firstSizeIsActive = true;
            break;
        }
    }

    //-- Decide how to call SizeChanged --//
    if (firstSizeIsActive)
        SizeChanged(firstSize, selectedColour);
    else if (cmbSize.options[0] != null)
        SizeChanged(cmbSize.options[0].value, selectedColour);

}


function SizeChanged(selectedSize, selectedColour)
{

	//-- Hide --//
	$("#" + sppDivAddToCartOffID).show();
	$("#" + sppAddToCartID).hide();
	$("#" + sppLblAvailabilityID).text("");

	//-- Clear Colours Drop Down Menu --//
	next = 0;
	cmbColour = document.getElementById(sppCmbColoursID);
	cmbColour.options.length = 0;
	
    //-- -1 means "Please Choose Size" --//
    if (selectedSize != -1)
	{

		previouslySelectedColourIsAvailable = false;
	
        //-- Loop ALL Products --//
        for (i = 0; i < productsArray.length; i++)
		{

            //-- Get Product --//
            product = productsArray[i];

			//-- Populate Colours Drop Down --//
			if (product.basketSize == selectedSize)
			{

		        //-- Create colour item --//
				var newOption = new Option(product.colour, product.colour);

				if (product.colour == selectedColour)
					previouslySelectedColourIsAvailable = true;

				//-- Add colour item to colours DropDownList --//
				cmbColour.options[next] = newOption;

				//-- Make sure to keep the selected colour --//
				if (cmbColour.options[next].value == selectedColour)
					cmbColour.selectedIndex = next;

				next++;

			}

		}

		//-- Let's say that I open the page and I have Red, Green and Blue in the Colours drop down menu and
		//-- 34/36, 38/40 and 42/44 in the Sizes drop down menu. I change the size and enter this function with
		//-- selectedColour = "Red" but for the size I chosen, 42/44, Red is not available. This means that the
		//-- below condition if ((product.colour == selectedColour) && (product.basketSize == selectedSize))
		//-- will not be hit and the Add to Cart button will not switch on. This is why I am making sure - in
		//-- case of this scenario - to manually change selectedColour to the first available colour for this
		//-- size.

		if (previouslySelectedColourIsAvailable == false)
			selectedColour = $("#" + sppCmbColoursID).val();

        //-- Now Loop ALL Products again to see if we have a size + colour match --//
        for (i = 0; i < productsArray.length; i++)
		{

            //-- Get Product --//
            product = productsArray[i];

			//-- Is this the product we need? --//
            if ((product.colour == selectedColour) && (product.basketSize == selectedSize))
			{

				//-- Both a colour and a size are selected, so set Hidden Fields --//
				$("#" + sppHidProductReferenceID).val(product.reference);
				$("#" + sppHidSizeID).val(product.basketSize);

				//-- Price --//
                $("#" + sppLblPriceID).text(product.salePriceAfter);

				//-- Price Type --//
				if (product.isMiniPrice == "True")
				{
					$("#" + sppLblPriceTypeID).html(miniPriceText);
					$("#pPriceType").addClass("pPriceColourMini");
				}

				else if (product.isRed == "True")
				{
					$("#" + sppLblPriceTypeID).html(redPriceText);
					$("#pPriceType").addClass("pPriceColourRed");
				}

				else if (product.isGreen == "True")
				{
					$("#" + sppLblPriceTypeID).html(greenPriceText);
					$("#pPriceType").addClass("pPriceColourGreen");
				}

				//-- Availability --//
				$("#" + sppLblAvailabilityID).text(product.availability);

				//-- Discount --//
                if (product.discountPercentage == "0")
					$("#" + sppPDiscountID).hide();
                else                    
				{
					$("#" + sppPDiscountID).show();
					$("#" + sppPriceOldID).text(product.salePriceBefore);
					$("#" + sppLblPercentageID).text(product.discountPercentage + "%");				
				}

				//-- Enable the Add to Cart button if the item is available --//
				if (product.availabilityCode != "E")
				{
					$("#" + sppDivAddToCartOffID).hide();
					$("#" + sppAddToCartID).show();
				}
				else
					$("#divAddToCartToolTip").text(sorryItemIsOutOfStock);

                break;

            }

        }

    }
	else
	{

        //-- Loop ALL Distinct Colours --//
        for (i = 0; i < disColoursArray.length; i++)
		{

            //-- Get Product --//
            disColour = disColoursArray[i];

	        //-- Create colour item --//
			var newOption = new Option(disColour.colour, disColour.colour);

			//-- Add colour item to colours DropDownList --//
			cmbColour.options[next] = newOption;

			//-- Make sure to keep the selected colour --//
			if (cmbColour.options[next].value == selectedColour)
				cmbColour.selectedIndex = next;

			next++;

		}

	}

}


function ShowChooseSizeToolTip()
{
	$("#divAddToCartToolTip").show();
	$("#divAddToCartToolTip").text(pleaseChooseColSize);
}


function HideChooseSizeToolTip()
{
	$("#divAddToCartToolTip").hide();
}


function ChangeSizeColourViaAvailabilityGrid(selectedSize, selectedColour)
{

    //-- Get the Sizes DropDownList --//
    cmbSize = document.getElementById(sppCmbSizesID);

    //-- Loop sizes to find the one selected from the availability grid
    for (i = 0; i < cmbSize.options.length; i++)
	{
        if (cmbSize.options[i].value == selectedSize)
		{
            cmbSize.selectedIndex = i;
            break;
        }
    }

    //-- Get the Colours DropDownList --//
    cmbColour = document.getElementById(sppCmbColoursID);

    //-- Loop colours to find the one selected from the availability grid --//
    for (i = 0; i < cmbColour.options.length; i++)
	{
        if (cmbColour.options[i].value == selectedColour)
		{
            cmbColour.selectedIndex = i;
            break;
        }
    }

    //-- Select size + colour combination --//
    ColourChanged(sppCmbSizesID, selectedColour);

}


function SPPShowAvailabilityGrid()
{
	$("#divAvailabilityGrid").fadeIn();
}


function SPPCloseAvailabilityGrid()
{
	$("#divAvailabilityGrid").fadeOut();
}


function SPPOpenSendFriend(productID, documentID)
{
	sendToFriendWindow = dhtmlmodal.open('SendToFriend', 'iframe', '/productDetails/sendToFriend.aspx?productID=' + productID + '&documentID=' + documentID, '', 'width=512px,height=570px,top=0,left=0,center=1,resize=0,scrolling=1')
}


function SPPOpenAddToCartLayer()
{

    //-- Open Layer --//
	addToCartWindow = dhtmlmodal.open('AddToCart', 'iframe', '/productDetails/addToCartLayer.aspx', '', 'width=759px,height=475px,top=0,left=0,center=1,resize=0,scrolling=1')

}


function SPPOpenAddToCartLayerQuickZoom()
{

    //-- Open Layer --//
	parent.quickZoomWindow.hide();
	parent.quickZoomWindow.close();
	parent.window.location = parent.window.location;

}


function SPPAfterItemAddedToCart()
{
	SizeChanged($("#" + sppCmbSizesID).val(), $("#" + sppCmbColoursID).val());
}


/*--------------------/
/*  Send to a Friend  /
/*-------------------*/

function SendFValidate()
{

	var _txtTo = document.getElementById("ctl00_cphMain_ctl00_txtFriendEmail");
	var _txtMessage = document.getElementById("ctl00_cphMain_ctl00_txtMessage");
	var _txtFrom = document.getElementById("ctl00_cphMain_ctl00_txtYourFullName");
	var _chkReceiveCopy = document.getElementById("ctl00_cphMain_ctl00_chkSendEmail");
	var _txtFromEmail = document.getElementById("ctl00_cphMain_ctl00_txtYourEmailAddress");
	
	var i;
	var regEx = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
				
	if(_txtTo.value=="" && _txtTo.value.length >0)
	{
		alert(errorFriendEmail);
		_txtTo.focus();
		return false;
	}
	else
	{
		var sendToFriendEmailArray = _txtTo.value.split(",");
		var result = SendFEmailValidation(sendToFriendEmailArray, errorFriendEmail);

		_txtTo.focus();
		_txtTo.select();
		if (!result)
			return false;
	}			
	 			
	if(_txtMessage.value=="")
	{
		alert(errorMessage);
		_txtMessage.focus();
		return false;
	}
				
	if(_txtFrom.value=="")
	{
		alert(errorYourFullName);
		_txtFrom.focus();
		return false;
	}
				
	if(_chkReceiveCopy.checked)
	{

		if(_txtFromEmail.value=="" && _txtFromEmail.value.length <= 0)
		{
			alert(errorYourEmail);
			_txtFromEmail.focus();
			return false;
		}
		else
		{
			var sendToFriendEmailArray = _txtFromEmail.value.split(",");
			var result = SendFEmailValidation(sendToFriendEmailArray, errorYourEmail);

			_txtFromEmail.focus();
			_txtFromEmail.select();
			if (!result)
				return false;
		}

	}
				
}


function SendFEmailValidation(arr, msg)
{
			
	for(i=0;i<arr.length;i++)
	{

		var at="@"
		var dot="."
		var lat=arr[i].indexOf(at)
		var lstr=arr[i].length
		var ldot=arr[i].indexOf(dot)
					
		if (arr[i].indexOf(at)==-1)
		{
			alert(msg);
			return false;
		}

		if (arr[i].indexOf(at)==-1 || arr[i].indexOf(at)==0 || arr[i].indexOf(at)==lstr)
		{
			alert(msg);
			return false;
		}

		if (arr[i].indexOf(dot)==-1 || arr[i].indexOf(dot)==0 || arr[i].indexOf(dot)==lstr)
		{
			alert(msg);
			return false;
		}

		if (arr[i].indexOf(at,(lat+1))!=-1)
		{
			alert(msg);
			return false;
		}

		if (arr[i].substring(lat-1,lat)==dot || arr[i].substring(lat+1,lat+2)==dot)
		{
			alert(msg);
			return false;
		}

		if (arr[i].indexOf(dot,(lat+2))==-1)
		{
			alert(msg);
			return false;
		}
					
		if (arr[i].indexOf(" ")!=-1)
		{
			alert(msg);
			return false;
		}
					
 	}

 	return true;

}

/*---------------/
/*  Size Charts  /
/*--------------*/

function OpenSizeCharts()
{
	sizeChartsWindow = dhtmlmodal.open('SizeCharts', 'iframe', '/help/sizes.aspx', "", 'width=982px,height=440px,top=0,left=0,center=1,resize=0,scrolling=1')
}

function OpenSizeCharts(collectionId) {
    sizeChartsWindow = dhtmlmodal.open('SizeCharts', 'iframe', '/help/sizes.aspx?on=' + collectionId, "", 'width=982px,height=440px,top=0,left=0,center=1,resize=0,scrolling=1')
}


function SizeChartsSwitchAllOff(classToLeaveOn)
{

    //-- Switch them all off --//
	if (classToLeaveOn != "womenImgNav")
		$(".womenImgNav").attr("src", $(".womenImgNav").attr("src").replace("On", "Off"));
	
	if (classToLeaveOn != "menImgNav")
		$(".menImgNav").attr("src", $(".menImgNav").attr("src").replace("On", "Off"));

	if (classToLeaveOn != "childrenImgNav")
		$(".childrenImgNav").attr("src", $(".childrenImgNav").attr("src").replace("On", "Off"));

	if (classToLeaveOn != "shoesImgNav")
		$(".shoesImgNav").attr("src", $(".shoesImgNav").attr("src").replace("On", "Off"));

	if (classToLeaveOn != "lingerieImgNav")
		$(".lingerieImgNav").attr("src", $(".lingerieImgNav").attr("src").replace("On", "Off"));

	if (classToLeaveOn != "homeImgNav")
		$(".homeImgNav").attr("src", $(".homeImgNav").attr("src").replace("On", "Off"));

}


function SizeChartsNavigationOn(imgToChange, type)
{

    //-- Switch them all off --//
	SizeChartsSwitchAllOff();

    //-- Switch ON this one --//
	$(imgToChange).attr("src", $(imgToChange).attr("src").replace("Off", "On"));
}

function SizeChartsNavigationChange(section)
{
    $("#" + section + "ImgNav").mouseover();

    if (section == "women") {
        window.location = "#";
    } else {
        window.location = "#" + section;
    }
}


/*--------/
/*  Help  /
/*-------*/

function HelpHighlightSection(divToHighlight)
{
	$(divToHighlight).addClass("divItemOuterHighlighted");
	$(divToHighlight).children(".divItem").css("color", "#F93196");
	$(divToHighlight).children(".divItem").css("background-image", $(divToHighlight).children(".divItem").css("background-image").replace("Off", "On"));
}


function HelpDeHighlightSection(divToHighlight)
{
	$(divToHighlight).removeClass("divItemOuterHighlighted");
	$(divToHighlight).children(".divItem").css("color", "#85BD49");
	$(divToHighlight).children(".divItem").css("background-image", $(divToHighlight).children(".divItem").css("background-image").replace("On", "Off"));
}


/*----------------/
/*  Registration  /
/*---------------*/

function SetCityZipCodeRegistration(cmbCtrlId, txtZipCodeId, hidCityId)
{

    var cmb = $("#" + cmbCtrlId);
    var selectedOption = $("#" + cmbCtrlId + " option:selected");
    var city = $.trim(selectedOption.text().split('-')[0]);
    $("#" + hidCityId).val(city);

    if (city == "")
        city = $.trim(selectedOption.text());
 
    var zip = selectedOption.val();

    if (zip != "")
        $("#" + txtZipCodeId).val(zip);        

}


function SetAddressField(cmbCtrlId, txtStreetId)
{

    var cmb = $("#" + cmbCtrlId);
    var selectedOption = $("#" + cmbCtrlId + " option:selected");
    var street = selectedOption.val();
    
	if (street != "")
        $("#" + txtStreetId).val(street);

}


function RegisterDisableZIPCode()
{

    //-- Store Value in Hidden Field --//
	$("#" + hidZIPCodeClientID).val($("#" + txtZIPCodeClientID).val());

    //-- Enable or Disable? --//
	if ($("#" + txtZIPCodeClientID).attr("disabled") == true)
		$("#" + txtZIPCodeClientID).removeAttr("disabled")
	else
		$("#" + txtZIPCodeClientID).attr("disabled", "disabled");

    //-- Important: Hide any error messages related to the text box txtZIPCode --//
	validationControlsArray = validationControlsArray.replace("txtZIPCodeEmpty|", "").replace("txtZIPCodeValJustEmpty|", "");
	$("#txtZIPCodeEmpty").hide();
	$("#txtZIPCodeHelp").hide();
	$("#txtZIPCodeValJustEmpty").hide();

}


function RegisterOpenModifyDetails()
{
	modifyDetailsWindow = dhtmlmodal.open('ModifyDetails', 'iframe', '/webAccount/modifyDetailsLayer.aspx', '', 'width=920px,height=540px,top=0,left=0,center=1,resize=0,scrolling=1')
}


function RegisterOpenZIPCodeExplanation()
{
	zipCodeWindow = dhtmlmodal.open('ZIPCode', 'iframe', '/webAccount/zipCodeExplanation.aspx', '', 'width=400px,height=250px,top=0,left=0,center=1,resize=0,scrolling=1')
}


/*--------------/
/*  Help Pages  /
/*-------------*/

function HelpInitializeFAQ()
{

    //-- Switch them all off --//
	$(".pFAQ").hide();
	$(".tableFAQ").hide();
	$(".spanFAQ").hide();

}


function HelpShowFAQ(idToShow)
{

    //-- Switch them all off --//
	$(".pFAQ").hide();
	$(".tableFAQ").hide();
	$(".spanFAQ").hide();

	if ($("#pFAQ" + idToShow).css("display") == "none")
	{
		$("#pFAQ" + idToShow).fadeIn();
		$("#tableFAQ" + idToShow).fadeIn();
		$("#spanFAQ" + idToShow).fadeIn();
	}
	else
		$("#pFAQ" + idToShow).fadeOut();

	window.location.hash = "aFAQ" + idToShow;

}


/*--------------/
/*  My Account  /
/*-------------*/

function MyAccountOpenReturns()
{
	returnsWindow = dhtmlmodal.open('Returns', 'iframe', '/myAccount/myReturnsLayer.aspx', '', 'width=400px,height=250px,top=0,left=0,center=1,resize=0,scrolling=1')
}


function MyAccountOpenRefunds()
{
	refundsWindow = dhtmlmodal.open('Refunds', 'iframe', '/myAccount/myRefundsLayer.aspx', '', 'width=400px,height=250px,top=0,left=0,center=1,resize=0,scrolling=1')
}


/*---------------/
/*  ImageSwitch  /
/*--------------*/

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('b T=9(1t,1R){c(!$("#T")){$("13").L("<H C=\'T\'></H>")}c(1R){$("#T").1h($("#T").1h()+"<2a/>"+1t)}A{$("#T").1h($("#T").1h()+1t)}};(9($){$.1v.2d=9(1Q,1C){b 1P={1Y:"19",f:"",X:J,w:2e,i:1J,h:0,S:0,u:-1J,v:0,s:0,1c:"1e",10:"",1o:"",15:""};b 5=$.25(1P,1Q);b 3=y;b l=0;b 6;b j;b B;b r=9(){3.U("P",-1)};c($.1k(1C)){r=9(){1C();3.U("P",-1)}}b 1X=9(){3.2c().L("<V N=\'G\' C=\'"+6.M("#","")+"\'/>");$(6).g("e",3.g("e"));$(6).4("d","q");$(6).4("7",3.d().7);$(6).4("8",3.d().8);$(6).4("t",1);3.g("e",5.f);c(5.X){3.4("t",5.S);3.x({"t":1},5.w)}$(6).x({"t":0},5.w,9(){$(6).F();r()})};b 1n=9(19){$("13").L("<V N=\'G\' C=\'"+6.M("#","")+"\'/>");$(6).4("d","q");c(19){$(6).g("e",5.f);$(6).4("7",3.k().7+5.h);$(6).4("8",3.k().8+5.i);$(6).4("t",5.S);v=3.k().7;u=3.k().8;s=1}A{$(6).g("e",3.g("e"));3.g("e",5.f);$(6).4("7",3.k().7);$(6).4("8",3.k().8);$(6).4("t",1);v=3.k().7+5.v;u=3.k().8+5.u;s=5.s}$(6).x({"t":s,"7":v,"8":u},5.w,9(){3.g("e",5.f);$(6).F();r()})};b 12=9(12){$("13").L("<V N=\'G\' C=\'"+6.M("#","")+"\'/>");$(6).4("d","q");c(12){$(6).g("e",5.f);$(6).4("7",3.k().7+5.h);$(6).4("8",3.k().8+5.i);$(6).4("t",5.S);$(6).4("o",1M);$(6).4("p",1M);$(6).4("z-O","2f");v=3.k().7;u=3.k().8;s=1;c(R.1L.1K){$(y).1g(1N,9(){$(5.15).4("D-1a","Z("+5.f+")")})}A{$(y).1g(1O,9(){$(5.15).4("D-1a","Z("+5.f+")")})}}$(6).x({"t":s,"7":v,"8":u},5.w,9(){3.g("e",5.f);$(6).F();r()})};b 16=9(16){$("13").L("<V N=\'G\' C=\'"+6.M("#","")+"\'/>");$(6).4("d","q");c(16){$(6).g("e",5.f);$(6).4("7",3.k().7+5.h);$(6).4("8",3.k().8+5.i);$(6).4("t",5.S);v=3.k().7;u=3.k().8;s=1;c(R.1L.1K){$(y).1g(1N,9(){$(5.15).4("D-1a","Z("+5.f+")")})}A{$(y).1g(1O,9(){$(5.15).4("D-1a","Z("+5.f+")")})}}$(6).x({"t":s,"7":v,"8":u},5.w,9(){3.g("e",5.f);$(6).F();r()})};b 1z=9(17){b E=3.1q(J);3.1F("<H C=\'a-"+l+"\'></H>");$("#a-"+l).4("1I","1s");$("#a-"+l).o(3.o());$("#a-"+l).p(3.p());$("#a-"+l).4("2g","2i 2j #2k");$("#a-"+l).L("<V N=\'G\' C=\'"+6.M("#","")+"\'/>");$(6).4("d","q");b h=0;b i=0;1b(5.1c){m"1e":i=-3.o();n;m"1G":i=3.o();n;m"1x":h=-3.p();n;m"1w":h=3.p();n}c(17){$(6).g("e",5.f);$(6).4("7",h);$(6).4("8",i);$(6).4("t",5.S);v=0;u=0;s=1}A{$(6).g("e",3.g("e"));$(6).4("8",0);$(6).4("7",0);3.g("e",5.f);v=h;u=i;s=5.s}c(3.4("d")!="q"){$("#a-"+l).4("d","18");3.4("d","q")}A{$("#a-"+l).4("d","q");$("#a-"+l).4("8",3.4("8"));$("#a-"+l).4("7",3.4("7"));3.4("7",0);3.4("8",0)}c(5.X&&17){3.x({"7":-h,"8":-i},5.w)}$(6).x({"t":s,"7":v,"8":u},5.w,9(){E.g("e",5.f);E.1E("P");$("#a-"+l).14(E);r()})};b 1A=9(){b E=3.1q(J);3.1F("<H C=\'a\'></H>");$("#a").4("1I","1s");$("#a").o(3.o());$("#a").p(3.p());$("#a").L("<H N=\'W\' C=\'"+j.M("#","")+"\'/>");$(j).g("e",5.f);$(j).4("d","q");$(j).4("D-1r","#11");c(5.10.1p>0){$(j).4("D",5.10)}$(j).o(3.o());$(j).p(3.p());b h=0;b i=0;1b(5.1c){m"1e":i=-3.o();n;m"1G":i=3.o();n;m"1x":h=-3.p();n;m"1w":h=3.p();n}$(j).4("7",h);$(j).4("8",i);c(3.4("d")!="q"){$("#a").4("d","18");3.4("d","q")}A{$("#a").4("d","q");$("#a").4("8",3.4("8"));$("#a").4("7",3.4("7"));3.4("7",0);3.4("8",0)}$(j).x({"7":0,"8":0},5.w,9(){3.g("e",5.f);$(j).x({"7":h,"8":i},5.w,9(){E.g("e",5.f);E.1E("P");$("#a").14(E);r()})})};b 1y=9(){b 1D=3.4("d");b 1m=3.4("8");b 1f=3.4("7");3.1F("<H C=\'a\'></H>");$("#a").4("1I","1s");$("#a").o(3.o());$("#a").p(3.p());$("#a").L("<H N=\'W\' C=\'"+j.M("#","")+"\'/>");$(j).4("d","q");$(j).4("D-1r","#11");c(5.10.1p>0){$(j).4("D",5.10)}$(j).o(3.o());$(j).p(3.p());$("#a").L("<H N=\'Y\' C=\'"+B.M("#","")+"\'/>");$(B).4("d","q");$(B).4("D-1r","#11");c(5.1o.1p>0){$(B).4("D",5.1o)}$(B).o(3.o());$(B).p(3.p());b h=0;b i=0;1b(5.1c){m"1e":i=-3.o();n;m"1G":i=3.o();n;m"1x":h=-3.p();n;m"1w":h=3.p();n}$(j).4("7",h);$(j).4("8",i);$(B).4("7",-h);$(B).4("8",-i);c(!5.X){$(j).4("D","#11 Z("+5.f+") 1V-22 "+ -i/2+"1i "+ -h/2+"1i");$(B).4("D","#11 Z("+5.f+") 1V-22 "+i/2+"1i "+h/2+"1i")}c(3.4("d")!="q"){$("#a").4("d","18");3.4("d","q")}A{$("#a").4("d","q");$("#a").4("8",1m);$("#a").4("7",1f);3.4("d","q");3.4("7",0);3.4("8",0)}$(j).x({"7":h/2,"8":i/2},5.w,9(){3.g("e",5.f);c(!5.X){3.4("d",1D);3.4("7",1f);3.4("8",1m);$("#a").14(3)}A{$(j).x({"7":h,"8":i},5.w,9(){3.4("d",1D);3.4("7",1f);3.4("8",1m);$("#a").14(3)})}});$(B).x({"7":-h/2,"8":-i/2},5.w,9(){3.g("e",5.f);c(!5.X){r()}A{$(B).x({"7":-h,"8":-i},5.w,9(){r()})}})};b 1u=9(1d){b E=3.1q(J);c(3.4("z-O")==\'27\'){3.4("z-O",2o)}c(3.4("d")!="q"){3.4("d","18")}$("13").L("<V N=\'G\'  C=\'"+6.M("#","")+"\'/>");$(6).4("d","q");$(6).4("7",3.k().7);$(6).4("8",3.k().8);c(1d){$(6).4("t",5.S);$(6).4("z-O",3.4("z-O")-1);$(6).g("e",5.f)}A{$(6).4("t",1);$(6).4("z-O",3.4("z-O")+1);$(6).g("e",3.g("e"));3.g("e",5.f)}c(1U.1T(5.v)<3.p()&&1U.1T(5.u)<3.o()){v=3.k().7;u=3.k().8+3.o()}A{v=3.k().7+5.v;u=3.k().8+5.u}s=1;$(6).x({"t":s,"7":v,"8":u},5.w,9(){c(1d){$(6).4("z-O",2m)}A{s=5.s;$(6).4("z-O",2)}$(6).x({"t":s,"7":3.k().7,"8":3.k().8},5.w,9(){E.g("e",5.f);E.1E("P");3.14(E);$(6).F();r()})})};1j y.20(9(){3=$(y);c(!3.1H()){l=$.U(3);3.U("P",l);6="#G-"+l;j="#Y-"+l;B="#24-"+l;b 1W=23 1S();1W.e=5.f;$.1Z(5.f,9(){1b(5.1Y){m"2b":1X();n;m"19":1n(J);n;m"16":16(J);n;m"12":12(J);n;m"29":1n(1l);n;m"1d":1u(J);n;m"28":1u(1l);n;m"17":1z(J);n;m"26":1z(1l);n;m"1A":1A();n;m"1y":1y();n}})}})}})(R);(9($){$.1v.1H=9(){c(y.U("P")>0){1j J}A{1j 1l}}})(R);(9($){$.1v.2n=9(I,K,r){1j y.20(9(){c($(y).1H()){b l=$.U(y,"P");$("#G-"+l).Q(I,K);$("#W-"+l).Q(I,K);$("#Y-"+l).Q(I,K);$(y).Q(I,K);$("#G-"+l).F();$("#W-"+l).F();$("#Y-"+l).F();c($.1k(r)){r()}}})}})(R);(9($){$.2l=9(I,K,r){$(".G").Q(I,K);$(".W").Q(I,K);$(".Y").Q(I,K);$(y).Q(I,K);$(".G").F();$(".W").F();$(".Y").F();$.U(y,"P",-1);c($.1k(r)){r()}}})(R);(9($){$.1Z=9(21,r){b 1B=23 1S();1B.e=21;c($.1k(r)){$(1B).2h(r())}}})(R);',62,149,'|||Obj|css|Args|EffectImageId|top|left|function|GrpViewport|var|if|position|src|NewImage|attr|StartTop|StartLeft|EffectDivId1|offset|EffectID|case|break|width|height|absolute|EndFunction|EndOpacity|opacity|EndLeft|EndTop|Speed|animate|this||else|EffectDivId2|id|background|backup|remove|GrpEffectImg|div|clearQueue|true|gotoEnd|append|replace|class|index|imageswitch|stop|jQuery|StartOpacity|Debug|data|img|GrpEffectDiv|EffectOriginal|GrpEffectDiv1|url|Door1|FFF|FlyZoom|body|replaceWith|DivID|FlyBG|ScrollIn|relative|FlyIn|image|switch|Direction|FlipIn|RightLeft|orgTop|delay|html|px|return|isFunction|false|orgLeft|Fly|Door2|length|clone|color|hidden|mess|Flip|fn|DownTop|TopDown|DoubleDoor|Scroll|SingleDoor|TempImage|FuntionHandle|orgPosition|removeAttr|wrap|LeftRight|ImageAnimating|overflow|50|mozilla|browser|300|1350|1250|defaults|Arguements|line|Image|abs|Math|no|TempImg|FadeImage|Type|ImagePreload|each|FileName|repeat|new|GrpEffectDiv2|extend|ScrollOut|auto|FlipOut|FlyOut|br|FadeIn|parent|ImageSwitch|1000|200001|border|load|1px|solid|D9D9D9|ImageStopAll|101|ImageStop|100'.split('|'),0,{}))


/*------------------/
/*  SWFObject v2.2  /
/*-----------------*/

var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();


//-- For moving window problem after scroll, we changed "this.scroll_top" to 0 in moveTo function --//
/*-----------------/
/*  DHTML Windows  /
/*----------------*/

// -------------------------------------------------------------------
// DHTML Window Widget- By Dynamic Drive, available at: http://www.dynamicdrive.com
// v1.0: Script created Feb 15th, 07'
// v1.01: Feb 21th, 07' (see changelog.txt)
// v1.02: March 26th, 07' (see changelog.txt)
// v1.03: May 5th, 07' (see changelog.txt)
// v1.1:  Oct 29th, 07' (see changelog.txt)
// -------------------------------------------------------------------

var dhtmlwindow = {
	imagefiles: ['windowfiles/min.gif', '/images/header/layerClose.png', 'windowfiles/restore.gif', 'windowfiles/resize.gif'], //Path to 4 images used by script, in that order
	ajaxbustcache: true, //Bust caching when fetching a file via Ajax?
	ajaxloadinghtml: '<b>Loading Page. Please wait...</b>', //HTML to show while window fetches Ajax Content?

	minimizeorder: 0,
	zIndexvalue: 100,
	tobjects: [], //object to contain references to dhtml window divs, for cleanup purposes
	lastactivet: {}, //reference to last active DHTML window

	init: function (t)
	{
		$('#divDHTMLoading').show();
		var domwindow = document.createElement("div") //create dhtml window div
		domwindow.id = t
		domwindow.className = "dhtmlwindow"
		var domwindowdata = ''
		domwindowdata = '<div class="drag-handle">'
		domwindowdata += 'DHTML Window <div class="drag-controls"><img src="' + this.imagefiles[0] + '" title="Minimize" /><img src="' + this.imagefiles[1] + '" title="Close" /></div>'
		domwindowdata += '</div>'
		domwindowdata += '<div id="divDHTMLoading" class="divDHTMLoading">'
		domwindowdata += '<img id="imgQZLoading" src="/images/productList/quickZoomLoading.gif" alt="Loading" />'
		domwindowdata += '</div>'
		domwindowdata += '<div class="drag-contentarea"></div>'
		domwindowdata += '<div class="drag-statusarea"><div class="drag-resizearea" style="background: transparent url(' + this.imagefiles[3] + ') top right no-repeat;">&nbsp;</div></div>'
		domwindowdata += "</div>"

		domwindow.innerHTML = domwindowdata
		document.getElementById("dhtmlwindowholder").appendChild(domwindow)
		//this.zIndexvalue=(this.zIndexvalue)? this.zIndexvalue+1 : 100 //z-index value for DHTML window: starts at 0, increments whenever a window has focus
		var t = document.getElementById(t)
		var divs = t.getElementsByTagName("div")
		for (var i = 0; i < divs.length; i++)
		{ //go through divs inside dhtml window and extract all those with class="drag-" prefix
			if (/drag-/.test(divs[i].className))
				t[divs[i].className.replace(/drag-/, "")] = divs[i] //take out the "drag-" prefix for shorter access by name
		}
		//t.style.zIndex=this.zIndexvalue //set z-index of this dhtml window
		t.handle._parent = t //store back reference to dhtml window
		t.resizearea._parent = t //same
		t.controls._parent = t //same
		t.onclose = function () { return true } //custom event handler "onclose"
		t.onmousedown = function () { dhtmlwindow.setfocus(this) } //Increase z-index of window when focus is on it
		t.handle.onmousedown = dhtmlwindow.setupdrag //set up drag behavior when mouse down on handle div
		t.resizearea.onmousedown = dhtmlwindow.setupdrag //set up drag behavior when mouse down on resize div
		t.controls.onclick = dhtmlwindow.enablecontrols
		t.show = function () { dhtmlwindow.show(this) } //public function for showing dhtml window
		t.hide = function () { dhtmlwindow.hide(this) } //public function for hiding dhtml window
		t.close = function () { dhtmlwindow.close(this) } //public function for closing dhtml window (also empties DHTML window content)
		t.setSize = function (w, h) { dhtmlwindow.setSize(this, w, h) } //public function for setting window dimensions
		t.moveTo = function (x, y) { dhtmlwindow.moveTo(this, x, y) } //public function for moving dhtml window (relative to viewpoint)
		t.isResize = function (bol) { dhtmlwindow.isResize(this, bol) } //public function for specifying if window is resizable
		t.isScrolling = function (bol) { dhtmlwindow.isScrolling(this, bol) } //public function for specifying if window content contains scrollbars
		t.load = function (contenttype, contentsource, title) { dhtmlwindow.load(this, contenttype, contentsource, title) } //public function for loading content into window
		this.tobjects[this.tobjects.length] = t
		return t //return reference to dhtml window div
	},

	open: function (t, contenttype, contentsource, title, attr, recalonload)
	{
		var d = dhtmlwindow //reference dhtml window object
		function getValue(Name)
		{
			var config = new RegExp(Name + "=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
			return (config.test(attr)) ? parseInt(RegExp.$1) : 0 //return value portion (int), or 0 (false) if none found
		}
		if (document.getElementById(t) == null) //if window doesn't exist yet, create it
			t = this.init(t) //return reference to dhtml window div
		else
			t = document.getElementById(t)
		this.setfocus(t)
		t.setSize(getValue(("width")), (getValue("height"))) //Set dimensions of window
		var xpos = getValue("center") ? "middle" : getValue("left") //Get x coord of window
		var ypos = getValue("center") ? "middle" : getValue("top") //Get y coord of window
		//t.moveTo(xpos, ypos) //Position window
		if (typeof recalonload != "undefined" && recalonload == "recal" && this.scroll_top == 0)
		{ //reposition window when page fully loads with updated window viewpoints?
			if (window.attachEvent && !window.opera) //In IE, add another 400 milisecs on page load (viewpoint properties may return 0 b4 then)
				this.addEvent(window, function () { setTimeout(function () { t.moveTo(xpos, ypos) }, 400) }, "load")
			else
				this.addEvent(window, function () { t.moveTo(xpos, ypos) }, "load")
		}
		t.isResize(getValue("resize")) //Set whether window is resizable
		t.isScrolling(getValue("scrolling")) //Set whether window should contain scrollbars
		t.style.visibility = "visible"
		t.style.display = "block"
		t.contentarea.style.display = "block"
		t.moveTo(xpos, ypos) //Position window
		t.load(contenttype, contentsource, title)
		if (t.state == "minimized" && t.controls.firstChild.title == "Restore")
		{ //If window exists and is currently minimized?
			t.controls.firstChild.setAttribute("src", dhtmlwindow.imagefiles[0]) //Change "restore" icon within window interface to "minimize" icon
			t.controls.firstChild.setAttribute("title", "Minimize")
			t.state = "fullview" //indicate the state of the window as being "fullview"
		}
		return t
	},

	setSize: function (t, w, h)
	{ //set window size (min is 150px wide by 100px tall)
		t.style.width = Math.max(parseInt(w), 150) + "px"
		t.contentarea.style.height = Math.max(parseInt(h), 100) + "px"
	},

	moveTo: function (t, x, y)
	{ //move window. Position includes current viewpoint of document
		this.getviewpoint() //Get current viewpoint numbers
		t.style.left = (x == "middle") ? this.scroll_left + (this.docwidth - t.offsetWidth) / 2 + "px" : this.scroll_left + parseInt(x) + "px"
		t.style.top = (y == "middle") ? 0 + (this.docheight - t.offsetHeight) / 2 + "px" : this.scroll_top + parseInt(y) + "px"
	},

	isResize: function (t, bol)
	{ //show or hide resize inteface (part of the status bar)
		t.statusarea.style.display = (bol) ? "block" : "none"
		t.resizeBool = (bol) ? 1 : 0
	},

	isScrolling: function (t, bol)
	{ //set whether loaded content contains scrollbars
		t.contentarea.style.overflow = (bol) ? "auto" : "hidden"
	},

	load: function (t, contenttype, contentsource, title)
	{ //loads content into window plus set its title (3 content types: "inline", "iframe", or "ajax")
		if (t.isClosed)
		{
			alert("DHTML Window has been closed, so no window to load contents into. Open/Create the window again.")
			return
		}
		var contenttype = contenttype.toLowerCase() //convert string to lower case
		if (typeof title != "undefined")
			t.handle.firstChild.nodeValue = title
		if (contenttype == "inline")
			t.contentarea.innerHTML = contentsource
		else if (contenttype == "div")
		{
			var inlinedivref = document.getElementById(contentsource)
			t.contentarea.innerHTML = (inlinedivref.defaultHTML || inlinedivref.innerHTML) //Populate window with contents of inline div on page
			if (!inlinedivref.defaultHTML)
				inlinedivref.defaultHTML = inlinedivref.innerHTML //save HTML within inline DIV
			inlinedivref.innerHTML = "" //then, remove HTML within inline DIV (to prevent duplicate IDs, NAME attributes etc in contents of DHTML window
			inlinedivref.style.display = "none" //hide that div
		}
		else if (contenttype == "iframe")
		{
			t.contentarea.style.overflow = "hidden" //disable window scrollbars, as iframe already contains scrollbars
			if (!t.contentarea.firstChild || t.contentarea.firstChild.tagName != "IFRAME") //If iframe tag doesn't exist already, create it first
				t.contentarea.innerHTML = '<iframe src="" frameborder=0 style="margin:0; padding:0; width:100%; height: 100%" name="_iframe-' + t.id + '"></iframe>'
			window.frames["_iframe-" + t.id].location.replace(contentsource) //set location of iframe window to specified URL
		}
		else if (contenttype == "ajax")
		{
			this.ajax_connect(contentsource, t) //populate window with external contents fetched via Ajax
		}
		t.contentarea.datatype = contenttype //store contenttype of current window for future reference
	},

	setupdrag: function (e)
	{
		var d = dhtmlwindow //reference dhtml window object
		var t = this._parent //reference dhtml window div
		d.etarget = this //remember div mouse is currently held down on ("handle" or "resize" div)
		var e = window.event || e
		d.initmousex = e.clientX //store x position of mouse onmousedown
		d.initmousey = e.clientY
		d.initx = parseInt(t.offsetLeft) //store offset x of window div onmousedown
		d.inity = parseInt(t.offsetTop)
		d.width = parseInt(t.offsetWidth) //store width of window div
		d.contentheight = parseInt(t.contentarea.offsetHeight) //store height of window div's content div
		if (t.contentarea.datatype == "iframe")
		{ //if content of this window div is "iframe"
			t.style.backgroundColor = "#F8F8F8" //colorize and hide content div (while window is being dragged)
			t.contentarea.style.visibility = "hidden"
		}
		document.onmousemove = d.getdistance //get distance travelled by mouse as it moves
		document.onmouseup = function ()
		{
			if (t.contentarea.datatype == "iframe")
			{ //restore color and visibility of content div onmouseup
				t.contentarea.style.backgroundColor = "white"
				t.contentarea.style.visibility = "visible"
			}
			d.stop()
		}
		return false
	},

	getdistance: function (e)
	{
		var d = dhtmlwindow
		var etarget = d.etarget
		var e = window.event || e
		d.distancex = e.clientX - d.initmousex //horizontal distance travelled relative to starting point
		d.distancey = e.clientY - d.initmousey
		if (etarget.className == "drag-handle") //if target element is "handle" div
			d.move(etarget._parent, e)
		else if (etarget.className == "drag-resizearea") //if target element is "resize" div
			d.resize(etarget._parent, e)
		return false //cancel default dragging behavior
	},

	getviewpoint: function ()
	{ //get window viewpoint numbers
		var ie = document.all && !window.opera
		var domclientWidth = document.documentElement && parseInt(document.documentElement.clientWidth) || 100000 //Preliminary doc width in non IE browsers
		this.standardbody = (document.compatMode == "CSS1Compat") ? document.documentElement : document.body //create reference to common "body" across doctypes
		this.scroll_top = (ie) ? this.standardbody.scrollTop : window.pageYOffset
		this.scroll_left = (ie) ? this.standardbody.scrollLeft : window.pageXOffset
		this.docwidth = (ie) ? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent)) ? window.innerWidth : Math.min(domclientWidth, window.innerWidth - 16)
		this.docheight = (ie) ? this.standardbody.clientHeight : window.innerHeight
	},

	rememberattrs: function (t)
	{ //remember certain attributes of the window when it's minimized or closed, such as dimensions, position on page
		this.getviewpoint() //Get current window viewpoint numbers
		t.lastx = parseInt((t.style.left || t.offsetLeft)) - dhtmlwindow.scroll_left //store last known x coord of window just before minimizing
		t.lasty = parseInt((t.style.top || t.offsetTop)) - dhtmlwindow.scroll_top
		t.lastwidth = parseInt(t.style.width) //store last known width of window just before minimizing/ closing
	},

	move: function (t, e)
	{
		t.style.left = dhtmlwindow.distancex + dhtmlwindow.initx + "px"
		t.style.top = dhtmlwindow.distancey + dhtmlwindow.inity + "px"
	},

	resize: function (t, e)
	{
		t.style.width = Math.max(dhtmlwindow.width + dhtmlwindow.distancex, 150) + "px"
		t.contentarea.style.height = Math.max(dhtmlwindow.contentheight + dhtmlwindow.distancey, 100) + "px"
	},

	enablecontrols: function (e)
	{
		var d = dhtmlwindow
		var sourceobj = window.event ? window.event.srcElement : e.target //Get element within "handle" div mouse is currently on (the controls)
		if (/Minimize/i.test(sourceobj.getAttribute("title"))) //if this is the "minimize" control
			d.minimize(sourceobj, this._parent)
		else if (/Restore/i.test(sourceobj.getAttribute("title"))) //if this is the "restore" control
			d.restore(sourceobj, this._parent)
		else if (/Close/i.test(sourceobj.getAttribute("title"))) //if this is the "close" control
			d.close(this._parent)
		return false
	},

	minimize: function (button, t)
	{
		dhtmlwindow.rememberattrs(t)
		button.setAttribute("src", dhtmlwindow.imagefiles[2])
		button.setAttribute("title", "Restore")
		t.state = "minimized" //indicate the state of the window as being "minimized"
		t.contentarea.style.display = "none"
		t.statusarea.style.display = "none"
		if (typeof t.minimizeorder == "undefined")
		{ //stack order of minmized window on screen relative to any other minimized windows
			dhtmlwindow.minimizeorder++ //increment order
			t.minimizeorder = dhtmlwindow.minimizeorder
		}
		t.style.left = "10px" //left coord of minmized window
		t.style.width = "200px"
		var windowspacing = t.minimizeorder * 10 //spacing (gap) between each minmized window(s)
		t.style.top = dhtmlwindow.scroll_top + dhtmlwindow.docheight - (t.handle.offsetHeight * t.minimizeorder) - windowspacing + "px"
	},

	restore: function (button, t)
	{
		dhtmlwindow.getviewpoint()
		button.setAttribute("src", dhtmlwindow.imagefiles[0])
		button.setAttribute("title", "Minimize")
		t.state = "fullview" //indicate the state of the window as being "fullview"
		t.style.display = "block"
		t.contentarea.style.display = "block"
		if (t.resizeBool) //if this window is resizable, enable the resize icon
			t.statusarea.style.display = "block"
		t.style.left = parseInt(t.lastx) + dhtmlwindow.scroll_left + "px" //position window to last known x coord just before minimizing
		t.style.top = parseInt(t.lasty) + dhtmlwindow.scroll_top + "px"
		t.style.width = parseInt(t.lastwidth) + "px"
	},


	close: function (t)
	{
		try
		{
			var closewinbol = t.onclose()
		}
		catch (err)
		{ //In non IE browsers, all errors are caught, so just run the below
			var closewinbol = true
		}
		finally
		{ //In IE, not all errors are caught, so check if variable isn't defined in IE in those cases
			if (typeof closewinbol == "undefined")
			{
				alert("An error has occured somwhere inside your \"onclose\" event handler")
				var closewinbol = true
			}
		}

		if (closewinbol)
		{ //if custom event handler function returns true
			if (t.state != "minimized") //if this window isn't currently minimized
				dhtmlwindow.rememberattrs(t) //remember window's dimensions/position on the page before closing
			if (window.frames["_iframe-" + t.id]) //if this is an IFRAME DHTML window
				window.frames["_iframe-" + t.id].location.replace("about:blank")
			else
				t.contentarea.innerHTML = ""
			t.style.display = "none"
			t.isClosed = true //tell script this window is closed (for detection in t.show())
		}
		return closewinbol
	},


	setopacity: function (targetobject, value)
	{ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
		if (!targetobject)
			return
		if (targetobject.filters && targetobject.filters[0])
		{ //IE syntax
			if (typeof targetobject.filters[0].opacity == "number") //IE6
				targetobject.filters[0].opacity = value * 100
			else //IE 5.5
				targetobject.style.filter = "alpha(opacity=" + value * 100 + ")"
		}
		else if (typeof targetobject.style.MozOpacity != "undefined") //Old Mozilla syntax
			targetobject.style.MozOpacity = value
		else if (typeof targetobject.style.opacity != "undefined") //Standard opacity syntax
			targetobject.style.opacity = value
	},

	setfocus: function (t)
	{ //Sets focus to the currently active window
		this.zIndexvalue++
		t.style.zIndex = this.zIndexvalue
		t.isClosed = false //tell script this window isn't closed (for detection in t.show())
		this.setopacity(this.lastactivet.handle, 0.5) //unfocus last active window
		this.setopacity(t.handle, 1) //focus currently active window
		this.lastactivet = t //remember last active window
	},


	show: function (t)
	{
		if (t.isClosed)
		{
			alert("DHTML Window has been closed, so nothing to show. Open/Create the window again.")
			return
		}
		if (t.lastx) //If there exists previously stored information such as last x position on window attributes (meaning it's been minimized or closed)
			dhtmlwindow.restore(t.controls.firstChild, t) //restore the window using that info
		else
			t.style.display = "block"
		this.setfocus(t)
		t.state = "fullview" //indicate the state of the window as being "fullview"
	},

	hide: function (t)
	{
		t.style.display = "none"
	},

	ajax_connect: function (url, t)
	{
		var page_request = false
		var bustcacheparameter = ""
		if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
			page_request = new XMLHttpRequest()
		else if (window.ActiveXObject)
		{ // if IE6 or below
			try
			{
				page_request = new ActiveXObject("Msxml2.XMLHTTP")
			}
			catch (e)
			{
				try
				{
					page_request = new ActiveXObject("Microsoft.XMLHTTP")
				}
				catch (e) { }
			}
		}
		else
			return false
		t.contentarea.innerHTML = this.ajaxloadinghtml
		page_request.onreadystatechange = function () { dhtmlwindow.ajax_loadpage(page_request, t) }
		if (this.ajaxbustcache) //if bust caching of external page
			bustcacheparameter = (url.indexOf("?") != -1) ? "&" + new Date().getTime() : "?" + new Date().getTime()
		page_request.open('GET', url + bustcacheparameter, true)
		page_request.send(null)
	},

	ajax_loadpage: function (page_request, t)
	{
		if (page_request.readyState == 4 && (page_request.status == 200 || window.location.href.indexOf("http") == -1))
		{
			t.contentarea.innerHTML = page_request.responseText
		}
	},


	stop: function ()
	{
		dhtmlwindow.etarget = null //clean up
		document.onmousemove = null
		document.onmouseup = null
	},

	addEvent: function (target, functionref, tasktype)
	{ //assign a function to execute to an event handler (ie: onunload)
		var tasktype = (window.addEventListener) ? tasktype : "on" + tasktype
		if (target.addEventListener)
			target.addEventListener(tasktype, functionref, false)
		else if (target.attachEvent)
			target.attachEvent(tasktype, functionref)
	},

	cleanup: function ()
	{
		for (var i = 0; i < dhtmlwindow.tobjects.length; i++)
		{
			dhtmlwindow.tobjects[i].handle._parent = dhtmlwindow.tobjects[i].resizearea._parent = dhtmlwindow.tobjects[i].controls._parent = null
		}
		window.onload = null
	}

} //End dhtmlwindow object

document.write('<div id="dhtmlwindowholder"><span style="display:none">.</span></div>') //container that holds all dhtml window divs on page
window.onunload=dhtmlwindow.cleanup


// -------------------------------------------------------------------
// DHTML Modal window- By Dynamic Drive, available at: http://www.dynamicdrive.com
// v1.0: Script created Feb 27th, 07'
// v1.01 May 5th, 07' Minor change to modal window positioning behavior (not a bug fix)
// v1.1: April 16th, 08' Brings it in sync with DHTML Window widget. See changelog.txt for the later for changes.
// REQUIRES: DHTML Window Widget (v1.01 or higher): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/
// -------------------------------------------------------------------

if (typeof dhtmlwindow=="undefined")
alert('ERROR: Modal Window script requires all files from "DHTML Window widget" in order to work!')

var dhtmlmodal={
veilstack: 0,
open:function(t, contenttype, contentsource, title, attr, recalonload){
	var d=dhtmlwindow //reference dhtmlwindow object
	this.interVeil=document.getElementById("interVeil") //Reference "veil" div
	this.veilstack++ //var to keep track of how many modal windows are open right now
	this.loadveil()
	if (recalonload=="recal" && d.scroll_top==0)
		d.addEvent(window, function(){dhtmlmodal.adjustveil()}, "load")
	var t=d.open(t, contenttype, contentsource, title, attr, recalonload)
	t.controls.firstChild.style.display="none" //Disable "minimize" button
	t.controls.onclick=function(){dhtmlmodal.close(this._parent, true)} //OVERWRITE default control action with new one
	t.show=function(){dhtmlmodal.show(this)} //OVERWRITE default t.show() method with new one
	t.hide=function(){dhtmlmodal.close(this)} //OVERWRITE default t.hide() method with new one
return t
},


loadveil:function(){
	var d=dhtmlwindow
	d.getviewpoint()
	this.docheightcomplete = (d.standardbody.offsetHeight > d.standardbody.scrollHeight) ? d.standardbody.offsetHeight : d.standardbody.scrollHeight
	this.interVeil.style.width=d.docwidth+"px" //set up veil over page
	this.interVeil.style.height = ((this.docheightcomplete > $(window).height()) ? this.docheightcomplete : $(window).height()) + "px" //set up veil over page
	this.interVeil.style.left=0 //Position veil over page
	this.interVeil.style.top=0 //Position veil over page
	this.interVeil.style.visibility="visible" //Show veil over page
	this.interVeil.style.display="block" //Show veil over page
},

adjustveil:function(){ //function to adjust veil when window is resized
	if (this.interVeil && this.interVeil.style.display=="block") //If veil is currently visible on the screen
		this.loadveil() //readjust veil
},

closeveil:function(){ //function to close veil
	this.veilstack--
	if (this.veilstack==0) //if this is the only modal window visible on the screen, and being closed
		this.interVeil.style.display="none"
},


close:function(t, forceclose){ //DHTML modal close function
	$(".dhtmlwindow").hide();
	$("#interVeil").hide();
},


show:function(t){
	dhtmlmodal.veilstack++
	dhtmlmodal.loadveil()
	dhtmlwindow.show(t)
}
} //END object declaration


document.write('<div id="interVeil"></div>')
dhtmlwindow.addEvent(window, function(){if (typeof dhtmlmodal!="undefined") dhtmlmodal.adjustveil()}, "resize")

$(document).ready
(
	function()
	{
		$('#divDHTMLoading', parent.document.body).hide();
	}
);

/*---------------------/
/*  Basket Functions   /
/*--------------------*/

//divColourLiteral = Colour Literal To Be Toggled
//divColourComboBox = Colour ComboBox To Be Toggled
//divSizeLiteral = Size Literal To Be Toggled
//divSizeComboBox = Size ComboBox To Be Toggled
//divQuantityLiteral = Quantity Literal To Be Toggled
//divQuantityComboBox = Quantity ComboBox To Be Toggled
//ShowCombos = True To Show Combo Boxes / False To Show Literals
	function ModifyDetailsToggle(divColourLiteral, divColourComboBox, divSizeLiteral, divSizeComboBox, divQuantityLiteral, divQuantityComboBox, ShowCombos, imgModifyDetails, imgChangeDetails, ctrl, ctrlToUpdate, lineId) {

    if (ShowCombos == "true") {
        // Hide Literals And Show Combo Boxes
        $("#" + divColourLiteral).hide();
        $("#" + divSizeLiteral).hide();
        $("#" + divQuantityLiteral).hide();

        $("#" + divColourComboBox).show();
        $("#" + divSizeComboBox).show();
        $("#" + divQuantityComboBox).show();

        $("#" + imgModifyDetails).hide();
        $("#" + imgChangeDetails).show();

        //Activate DropDowns and Filter Remove the Redundant Options
        DropDownChangedCart(ctrl, ctrlToUpdate, "colour", lineId);
        DropDownChangedCart(ctrlToUpdate, ctrl, "size", lineId);
    }
    //    else {
    //        // Show Literals And Hide Combo Boxes
    //        $("#" + divColourLiteral).show();
    //        $("#" + divSizeLiteral).show();
    //        $("#" + divQuantityLiteral).show();

    //        $("#" + divColourComboBox).hide();
    //        $("#" + divSizeComboBox).hide();
    //        $("#" + divQuantityComboBox).hide();

    //        $("#" + imgModifyDetails).show();
    //        $("#" + imgChangeDetails).hide();
    //    }
}

//ctrl = dropdown changed
//ctrlToUpdate = control to be updated
//type = what was changed - colour or size
//lineid = line id
function DropDownChangedCart(ctrl, ctrlToUpdate, type, lineid) {

    //Get Values
    var delimitedlist = arr[lineid + "_" + type + "_" + $("#" + ctrl).val()];

    //Store Current Value of the DropDown, before clearing it
    var oldValue = $("#" + ctrlToUpdate).val();

    //Clear DropDown To Update
    $("select[id$=" + ctrlToUpdate + "] > option").remove();

    //Split strings
    var seperateValues = delimitedlist.split(",");

    //Re-Fill Dropdown
    var splitCriteria;

    for (j = 0; j < seperateValues.length; j++) {
        //splitCriteria = seperateValues[j].split("|");
        //$('<option/>').val(splitCriteria[0]).html(splitCriteria[1]).appendTo("#" + ctrlToUpdate);
        $('<option/>').val(seperateValues[j].split("|")[0]).html(seperateValues[j].split("|")[1]).appendTo("#" + ctrlToUpdate);
    }

    //If the old value is in the new list, than pre-select it
    $("#" + ctrlToUpdate).find("option[value*='" + oldValue + "']").attr('selected', 'selected');

}

function SetOfferCode() {
    $(".btnSetOfferCode").click();
}
function GoToStep2() {
    $(".btnGotoStep2").click();
}
function QuantityChanged(ctrl) {
    if (ctrl.value != ctrl.getAttribute("OriginalQuantity")) {

        ctrl.parentNode.getElementsByTagName("input")[2].disabled = false;
        ctrl.parentNode.getElementsByTagName("input")[2].removeAttribute("disabled");
    }

}
function ShowSatisfiedText() {
    $("#divSatisfied").fadeIn(700);
}


function HideSatisfiedText() {
    $("#divSatisfied").fadeOut(700);
}


function OpenOrClose(divName) {

    if ($("#" + divName).is(':visible')) {
        $("#" + divName).hide();
        $("#" + divName + "Img").attr("src", "/shoppingBasket/images/step2Down.gif");
    }
    else {
        $("#" + divName).show();
        $("#" + divName + "Img").attr("src", "/shoppingBasket/images/step2Up.gif");
    }

}


function ShowDelMethodDiv(whichOne) {

    if (whichOne == "CreditCards") {
        $("#trCreditCards").show();
        $("#radCreditCards").attr("checked", true);
        $("#trColissimo").hide();
    }
    else {
        $("#trCreditCards").hide();
        $("#trColissimo").show();
        $("#radColissimo").attr("checked", true);
    }

}



function ShowPayMethodDiv(whichOne) {

    if (whichOne == "CreditCards") {
        $("#trCreditCards").show();
        $("#radCreditCards").attr("checked", true);
        $("#trKangourou").hide();
        $("#trVoucher").hide();
    }

    else if (whichOne == "Kangourou") {
        $("#trKangourou").show();
        $("#radKangourou").attr("checked", true);
        $("#trCreditCards").hide();
        $("#trVoucher").hide();
    }

    else if (whichOne == "Voucher") {
        $("#trVoucher").show();
        $("#radVoucher").attr("checked", true);
        $("#trCreditCards").hide();
        $("#trKangourou").hide();
    }

}


function ShowCreditCardError() {
    /*$("#tdCardNumberLeft").addClass("step3-tdFormLeftError")
    $("#tdCardNumberRight").addClass("step3-tdFormRightError")*/
}


function BasketOpenOfferExplanation()
{
	offerWindow = dhtmlmodal.open('Offer', 'iframe', '/shoppingBasket/basketOfferExplanation.aspx', '', 'width=400px,height=250px,top=0,left=0,center=1,resize=0,scrolling=1')
}


function BasketOpenDeliveryExplanation()
{
	deliveryWindow = dhtmlmodal.open('Delivery', 'iframe', '/shoppingBasket/basketDeliveryExplanation.aspx', '', 'width=400px,height=250px,top=0,left=0,center=1,resize=0,scrolling=1')
}


function BasketOpenTaxRefund()
{
	taxRefund = dhtmlmodal.open('TaxRefund', 'iframe', '/shoppingBasket/basketTaxRefund.aspx', '', 'width=400px,height=250px,top=0,left=0,center=1,resize=0,scrolling=1')
}


//-- Basket Step 2 --//

//-- Outlets --//
var pnlOutletAddressId = "ctl00_cphMain_ctl00_ucOutletDelivery_pnlOutletAddress";
var pnlOutletHoursId = "ctl00_cphMain_ctl00_ucOutletDelivery_pnlOutletHours";
var pnlOutletDatesId = "ctl00_cphMain_ctl00_ucOutletDelivery_pnlOutletDates";
var lstOuletChoiceListId = "ctl00_cphMain_ctl00_ucOutletDelivery_lstOuletChoiceList";
var radDeliveryDatesName = "ctl00$cphMain$ctl00$ucOutletDelivery$radDeliveryDates";
var hidChosenDeliveryDateId = "ctl00_cphMain_ctl00_ucOutletDelivery_hidChosenDeliveryDate";
function InitialiseOutletSelection() {

    var originalOnChange = "setTimeout(\"__doPostBack('" + lstOuletChoiceListId.replace(/_/g, "$") + "','')\", 0)";

    $("#" + lstOuletChoiceListId).attr("onchange", "")
    $("#" + lstOuletChoiceListId).change(function() { if (OutletSelected()) { eval(originalOnChange); } });
    $("#" + pnlOutletDatesId + " div[outlet] input").change(
function() {
    if ($("#" + hidChosenDeliveryDateId).length > 0)
        $("#" + hidChosenDeliveryDateId).val($(this).val());
}
);
    OutletSelected();
    /*	
    $("input[name='"+radDeliveryDatesName+"']").click=function()
    {
    alert(this.value);
    $("#"+hidChosenDeliveryDateId).value=this.value;
    }	
    */

}

function OutletSelected() {

    var outletId = $("#" + lstOuletChoiceListId).find(':selected').val();

    //alert($("#"+lstOuletChoiceListId).find(':selected').attr("Postback"));
    $("#" + pnlOutletAddressId + " > div").css("display", "none");
    $("#" + pnlOutletAddressId + " > div[Outlet='" + outletId + "']").css("display", "");

    $("#" + pnlOutletHoursId + " > div").css("display", "none");
    $("#" + pnlOutletHoursId + " > div[Outlet='" + outletId + "']").css("display", "");

    $("#" + pnlOutletDatesId + " > div > div[outlet]").css("display", "none");
    $("#" + pnlOutletDatesId + " > div > div[Outlet='" + outletId + "']").css("display", "");

    var selectedRadiosDeliveryDate = $("#" + pnlOutletDatesId + " div[Outlet='" + outletId + "'] input[checked]	");


    if ($("#" + hidChosenDeliveryDateId).length > 0) {
        if (selectedRadiosDeliveryDate.length > 0) {
            $("#" + hidChosenDeliveryDateId).get(0).value = selectedRadiosDeliveryDate.get(0).value;
        }
        else {
            $("#" + hidChosenDeliveryDateId).get(0).value = "";
        }
    }

    //alert($("#"+pnlOutletDatesId+" > div[Outlet='"+outletId+"'] input[checked='checked']").get(0).value);

    return $("#" + lstOuletChoiceListId).find(':selected').attr("Postback") == "1";
}


function ShowDeliveryMethod(deliveryType, force)
{

    var changed = true;

    if (force == null)
        force = false;

    if (!force) {
        if ($("span[HeaderCheck='rad" + deliveryType + "'] > input").length > 0) {
            changed = $("span[HeaderCheck='rad" + deliveryType + "'] > input").get(0).checked == false;
        }
    }

    if (changed) {
        var i;
        var radios = $("span[HeaderCheck*='rad'] > input")
        for (i = 0; i < radios.length; i++) {
            radios.get(i).checked = false;
        }


	$("span[HeaderCheck='rad" + deliveryType + "'] > input").get(0).checked = true;

        if (!force) {
            $(".deliveryMethod .section:visible").slideUp('slow');
            $("div[DeliveryType='" + deliveryType + "'] > .section").slideDown('slow');
        }

        else {
            $(".deliveryMethod .section:visible").css("display", "none");
            $("div[DeliveryType='" + deliveryType + "'] > .section").css("display", "");
        }

        if ($("div[DeliveryType='" + deliveryType + "'] .fee").length > 0)
        {
                        if($("#deliveryFee").length>0)
                                        $("#deliveryFee").get(0).innerHTML = $("div[DeliveryType='" + deliveryType + "']  .fee").get(0).innerHTML;

        }

        var feeValue = $("#deliveryFee").html();
        feeValue = " " + feeValue + " ";
        feeValue = feeValue.replace(/[^0-9]/g, " ");

        if (feeValue == 0) {
            $(".trProcessingFee").css("display", "none");
        }
        else {
            $(".trProcessingFee").css("display", "");
        }

        if ($("div[DeliveryType='" + deliveryType + "'] .total").length > 0)
			if($("#total").length>0)                                 
				$("#total").get(0).innerHTML = $("div[DeliveryType='" + deliveryType + "']  .total").get(0).innerHTML;
    }

}


function InitialiseDeliveryMethods() {
    var radios = $(".radDeliveryHeader");
    var i = 0;

    for (i = 0; i < radios.length; i++) {
        var radio = radios.get(i).getElementsByTagName("input")[0];
        var checked = radios.get(i).getElementsByTagName("input")[0].checked;
        //if(checked)
        //    alert(radios.get(i).getAttribute("headerCheck"));	
        if (radios.get(i).getAttribute("headerCheck") == "radOutlet") {
            if (checked)
                ShowDeliveryMethod('Outlet', true);

            radio.onclick = function() { ShowDeliveryMethod('Outlet', true) };

        }
        else if (radios.get(i).getAttribute("headerCheck") == "radPostal") {
            if (checked)
                ShowDeliveryMethod('Postal', true);
            radio.onclick = function() { ShowDeliveryMethod('Postal', true) };


        }
        else if (radios.get(i).getAttribute("headerCheck") == "radHome") {
            if (checked)
                ShowDeliveryMethod('Home', true);
            radio.onclick = function() { ShowDeliveryMethod('Home', true) };
        }
        else if (radios.get(i).getAttribute("headerCheck") == "radExpressDelivery") {
            if (checked)
                ShowDeliveryMethod('ExpressDelivery', true);
            radio.onclick = function() { ShowDeliveryMethod('ExpressDelivery', true) };
        }
    }
}

function ShowHide_SelectOutletDiv(divname, show) {
    if (show == "false") {
        $("#" + divname).hide();
    }
    else {
        $("#" + divname).show();
        colisPanelBottomContainer.height = "500px";
    }
}

function ShowHide_SelectColissimoDiv(divname, show) {
    if (show == "false") {
        $("#spanChangeAddress").show();
        $("#" + divname).hide();
        //$("#" + radioButton).attr("checked", true);
    }
    else {
        $("#spanChangeAddress").hide();
        $("#" + divname).show();
        //$("#" + radioButton).attr("checked", true);
    }
}

function TickRadioButton(radioButton) {
    $("#" + radioButton).attr("checked", true);
}

//-- Basket Step 3 --//
function ShowPaymentMethod(paymentType, force) {

    var changed = true;
    if (force == null)
        force = false;

    if (!force) {
        if ($("span[HeaderCheck='rad" + paymentType + "'] > input").length > 0) {
            changed = $("span[HeaderCheck='rad" + paymentType + "'] > input").get(0).checked == false;
        }
    }

    if (changed) {
        var i;
        var radios = $("span[HeaderCheck*='rad'] > input")
        for (i = 0; i < radios.length; i++) {
            radios.get(i).checked = false;
        }

        //$(".deliveryMethodSection").css("display","none");
        //$(".deliveryMethod .section").css("display","none");
        //$(".deliveryMethodSection").slideUp();
        $("span[HeaderCheck='rad" + paymentType + "'] > input").get(0).checked = true;
//        if (!force) {
//            $(".paymentMethod .section:visible").slideUp('slow');
//            $("div[PaymentType='" + paymentType + "'] > .section").slideDown('slow');
//        }
//        else {
//            $(".paymentMethod .section:visible").css("display", "none");
//            $("div[PaymentType='" + paymentType + "'] > .section").css("display", "");
//        }


        if ($("div[PaymentType='" + paymentType + "'] .fee").length > 0) {
            //var fee = $("#paymentFee").get(0).innerHTML = $("div[PaymentType='" + paymentType + "']  .fee").get(0).innerHTML;
            var fee = $("div[PaymentType='" + paymentType + "']  .fee").get(0).innerHTML;
            $(".trPaymentFee").css("display", "");
            $(".labPaymentFee").html(fee);
            $(".trProcessingFee td").css("padding-bottom", "0px");
        }
        else {
            $(".trPaymentFee").css("display", "none");
            $(".trProcessingFee td").css("padding-bottom", "25px");
        }

        if ($("div[PaymentType='" + paymentType + "'] .total").length > 0) {
            var total = $("div[PaymentType='" + paymentType + "']  .total").get(0).innerHTML;
            $(".labTotal").html(total);
        }

        //alert(("div[PaymentType='" + paymentType + "'] .total"))
        //alert($("div[PaymentType='" + paymentType + "']  .total").get(0).innerHTML)
    }

}

function InitialisePaymentMethods() {
    var radios = $(".radPaymentHeader");
    var i = 0;

    for (i = 0; i < radios.length; i++) {
        var radio = radios.get(i).getElementsByTagName("input")[0];

        var checked = radios.get(i).getElementsByTagName("input")[0].checked;

        if (radios.get(i).getAttribute("headerCheck") == "radKangourou") {
            if (checked)
                ShowPaymentMethod('Kangourou', true);
            radio.onclick = function() { ShowPaymentMethod('Kangourou', true) };



        }
        else if (radios.get(i).getAttribute("headerCheck") == "radVoucher") {
            if (checked)
                ShowDeliveryMethod('Voucher', true);
            radio.onclick = function() { ShowPaymentMethod('Voucher', true) };
        }
        else if (radios.get(i).getAttribute("headerCheck").indexOf("radCashOnDelivery") != -1) {
            var paymentMethodName = radios.get(i).getAttribute("headerCheck").replace("rad", "");
            if (checked)
                ShowPaymentMethod(paymentMethodName, true);
            radio.onclick = function() { ShowPaymentMethod(paymentMethodName, true) };
        }
        else //if (radios.get(i).getAttribute("headerCheck").indexOf("radCreditCard") != -1)
        {
            var paymentMethodName = radios.get(i).getAttribute("headerCheck").replace("rad", "");

            if (checked) {
                ShowPaymentMethod(paymentMethodName, true);
            }
            radio.onclick = function() { ShowPaymentMethod(paymentMethodName, true) };

        }
    }
}


var CardValidationRules;
var cmbCreditCardsId = "ctl00_cphMain_ctl00_ucCreditCardPayment_cmbCreditCards";
function CreditCardValidation(cardId, cardNumberLength, requiresExpiryDate, requiresScratchCode) {
    this.CardId = cardId;
    this.CardNumberLength = cardNumberLength;
    this.RequiresExpiryDate = requiresExpiryDate;
    this.RequiresScratchCode = requiresScratchCode;
}


function CreditCardChosen(ctrl) {
    if (ctrl != null) {
        var creditCardId = ctrl.value;
        var cardValidation = CardValidationRules[creditCardId];

        if (cardValidation.RequiresExpiryDate) {
            $("#ExpiryDateSection").css("display", "");
        }
        else {
            $("#ExpiryDateSection").css("display", "none");
        }

        if (cardValidation.RequiresScratchCode) {
            $("#ScratchCodeSection").css("display", "");
        }
        else {
            $("#ScratchCodeSection").css("display", "none");
            $("#ScratchCodeSection input").attr("value", "")
        }

        var creditCardType = $("#" + ctrl.id + " :checked").attr("creditcardtype");
        //$("#imgCreditCardHelp").attr("onmouseover","Tip('<img src=/shoppingBasket/images/rev2/creditCardBubble_"+creditCardType+".png>')");
        $("#imgCreditCardHelp").mouseover(function() { Tip('<img src=/shoppingBasket/images/rev2/creditCardBubble_' + creditCardType + '.png>') });
    }
}

function InitialiseCreditCards() {
    CreditCardChosen($("#" + cmbCreditCardsId).get(0));
}


function OpenVoucherExplanation(title) {
    var title = $("#divVoucherExplanation").attr("title");
    dhtmlmodal.open('VoucherExplanation', 'div', 'divVoucherExplanation', title, 'width=450px,height=175px,center=1,resize=0,scrolling=1');
}


function OpenThankYouExplanation(title) {
    var title = $("#divThankYouExplanation").attr("title");
    dhtmlmodal.open('ThankYouExplanation', 'div', 'divThankYouExplanation', title, 'width=450px,height=175px,center=1,resize=0,scrolling=1');
}

function ValidateConditions(chkClass, divErrorId) {
    if ($("." + chkClass + " input").length > 0) {
        isChecked = $("." + chkClass + " input").attr("checked");
        if (!isChecked) {
            $("#" + divErrorId).css("display", "");
            return false;
        }
        else {
            $("#" + divErrorId).css("display", "none");
        }

    }
    return true;
}

window.onbeforeunload = function() { }

function SetCityZipCode(cmbCtrlId, txtCityId, txtZipCodeId) {
    var cmb = $("#" + cmbCtrlId);
    var selectedOption = $("#" + cmbCtrlId + " option:selected");
    var city = selectedOption.text();
    var zip = selectedOption.val();
    var city = $.trim(selectedOption.text().split('-')[1]);
    if (city == "")
        city = $.trim(selectedOption.text());

    //    if (zip != "") {
    //        $("#" + txtCityId).val(city);
    //        $("#" + txtZipCodeId).val(zip);

    //    }
}

function SetStreet(cmbCtrlId, txtStreetId) {
    var cmb = $("#" + cmbCtrlId);
    var selectedOption = $("#" + cmbCtrlId + " option:selected");
    var street = selectedOption.text();
    if (street != "") {
        $("#" + txtStreetId).val(street);
    }
}


function ConfirmPaymentMethod() {
    $("#" + $(".radPaymentHeader input:checked").parent().attr("confirmbutton")).click();

    return false;
}


/* =========================================================

// jquery.innerfade.js

// Datum: 2008-02-14
// Firma: Medienfreunde Hofmann & Baldes GbR
// Author: Torsten Baldes
// Mail: t.baldes@medienfreunde.com
// Web: http://medienfreunde.com

// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/
// and Ralf S. Engelschall http://trainofthoughts.org/

 *
 *  <ul id="news"> 
 *      <li>content 1</li>
 *      <li>content 2</li>
 *      <li>content 3</li>
 *  </ul>
 *  
 *  $('#news').innerfade({ 
 *	  animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'), 
 *	  speed: Fading-/Sliding-Speed in milliseconds or keywords (slow, normal or fast) (Default: 'normal'), 
 *	  timeout: Time between the fades in milliseconds (Default: '2000'), 
 *	  type: Type of slideshow: 'sequence', 'random' or 'random_start' (Default: 'sequence'), 
 * 		containerheight: Height of the containing element in any css-height-value (Default: 'auto'),
 *	  runningclass: CSS-Class which the container getâ€™s applied (Default: 'innerfade'),
 *	  children: optional children selector (Default: null)
 *  }); 
 *

// ========================================================= */


(function($) {

    $.fn.innerfade = function(options) {
        return this.each(function() {   
            $.innerfade(this, options);
        });
    };

    $.innerfade = function(container, options) {
        var settings = {
        		'animationtype':    'fade',
            'speed':            'normal',
            'type':             'sequence',
            'timeout':          2000,
            'containerheight':  'auto',
            'runningclass':     'innerfade',
            'children':         null
        };
        if (options)
            $.extend(settings, options);
        if (settings.children === null)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);
        if (elements.length > 1) {
            $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
            for (var i = 0; i < elements.length; i++) {
                $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
            };
            if (settings.type == "sequence") {
                setTimeout(function() {
                    $.innerfade.next(elements, settings, 1, 0);
                }, settings.timeout);
                $(elements[0]).show();
            } else if (settings.type == "random") {
            		var last = Math.floor ( Math.random () * ( elements.length ) );
                setTimeout(function() {
                    do { 
												current = Math.floor ( Math.random ( ) * ( elements.length ) );
										} while (last == current );             
										$.innerfade.next(elements, settings, current, last);
                }, settings.timeout);
                $(elements[last]).show();
						} else if ( settings.type == 'random_start' ) {
								settings.type = 'sequence';
								var current = Math.floor ( Math.random () * ( elements.length ) );
								setTimeout(function(){
									$.innerfade.next(elements, settings, (current + 1) %  elements.length, current);
								}, settings.timeout);
								$(elements[current]).show();
						}	else {
							alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
						}
				}
    };

    $.innerfade.next = function(elements, settings, current, last) {
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
							removeFilter($(this)[0]);
						});
        } else
            alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
        if (settings.type == "sequence") {
            if ((current + 1) < elements.length) {
                current = current + 1;
                last = current - 1;
            } else {
                current = 0;
                last = elements.length - 1;
            }
        } else if (settings.type == "random") {
            last = current;
            while (current == last)
                current = Math.floor(Math.random() * elements.length);
        } else
            alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
        setTimeout((function() {
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };

})(jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
	if(element.style.removeAttribute){
		element.style.removeAttribute('filter');
	}
}

function LazyLoadImages()
{
	setTimeout(function(){
	$('img[lazyloadsrc]').each(function(){
	  $(this).attr('src', $(this).attr('lazyloadsrc'));
	});
	},1000);
	

}
