// JavaScript Document
	var strSiteLink="http://www.treather.com";
	//var strSiteLink="http://localhost:81";
	
	var xmlHttp;
	messageObj = new DHTML_modalMessage();	// We only create one object of this class
	messageObj.setShadowOffset(0);	// Large shadow
	function displayTerms(url)
	{
	
		messageObj.setSource(url);
		messageObj.setCssClassMessageBox('termsdivscroll');
		messageObj.setSize(650,500);
		messageObj.setShadowDivVisible(false);	// Enable shadow for these boxes
		messageObj.display();
	}
	function displayIpointsBox(url)
	{
		//alert(url);
		messageObj.setHtmlContent("");
		messageObj.setSource(url);
		messageObj.setCssClassMessageBox(false);
		messageObj.setSize(400,310);
		messageObj.setShadowDivVisible(false);	// Enable shadow for these boxes
		messageObj.display();
	}
	function displayReviewBox(url)
	{
		//alert(url);
		
		messageObj.setHtmlContent("");
		messageObj.setSource(url);
		messageObj.setCssClassMessageBox('termsdivscroll');
		messageObj.setSize(650,500);
		messageObj.setShadowDivVisible(true);	// Enable shadow for these boxes
		messageObj.display();
	}
	function registerIPointsUser()
	{
		Ajax("divIPointsResponse",strSiteLink + "/tools/registeripointuser.asp?rand=" + Math.random() + "&txtEmail=" + document.getElementById("txtEmail").value + "&txtPassword=" + document.getElementById("txtPassword").value + "&txtFirstName=" + document.getElementById("txtFirstName").value + "&txtLastName=" + document.getElementById("txtLastName").value + "&txtAddress=" + document.getElementById("txtAddress").value + "&txtPostCode=" + document.getElementById("txtPostCode").value + "&isRegister=1" );
		//startCheckingForIPointRegistrationStatus();
	}
	
