// JavaScript Document

 //HemanT 20091031: As ET Biz is down so thir site will be down for sometime.
//Setting all pag's redirection to the Main root page

//window.location.href='http://www.expensivetaste.co.uk'

var boolMouseOut = false;
var boolImgSelected = false;


//functions for rollover images
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//Function to fill the text box with existing contents
function fillEmail(obj)
{
	if(document.getElementById(obj).value == "")
	{
		document.getElementById(obj).value ="Enter your Email Address";		
	}
}
function clearEmail(obj)
{
	if(document.getElementById(obj).value == "Enter your Email Address")
	{
		document.getElementById(obj).value ="";		
	}
}


function arrow_hover()
{
	
	document.getElementById("arrow").src="images/Arrow-Rolover.gif";
}
function arrow_lostfocus()
{
		document.getElementById("arrow").src="images/Arrow.gif";
}


function getObj(id)
{
	return document.getElementById(id)
}

/*function for: form- subscribe Submit button */
function submitSubscribe()
{
	if (RTrim(LTrim(getObj("CtlNewsLetters1_txtNewsletterSubscribe").value))=="")
	{
		getObj("CtlNewsLetters1_txtNewsletterSubscribe").value="Enter your Email address"
	}
	
	if(getObj("CtlNewsLetters1_txtNewsletterSubscribe").value=="Enter your Email address")
	{}
	else
	{
		s = getObj("CtlNewsLetters1_txtNewsletterSubscribe").value
		var emailAddress = getObj("CtlNewsLetters1_txtNewsletterSubscribe").value
		window.location.href="subscribe.aspx?userMail="+emailAddress
	}
}


function RTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for(j = String.length - 1; j >= 0; j--)
	{
		if (String.substr(j, 1) != ' ' &&
			String.substr(j, 1) != '\t')
		break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}
function LTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for (i = 0; i < String.length; i++)
	{
		if (String.substr(i, 1) != ' ' &&
		    String.substr(i, 1) != '\t')
			break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}

function AddItemToBasket(ItemId,Quantity,pid,cid,color,size)
{
	var isvalid;
  	if(BasketDetailsProper())
	{
		var objs = document.getElementsByTagName("input");
		var ObjId;
		for (i = 0; i < objs.length; i++)
		{
			try
			{
				if(objs[i].type == "hidden")
				{
					if(objs[i].id.indexOf("hdnCacheKey") != -1)
					{
						ObjId = objs[i].id;
						break;
					}
				}
			}
			catch(error){}
		}
		if (cid == 0) 
		{
				var strlink = "basket.aspx?ItemId=" + ItemId + "&ClassIds=" + pid  + "&cachekey=" + document.getElementById(ObjId).value + "&Quantity=" + Quantity + "&color=" + color + "&size=" + size; 
				document.location.href =strlink;
		}
		else
		{
				var strlink = "basket.aspx?ItemId=" + ItemId + "&ClassIds=" + pid + "," + cid + "&cachekey=" + document.getElementById(ObjId).value + "&Quantity=" + Quantity + "&color=" + color + "&size=" + size; 	
				document.location.href =strlink;
		}
	}
	return false;
}

function BasketDetailsProper()
{
	var isValid;	
	
	if (document.getElementById("UCproductDetail1_DLItems__ctl0_ddlColor") || document.getElementById("UCproductDetail1_DLItems__ctl0_ddlSize"))
	{ 
		  if (document.getElementById("UCproductDetail1_DLItems__ctl0_ddlColor"))
	       {
			if (document.getElementById("UCproductDetail1_DLItems__ctl0_ddlColor").selectedIndex == 0)
			{ 
				if (document.getElementById("UCproductDetail1_DLItems__ctl0_ddlSize"))
				{
					if (document.getElementById("UCproductDetail1_DLItems__ctl0_ddlSize").selectedIndex == 0)
					{
						document.getElementById("lblError").style.visibility="visible";
						document.getElementById("lblError").innerHTML="Select Colour & Size";						
						return false;

					}
				}	
				
				document.getElementById("lblError").style.visibility="visible";
				document.getElementById("lblError").innerHTML="Select Colour";
				return false;
			 
			}
			else
			{
				
				if (document.getElementById("UCproductDetail1_DLItems__ctl0_ddlSize"))
				{
					if (document.getElementById("UCproductDetail1_DLItems__ctl0_ddlSize").selectedIndex == 0)
					{
						document.getElementById("lblError").style.visibility="visible";
						document.getElementById("lblError").innerHTML="Select Size";						
						return false;

					}
				}	
				document.getElementById("lblError").innerHTML="";
				document.getElementById("lblError").style.visibility="hidden";
				return true;
			}
		}
		else
		{
			  if (document.getElementById("UCproductDetail1_DLItems__ctl0_ddlSize"))
				{
					if (document.getElementById("UCproductDetail1_DLItems__ctl0_ddlSize").selectedIndex == 0)
					{
						document.getElementById("lblError").style.visibility="visible";
						document.getElementById("lblError").innerHTML="Select Size";						
						return false;

					}
					document.getElementById("lblError").innerHTML="";
					document.getElementById("lblError").style.visibility="hidden";
					return true;
				}	
				else 
				{
					document.getElementById("lblError").innerHTML="";
					document.getElementById("lblError").style.visibility="hidden";
					return true;
				}
		}
	}
	else
	{		
		document.getElementById("lblError").innerHTML="";
		document.getElementById("lblError").style.visibility="hidden";
		return true;
	}
}

