// JavaScript Document
if(self != top)
	top.location.href = self.location.href;

function ValidateQuickQuote()
{
		if ((document.quickquote_small.Budget.value) == "0")
		{
		alert("Please select a value for your Budget per person.");
   		document.quickquote_small.Budget.focus();	
		return false;
		}
		
}

function ValidateQuickQuote_Alt()
{
		if ((document.quickquote_alt.Budget.value) == "0")
		{
		alert("Please select a value for your Budget per person.");
   		document.quickquote_alt.Budget.focus();	
		return false;
		}
		
}

function ValidateQuickQuote_UltLux()
{
		if ((document.quickquote_ultlux.Budget.value) == "0")
		{
		alert("Please select a value for your Budget per person.");
   		document.quickquote_ultlux.Budget.focus();	
		return false;
		}
		
}


function fixTelephoneNumber(number, mobile)
{
	// OFCOM telephone number specification: http://www.ofcom.org.uk/telecoms/ioi/numbers/numplan0207.pdf
	if (number == "") return "";

	// Replace any non-digit with nothing
	number = number.replace(/[\D]/g, '');
	// if it starts with a zero, make it start with the country code
	if (number.substr(0, 1) == "0")
	{
		number = "44" + number.substr(1);
	}
	
	if (mobile)
	{
		// Check it's a valid mobile area
		var Numbers = new Array("71", "72", "73", "74", "75", "77", "78", "79");
		var valid = false;
		var s = number.substr(0, 4);
		for (n in Numbers)
		{
			if (s == "44" + Numbers[n])
			{
				valid = true;
				break;
			}
		}
		if (!valid) return "";
	}
	
	if (number.length != 11 && number.length != 12) return "";
	return number;
}


function ValidateHoliday()
{
	var strCName = document.enqform.CustName.value;
	var strSName = document.enqform.CustSurname.value; 
	

	if(strCName.charAt(0) == " " ){
		  alert("First name cannot start with blank.");
		  document.enqform.CustName.focus();	
		  return false;

	}
	 if(strSName.charAt(0) == " " ){
		  alert("Surname cannot start with blank.");
		  document.enqform.CustSurname.focus();	
		  return false;

	}
	if (document.enqform.CustName.value.length==0)
	{
	alert("Please enter your first name.");
	document.enqform.CustName.focus();	
	return false;
	}
	
	if (document.enqform.CustSurname.value.length==0)
	{
	alert("Please enter your surname.");
	document.enqform.CustSurname.focus();	
	return false;
	}
	
	var tel = document.enqform.CustPhone1.value;
	document.enqform.CustPhone1.value = fixTelephoneNumber(document.enqform.CustPhone1.value);
	if (document.enqform.CustPhone1.value == "" && tel != "")
	{
		alert("Please ensure that your telephone number is valid");
		document.enqform.CustPhone1.value = tel;
		document.enqform.CustPhone1.focus();
		return false;
	}
	
	tel = document.enqform.CustPhone2.value;
	document.enqform.CustPhone2.value = fixTelephoneNumber(document.enqform.CustPhone2.value);
	if (document.enqform.CustPhone2.value == "" && tel != "")
	{
		alert("Please ensure that your telephone number is valid");
		document.enqform.CustPhone2.value = tel;
		document.enqform.CustPhone2.focus();
		return false;
	}
	
	if ((document.enqform.CustEMail.value.length==0) && (document.enqform.CustPhone1.value.length==0) && (document.enqform.CustPhone2.value.length==0))
	{
	alert("Please enter either your email address or a phone number so we can answer your enquiry.");
	document.enqform.CustEMail.focus();	
	return false;
	}
	
	var e = document.enqform.CustEMail.value;
	if (e.length && !e.match(/^[\w-.]+@[\w-]+.[\w-.]+$/))
	{
		alert("Please enter a valid email address, or leave the field blank.");
		document.enqform.CustEMail.focus();
		return false;
	}
	
	
}


function runSlideShow(){
   if (document.all){
      document.images.SlideShowFrame.style.filter="blendTrans(duration=4)"
      document.images.SlideShowFrame.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShowFrame.filters.blendTrans.Apply()      
   }
   document.images.SlideShowFrame.src = preLoad[j].src
   if (document.all){
      document.images.SlideShowFrame.filters.blendTrans.Play()
   }
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)
}

function hideAllErrors() 
{
document.getElementById("newsError").style.display = "none";
}

function checkNewsletter()
{
	email = document.getElementById("email").value;
	
	//clear errors
	hideAllErrors();
	
	if (email == "") {
	document.getElementById("newsError").style.display = "block";
	document.getElementById("email").select();
	document.getElementById("email").focus();
	return false;
	}

}

function ShowDetail(divid){
	
	//set initial variables
	//varSrc = '<a href="javascript:hideHelp(\'' + strMsg + '\',\'' + strHideMsg + '\');" title="' + strHideMsg + '">[ ? ]</a>';
	//now check input
	varMsg = 'display it'; 
	//alert(divid + "_link ");
	//if varMsg exists, stop the form and run scriptaculous effect
	if (varMsg != "") {
		//if (document.getElementById('system_message')) { 
		//document.getElementById('system_message').style.display = 'none';
		//}
		//document.getElementById(divid + '').innerHTML = varSrc;
		document.getElementById(divid).style.display = 'block';
		new Effect.Highlight(divid,{duration:5.0});
		document.getElementById(divid + "_link ").style.display = 'none';
	}
	
}
/* New  javascript function added    */

function handleHttpResponse()
{
		if(http.readyState==4)
	   {

			var result=http.responseText.split(","); 
			if(result.length==1){
				alert("There is no subcategory in this category");
			}	
			
			var len = document.form1.subcategory.options.length;
			if(len>1){			
			for(i=len-1; i >= 1 ; i--){
			   document.form1.subcategory.options[i] = null;
			  }
            }
            for(i=1; i < result.length; i++){	
               textValue = result[i].split("|");
			   document.form1.subcategory.options[i] = new Option(textValue[1],textValue[0]);

			}

	 }
}

function DestinationFill(url){
      cat = document.getElementById("category").value;
	  url="http://"+url+"/destinationServer.php?catid=";
	   http.open("GET", url + escape(cat), true);
	  http.onreadystatechange = handleHttpResponse;
	  http.send(null);


} 
function redirectUrl(){
   
   subcat = document.getElementById("subcategory").value;
   if(subcat == ''){
     alert("Select subcategory");
	  return false;
   }
   document.form1.action="/page/"+subcat;
   document.form1.submit();
   
     

}
function GiftListEnableValue(){
      
	document.getElementById('otheramount').disabled = false;	
}

function GiftListDisableValue(){
        
	document.getElementById('otheramount').disabled = true;	
	document.getElementById('otheramount').value = '';
}


