// JavaScript Document
//COOKIES
//GET COOKIE
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 ;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return ""
}
//SET COOKIE
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
//make cookie - must set path to root
document.cookie=c_name+'='+escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString())+'; path=/'
}
function checkCookie(c_name,value)
{
//call the cookie by name
cook=getCookie(c_name);

//if its not empty add the new number to it with comma
if (cook!=null && cook!="") 
  {
  setCookie(c_name,cook+",'"+value+"'",7);
  }
//if its empty add new number
else 
  {
	 if( cook.indexOf("'"+value+"'")==-1){
    setCookie(c_name,"'"+value+"'",7);
	 }
  } //END IF
} //END FUNCTION
function removeCookie(c_name,value)
{
//call the cookie by name
cook=getCookie(c_name);
//alert(value)
//if its not empty remove the property
if (cook!=null && cook!="") 
  {
	  //SPLIT COOKIE INTO AN ARRAY
	  var arrCook = cook.split(",");
	  var x;
	  var spliceNo = 100000;
	  //SET VALUE OF PROP NUMBER TO REMOVE WITH ' EITHER SIDE
	  var value = "'"+value+"'"
	  	//RUN THROUGH ARRAY
		for (x in arrCook)
			{
				//for quotes in shortlist - currency needs to be shown in full code
				var prop = '';
				var pound = '';
				pound = value.replace("pound", "&pound;")
				prop = pound.replace("euro", "&euro;")
				//IF ANYTHING IN THE ARRAY MATCHES
	 			if(arrCook[x] == prop){
				//alert('match'+arrCook[x]+'#'+prop)  
				//THIS IS THE NUMBER TO SPLICE AT
		 		spliceNo=x
	 			}
	 		}
	//IF SPLICE NUMBER NOT 100000 THEN REMOVE THIS NUM
	if (spliceNo < 100000) {
		//alert('splice')
	  //SPLICE TO REMOVE THE OLD PROPNUM
	  arrCook.splice(spliceNo,1)
  	 // alert('arrCook'+arrCook)
     //RESET COOKIE
     setCookie(c_name,arrCook,7);
     } //END IF
  } //END IF
} //END FUNCTION

//END COOKIES ///////////////////////////////////////////////////////////
function saveQuote(){
	vQuote = document.frmGo.fldPriceQuoted.value;
	if (vQuote !== '') {
	vProp = document.frmGo.fldProp.value;
	vStartD = document.frmGo.fldStartD.value;
	vNights = document.frmGo.fldNights.value;
	vAdults = document.frmCalendar.fldAdults.value;
	vChildren = document.frmCalendar.fldChildren.value;
	vInfants = document.frmCalendar.fldInfants.value;
	vPets = document.frmCalendar.fldPets.value;
	vTravel = document.frmGo.fldTravel.value;
	vCurrency = document.frmCalendar.fldCurrency.value;
	vTravelW = 'Accommodation Only';
	switch(vTravel){
	case 'Acc':
	vTravelW = 'Accommodation Only';
	break;
	case 'Ferry':
	vTravelW = 'Accommodation and Return Ferry';
	break;
	case 'Car Hire':
	vTravelW = 'Accommodation and Car Hire';
	break;
	} //END SWITCH
	
	if (vCurrency == "£" || vCurrency == "&pound;"){
		vCurrency = "&pound;"
	} else {
		vCurrency = "&euro;"
	}
	value = vProp+"-"+vQuote+"-"+vStartD+"-"+vNights+"-"+vAdults+"-"+vChildren+"-"+vInfants+"-"+vPets+"-"+vTravelW+"-"+vCurrency
	//alert(value)
	checkCookie('cQuote_'+vProp,value)
	} // if quote price empty
} //END FUNCTION