function getFinalColor()
{
	if (document.getElementById("UCproductDetail1_DLItems__ctl0_ddlColor"))
	{	
		return(document.getElementById("UCproductDetail1_DLItems__ctl0_ddlColor").value);
	}
	else
	{
		if (document.getElementById("UCproductDetail1_DLItems__ctl0_lblColor"))
		{
			return(document.getElementById("UCproductDetail1_DLItems__ctl0_lblColor").innerHTML);
		}
		else
		{
			return ("N.A.");
		}
	}
}

function getFinalSize()
{
	if (document.getElementById("UCproductDetail1_DLItems__ctl0_ddlSize"))
	{	
		return(document.getElementById("UCproductDetail1_DLItems__ctl0_ddlSize").value);
	}
	else
	{
		if (document.getElementById("UCproductDetail1_DLItems__ctl0_lblSize"))
		{
			return(document.getElementById("UCproductDetail1_DLItems__ctl0_lblSize").innerHTML);
		}
	}
}

function continueWithParent(pid,cid)
{
	if (cid == 0)
	{
		var strlink = "productListing.aspx?ClassIds=" + pid;
		//parent.window.document.location.href =strlink;
		document.location.href =strlink;
	}
	else
	{
		var strlink = "productListing.aspx?ClassIds=" + pid + "," + cid;
		//parent.window.document.location.href =strlink;
		document.location.href =strlink;
	}

}

function checkout()
{
	var strlink = "checkOut.aspx";
	window.document.location.href =strlink;

}

function setShippingAddress()
{
	if(document.getElementById("UCShippingDetail1_chkCheckAddress").checked)
	{
		document.getElementById("UCShippingDetail1_txtAddressShipping").value = document.getElementById("UCConIndAddress1_txtAddress").value
		document.getElementById("UCShippingDetail1_txtAddressShipping").readOnly = true
		document.getElementById("UCShippingDetail1_txtCityShipping").value = document.getElementById("UCConIndAddress1_txtCity").value
		document.getElementById("UCShippingDetail1_txtCityShipping").readOnly = true
		document.getElementById("UCShippingDetail1_txtStateShipping").value = document.getElementById("UCConIndAddress1_txtState").value
		document.getElementById("UCShippingDetail1_txtStateShipping").readOnly= true
		document.getElementById("UCShippingDetail1_txtZipShipping").value = document.getElementById("UCConIndAddress1_txtZip").value
		document.getElementById("UCShippingDetail1_txtZipShipping").readOnly= true
		/*document.getElementById("UCShippingDetail1_ddlCountryShipping").value = document.getElementById("UCConIndAddress1_ddlCountry").value
		document.getElementById("UCShippingDetail1_ddlCountryShipping").readOnly = true		*/
	}
	else
	{
	    //document.getElementById("UCShippingDetail1_txtAddressShipping").value = ""
		document.getElementById("UCShippingDetail1_txtAddressShipping").readOnly = false
		//document.getElementById("UCShippingDetail1_txtCityShipping").value = ""
		document.getElementById("UCShippingDetail1_txtCityShipping").readOnly = false
		//document.getElementById("UCShippingDetail1_txtStateShipping").value = ""
		document.getElementById("UCShippingDetail1_txtStateShipping").readOnly= false
		//document.getElementById("UCShippingDetail1_txtZipShipping").value = ""
		document.getElementById("UCShippingDetail1_txtZipShipping").readOnly= false
	/*	document.getElementById("UCShippingDetail1_ddlCountryShipping").value = 0
		document.getElementById("UCShippingDetail1_ddlCountryShipping").readOnly = false		*/
	}
}



