function TurnFormStatus()
{
	
	div = document.getElementById("ctl00_cphMain_ctl00_panAlternativeAddress");
	inputs = div.getElementsByTagName("input");
	selects = div.getElementsByTagName("select");

	for(i = 0; i < inputs.length; i++)
	{
		if ( inputs[i].disabled == true )
			inputs[i].disabled = false;
		else
			inputs[i].disabled = true;
	}
	
	for(i = 0; i < selects.length; i++)
	{
		if ( selects[i].disabled == true )
			selects[i].disabled = false;
		else
			selects[i].disabled = true;
	}
		
}


function ShowAltAddressForm()
{
	if ( document.getElementById("ctl00_cphMain_ctl00_divAltAddress").style.display == "none" )
		$("#ctl00_cphMain_ctl00_divAltAddress").show("slow");
	else
		$("#ctl00_cphMain_ctl00_divAltAddress").hide("slow");	
}


function HideAlternativeAddress(slow)
{
	if ( slow == "1" )
		$("#ctl00_cphMain_ctl00_divAltAddress").hide("slow");
	else
		$("#ctl00_cphMain_ctl00_divAltAddress").hide();
}


function SetUniqueRadioButton(match, current, hasPhone, type)
{
	CheckPhoneNumber(hasPhone, type);

	for(i = 0; i < document.forms[0].elements.length; i++)
	{
		elm = document.forms[0].elements[i];
		
		if (elm.type == 'radio' && elm.id.indexOf(match, 0) > -1)
		{
			elm.checked = false;
		}
	}

	current.checked = true;
}


function CheckPhoneNumber(hasPhone, type)
{

	if ( (type != "HomeDelivery") && (hasPhone == "False") )
		$("#divNoPhoneNumber").show();
	else
		$("#divNoPhoneNumber").hide();

	if (type == "DHL")
	{
		$("#trDHLPopUp").show();
		$("#trEMSPopUp").hide();
		$("#trB2CPopUp").hide();
	}
	else if (type == "EMS")
	{
		$("#trDHLPopUp").hide();
		$("#trEMSPopUp").show();
		$("#trB2CPopUp").hide();
	}
	else if (type == "B2C")
	{
		$("#trDHLPopUp").hide();
		$("#trEMSPopUp").hide();
		$("#trB2CPopUp").show();
	}
	else
	{
		$("#trDHLPopUp").hide();
		$("#trEMSPopUp").hide();
		$("#trB2CPopUp").hide();
	}

}


function OpenDHLPopup()
{
	dhlWindow = dhtmlmodal.open('DHL', 'iframe', '/shoppingBasket/dhlPopup.aspx', '', 'width=700px,height=600px,top=0,left=0,center=1,resize=0,scrolling=1')
}


function OpenEMSPopup()
{
	emsWindow = dhtmlmodal.open('EMS', 'iframe', '/shoppingBasket/emsPopup.aspx', '', 'width=700px,height=600px,top=0,left=0,center=1,resize=0,scrolling=1')
}


function OpenB2CPopup()
{
	b2cWindow = dhtmlmodal.open('B2C', 'iframe', '/shoppingBasket/b2cPopup.aspx', '', 'width=700px,height=600px,top=0,left=0,center=1,resize=0,scrolling=1')
}


function OpenErrorPopUp()
{

	//Open a modal window populated with the contents of a hidden DIV, and assign the result to a global variable called "errorWindow"
    errorWindow = dhtmlmodal.open('Error', 'div', 'divErrorPopUp', 'Error', 'width=310px,height=150px,center=1,resize=0,scrolling=1')
    
    errorWindow.onclose=function(){
        return true
    }

}


function GiftChooseAutomatically()
{
	$("[id$=txtGiftCode]").val($("[id$=cmbGiftChoose]").val());
}