//	function loginIPoints()
//	{
//		Ajax("divIPointsResponse",strSiteLink + "/tools/loginipointsuser.asp?rand=" + Math.random() + "&txtEmail=" + document.getElementById("txtEmail").value + "&txtPassword=" + document.getElementById("txtPassword").value );
//		//startCheckingForIPointRegistrationStatus();
//	}
	
	function loginIPoints()
	{
		Ajax("divIPointsResponse",strSiteLink + "/tools/registeripointuser.asp?rand=" + Math.random() + "&txtEmail=" + document.getElementById("txtEmail").value + "&txtPassword=" + document.getElementById("txtPassword").value + "&isRegister=0" );
		//startCheckingForIPointRegistrationStatus();
	}
	
	function startCheckingForIPointRegistrationStatus()
	{
		if(document.getElementById("divIPointsResponse").innerHTML.indexOf("successfully") > 0)
		{
			alert("change button");
			return;
		}
		else
		{
			startCheckingForIPointRegistrationStatus();
		}
	}
	function validateIPointsLoginForm()
	{
		if(document.getElementById("txtEmail").value == "")
		{
			alert("Please enter email");
			return;
		}
		if(emailCheck(document.getElementById("txtEmail").value) == false)
		{
			alert("Please enter valid email");
			return;
		}
		if(document.getElementById("txtPassword").value == "")
		{
			alert("Please enter password");
			return;
		}
		loginIPoints();
	}
	function validateIPointsForm()
	{
		if(document.getElementById("txtEmail").value == "")
		{
			alert("Please enter email");
			return;
		}
		if(emailCheck(document.getElementById("txtEmail").value) == false)
		{
			alert("Please enter valid email");
			return;
		}
		if(document.getElementById("txtPassword").value == "")
		{
			alert("Please enter password");
			return;
		}
		if(document.getElementById("txtConfirmPassword").value == "")
		{
			alert("Please enter confirm password");
			return;
		}
		if(document.getElementById("txtPassword").value !=  document.getElementById("txtConfirmPassword").value)
		{
			alert("Passwords are not matching");
			return;
		}
		if(document.getElementById("txtPassword").value.length < 6)
		{
			alert("Password should be atleast 6 characters");
			return;
		}
		if(document.getElementById("txtFirstName").value == "")
		{
			alert("Please enter first name");
			return;
		}
		if(document.getElementById("txtLastName").value == "")
		{
			alert("Please enter last name");
			return;
		}
		registerIPointsUser();
	}
	function GetXmlHttpObject()
	{ 
		var objXMLHttp=null
		if (window.XMLHttpRequest)
		{
		objXMLHttp=new XMLHttpRequest()
		}
		else if (window.ActiveXObject)
		{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
		return objXMLHttp
	} 


	function UpdateAllGiftSection()
	{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		} 
		var url= "allgifts.asp"
		url=url+"?sid="+Math.random();
		xmlHttp.onreadystatechange=show_gifts ;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		return false;
	} 


	function show_gifts() 
	{ 
	
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			display_values=xmlHttp.responseText;		
			document.getElementById("all_gifts_division").innerHTML="<div class=\"RedTextTitleC\">Want to see it all?  No problem! <br />Below you can find the entire selection of great gift ideas currently available on Treat Her…<br /><br /></div>"+display_values;
		} 
		else{
			document.getElementById("all_gifts_division").innerHTML="<div class=\"RedTextTitleC\">Want to see it all?  No problem! <br />Below you can find the entire selection of great gift ideas currently available on Treat Her…<br /><br />(Please be patient, it may take a couple of seconds to load up…)</div>";
		}
	} 
	
	
	
	function adjustIFrameSize (iframeWindow,val) {
	  if (iframeWindow.document.height) {
		var iframeElement = document.getElementById
	(iframeWindow.name);
		iframeElement.style.height = iframeWindow.document.height + 'px';
	   // iframeElement.style.width = iframeWindow.document.width + 'px';
	  }
	  else if (document.all) {
		var iframeElement = document.all[iframeWindow.name];
		if (iframeWindow.document.compatMode &&
			iframeWindow.document.compatMode != 'BackCompat') 
		{
		  iframeElement.style.height = 
	iframeWindow.document.documentElement.scrollHeight + 5 + 'px';
		//  iframeElement.style.width = 
	//iframeWindow.document.documentElement.scrollWidth + 5 + 'px';
		}
		else {
		
		if( iframeElement.style.height=="")
		{
			 iframeElement.style.height=val;
		}
		else
		{
		  iframeElement.style.height = 
	iframeWindow.document.body.scrollHeight;
		}	
	   //   iframeElement.style.width = 
	//iframeWindow.document.body.scrollWidth + 5 + 'px';
		}
	  }
	}


	function addbookmark()
	{
		bookmarkurl=strSiteLink
		bookmarktitle="Treat her - Exquisite, affordable, hassle-free gift ideas for women"
		if (document.all)
		window.external.AddFavorite(bookmarkurl,bookmarktitle)
	}
	

	function GiftGuideSearch()
	{		
		document.frmGiftGuideSearch.submit();
		return false;
	}
	
	function ClearGiftGuideSelection()
	{
	    document.getElementById("cmbOccasion").value="0";
	    document.getElementById("cmbRecipient").value ="0";
	    document.getElementById("cmbPersonality").value="0";
	    document.getElementById("cmbPrice").value="0";
	    document.getElementById("cmbGiftType").value="0";
		
		document.frmGiftGuideSearch.submit();
		return false;        
	}

	
	function Show_Price(ShowVal)
	{
		document.getElementById("hPrice").value=ShowVal;
		Show_Category();
	}
	
	
	function CartVarietyFunction(ProductI,ProductP,ProductAPrice,ProductDiscount,ProductWeight,ProductVarietyID,msg,ispersonalize,RecipientName)
	{
		if(RecipientName==undefined) 
			RecipientName="";
		if(msg==undefined) 
			msg="";

	if ((RecipientName=="" || msg=="") && ispersonalize=="True")
		{
			if(confirm("This gift can be personalised. Please press cancel to enter personalisation details or press Continue to Add this item to your cart without personalisation."))
			{
				callCartVarietyFunction(ProductI,ProductP,ProductAPrice,ProductDiscount,ProductWeight,ProductVarietyID,msg,RecipientName);	
			}
			else
			{
				return false;
			}
		}
		else
		{
			callCartVarietyFunction(ProductI,ProductP,ProductAPrice,ProductDiscount,ProductWeight,ProductVarietyID,msg,RecipientName);	
		}
		
			
	}
	
	function callCartVarietyFunction(ProductI,ProductP,ProductAPrice,ProductDiscount,ProductWeight,ProductVarietyID,msg,RecipientName)
	{
		document.ProductFrm.ProductID.value=ProductI;
		document.ProductFrm.ProductQuantity.value=1;
		document.ProductFrm.ProductPrice.value=ProductP;	
		document.ProductFrm.ProductActualPrice.value=ProductAPrice;
		document.ProductFrm.ProductDiscount.value=ProductDiscount;			
		document.ProductFrm.ProductWeight.value=ProductWeight;		
		document.ProductFrm.ProductVarietyID.value=ProductVarietyID;	
		document.ProductFrm.FPernonalMessage.value=msg;
		document.ProductFrm.FRecipientName.value=RecipientName;
		document.ProductFrm.action=strSiteLink + "/tools/AddCart.asp";
		document.ProductFrm.submit();
	}
	
	function CartFunction(ProductI,ProductP,ProductAPrice,ProductDiscount,ProductWeight)
	{
			document.ProductFrm.ProductID.value=ProductI;
			document.ProductFrm.ProductQuantity.value=1;
			document.ProductFrm.ProductPrice.value=ProductP;	
			document.ProductFrm.ProductActualPrice.value=ProductAPrice;
			document.ProductFrm.ProductDiscount.value=ProductDiscount;			
			document.ProductFrm.ProductWeight.value=ProductWeight;		
			document.ProductFrm.action=strSiteLink + "/tools/AddCart.asp";
			document.ProductFrm.submit();
	}
	function AddToWishlist(ProductI,ProductP,ProductVarietyID)
	{
			document.ProductFrm.ProductID.value=ProductI;
			document.ProductFrm.ProductQuantity.value=1;
			document.ProductFrm.ProductPrice.value=ProductP;	
			document.ProductFrm.ProductVarietyID.value=ProductVarietyID;			
			document.ProductFrm.action=strSiteLink + "/tools/AddToWishList.asp";
			document.ProductFrm.submit();
	}	
	function EmailFunction(PName)
	{
			document.EmailFrm.ProductName.value=PName;
			document.EmailFrm.action=strSiteLink + "/EMailToFriend.asp";
			document.EmailFrm.submit();
	}
	
	function ShowFilter(pagingurl,filter_crit)
	{
			window.location=pagingurl + "&PageFilter="+filter_crit;
	}	
	
	function characterCounter(field, maxlimit, counterField) 
	{	
		countfield = document.getElementById(counterField);
		if (field.value.length > maxlimit) // if too long...trim it!
			field.value = field.value.substring(0, maxlimit);
		else 
			countfield.innerHTML = maxlimit - field.value.length;
	}		
	
	function ShowContentDetail(Direction)
	{
		ContentDiv = jQuery("#content_detail")
		if(Direction == "show"){
			ContentDiv.show();
		}
		else {
			ContentDiv.hide();
		}			
	}	