function CustValidateShipping(source, value)
{
	returnVal = true;
	if(document.getElementById("UCShippingDetail1_chkCheckAddress").checked == true)
	{
		returnVal = true;
	}
	else
	{
		if(document.getElementById("UCShippingDetail1_txtAddressShipping").value == "" )
		{
			returnVal = false;
		}
		if(document.getElementById("UCShippingDetail1_txtCityShipping").value == "" )
		{
			returnVal = false;
		}
		if(document.getElementById("UCShippingDetail1_txtStateShipping").value == "" )
		{
			returnVal = false;
		}
		if(document.getElementById("UCShippingDetail1_txtZipShipping").value == "" )
		{
			returnVal = false;
		}
	}
	value.IsValid = returnVal;
}


function setFocusRegister()
{
	document.getElementById(UCConRegister1_txtUsername).focus() = true
}

function popUpTermsCondition()
{
	window.open("../comingSoon/TermsCondition.aspx","mywindow", "status=0, toolbar=0, location=0, menubar=0, scrollbars=0, height=400, width=450")
}
function popUpShippingRates()
{
	window.open("ShippingRates.aspx","mywindow", "status=0, toolbar=0, location=0, menubar=0, scrollbars=0, height=300, width=350");
}


function PassValidationOptional(source, value)
{
	returnVal = true;
	if(document.getElementById("UCConRegister1_chkRegister") != null)
	{ 
		if(document.getElementById("UCConRegister1_chkRegister").checked == true)
		{ 
			document.getElementById("UCConRegister1_hdnEmail").value = document.getElementById("UCConIndBasicInfo1_txtEmail").value
			
			if(document.getElementById("UCConRegister1_txtPassword").value == "" )
			{
				returnVal = false;
				document.getElementById("xRegPassword").style.visibility = "visible"
			}
			else
			{
				document.getElementById("xRegPassword").style.visibility = "hidden"
			}
			if(document.getElementById("UCConRegister1_txtConfirmPassword").value != document.getElementById("UCConRegister1_txtPassword").value)
			{
				returnVal = false;
				document.getElementById("xConfirmPass").style.visibility = "visible"
			}
			else
			{
				document.getElementById("xConfirmPass").style.visibility = "hidden"
			}
			if(document.getElementById("UCConRegister1_ddlQuestion").selectedIndex==0)
			{
				returnVal = false;
				document.getElementById("xSecurityQues").style.visibility = "visible"
			}
			else
			{
				document.getElementById("xSecurityQues").style.visibility = "hidden"
			}
			if(document.getElementById("UCConRegister1_txtAnswer").value == "")
			{
				returnVal = false;
				document.getElementById("xSecurityAns").style.visibility = "visible"
			}
			else
			{
				document.getElementById("xSecurityAns").style.visibility = "hidden"
			}
		}
	}
	value.IsValid = returnVal;
}


function focusValidation(buttonName, emailTxt, errLabelId)
{
	if((document.getElementById(emailTxt).value != "Enter your Email Address") && (document.getElementById(emailTxt).value != ""))
	{
		errMsg = validateEmail(document.getElementById(emailTxt).value);
		if(errMsg == "")
		{
			document.getElementById(buttonName).click();
			document.location.href="#validationAnchor";
		}
		else
		{
			document.getElementById(errLabelId).innerHTML = errMsg
		}
	}
}
function clientSubmit()
{
  if(document.all)
  {
   for (sums = 0; sums < Page_ValidationSummaries.length; sums++) 
   {
    summary = Page_ValidationSummaries[sums];
    summary.style.visibility = "visible"
   }
  }
}
function validateEmail(val)
{
	error=""
	if(val!="")
	{
		valArr = val.split("@")
		if(valArr.length!=2)
		{
			error="Incorrect e-mail format"+"\n";
		}
		else if(valArr[1].search(/\./)==-1||valArr[1].search(/\./)>valArr[1].length-3)
		{
			error="Incorrect e-mail format"+"\n";
		}
	}
	if(error=="")
	{	
		return error;
	}
	else
	{
		return error;
	}
}

function HAboutUsShowInputBox(ddlHearAboutUs)
{
	if(document.getElementById("UCConIndAddress1_ddlHearAboutUs") != null)
	{
		document.getElementById("UCConIndAddress1_txtHearAboutUs").value="";	 
		if(ddlHearAboutUs.selectedIndex==3)
		{
			document.getElementById("UCConIndAddress1_txtHearAboutUs").style.visibility='visible';
			document.getElementById("txtHAUDetails").innerHTML="Enter your Image Consultant code here";	 
			document.getElementById("UCConIndAddress1_txtHearAboutUs").focus()	
			document.getElementById("UCConIndAddress1_hdnImageConsultant").value = "ImageConsultant";
		}
		else if(ddlHearAboutUs.selectedIndex==10)
		{
			document.getElementById("UCConIndAddress1_txtHearAboutUs").style.visibility='visible';
			document.getElementById("txtHAUDetails").innerHTML="Enter your Business Network code here";	 
			document.getElementById("UCConIndAddress1_txtHearAboutUs").focus()	
			document.getElementById("UCConIndAddress1_hdnImageConsultant").value = "4Network";
		}
		else
		{
			document.getElementById("UCConIndAddress1_txtHearAboutUs").style.visibility='hidden';
			document.getElementById("txtHAUDetails").innerHTML="";
			document.getElementById("UCConIndAddress1_hdnImageConsultant").value = "";
		} 
   }     
}

function UpdateInputBox()
{
	if(document.getElementById("UCConIndAddress1_ddlHearAboutUs") != null)
	{
		ddlHearAboutUs= document.getElementById("UCConIndAddress1_ddlHearAboutUs");

		if(ddlHearAboutUs.selectedIndex==3)
		{
			document.getElementById("UCConIndAddress1_txtHearAboutUs").style.visibility='visible';
			document.getElementById("txtHAUDetails").innerHTML="Enter your Image Consultant code here";	 
		}
	}
}

function setEmail()
{
	if(document.getElementById("UCConRegister1_txtUsername"))
	{
	  document.getElementById("UCConIndBasicInfo1_txtEmail").value =  document.getElementById("UCConRegister1_txtUsername").value;
	  document.getElementById("UCConIndBasicInfo1_txtEmail").readOnly = true
	  
	}
}

function downloadPDF()
{
	if(document.getElementById("ddlNewsletters").value != "")
	{
		window.open(document.getElementById("ddlNewsletters").value)
	}
}

function selectImage(name, ID)
{
	//boolImgSelected = true;
	//alert(name);
	
	var objs =document.getElementsByName(name);
	
	for (i = 0; i < objs.length; i++)
	{
		{
			//alert(document.getElementById(objs[i].id).src);
			document.getElementById(objs[i].id).src = "images/StyleQuiz/Chkbox-" + objs[i].id.substring(name.length, objs[i].id.length) + ".gif";
		}
	}
		
		
	document.getElementById(name + ID).src = "images/StyleQuiz/Chkbox-" + ID + "-Selected.gif";
	
	
	/*for (i = 0; i < objs.length; i++)
	{
		if (objs[i].id == (name + ID))
		{
			document.getElementById(objs[i].id + ID).src = "images/StyleQuiz/Chkbox-" + ID + "-Selected.gif";
		}
	}*/
	

//	boolMouseOut = false;
}
function onMouseOver(name, ID)
{
	/*
	alert("onMouseOver - boolImgSelected: " + boolImgSelected);
	
	var objs =document.getElementsByName(name);

    
	for (i = 0; i < objs.length; i++)
	{
		if (objs[i].id == ID)
		{
			//if (document.getElementById(objs[i].id).src.indexOf("-Selected") != -1)	
			{
				document.getElementById(objs[i].id).src = "images/StyleQuiz/Chkbox-" + objs[i].id + "-Selected.gif";
				boolMouseOut = true;
				boolImgSelected = false;
			}
			//alert("onMouseOver: " + boolMouseOut);
		}
	}
	*/

}
function onMouseOut(name, ID)
{
	/*
	//alert("onMouseOut: " + boolMouseOut);
	alert("onMouseOut - boolImgSelected: " + boolImgSelected);
	if (boolImgSelected != true)
	{
		if (boolMouseOut == true)
		{
			//alert("onMouseOut");
			var objs =document.getElementsByName(name);

			for (i = 0; i < objs.length; i++)
			{
				if (objs[i].id == ID)
				{
					document.getElementById(objs[i].id).src = "images/StyleQuiz/Chkbox-" + objs[i].id + ".gif";
				}
			}
		}
	}
	*/
}