/* SORT OUT SCREEN RESOLUTION ISSUES 

if ((screen.width>1000) && (screen.height>748))
{
 document.write('<link rel="stylesheet" href="/css/css.css" type="text/css" media="screen" />');
}
else
{
 document.write('<link rel="stylesheet" href="/css/small.css" type="text/css" media="screen" />');
}
*/

 document.write('<link rel="stylesheet" href="/css/css.css" type="text/css" media="screen" />');


// JUMP MENU

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


// POPUP

function popUp	(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=400,left = 5,top = 5');");
}


function popUpqq	(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=500,left = 5,top = 5');");
}



// SHOW HIDE

function changeDiv(the_div,the_change)
{
  var the_style = getStyleObject(the_div);
  if (the_style != false)
  {
    the_style.display = the_change;
  }
}

function getStyleObject(objectId) {
  if (document.getElementById && document.getElementById(objectId)) {
    return document.getElementById(objectId).style;
  } else if (document.all && document.all(objectId)) {
    return document.all(objectId).style;
  } else {
    return false;
  }
}




function updateEvents(events) { 
    var tother    = document.getElementById('Other');  
    tother.style.display  = ((events=='Other'))?'block':'none';    
 }


// DYNAMIC DROPDOWN

function dynamicSelect(id1, id2) {
	if (document.getElementById && document.getElementsByTagName) {

		var sel1 = document.getElementById(id1);
		var sel2 = document.getElementById(id2);

		var clone = sel2.cloneNode(true);

		var clonedOptions = clone.getElementsByTagName("option");

		refreshDynamicSelectOptions(sel1, sel2, clonedOptions);

		sel1.onchange = function() {
			refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		};
	}
}
function refreshDynamicSelectOptions(sel1, sel2, clonedOptions) {
	while (sel2.options.length) {
		sel2.remove(0);
	}

	var pattern1 = /( |^)(select)( |$)/;
	var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");

	for (var i = 0; i < clonedOptions.length; i++) {

		if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {

			sel2.appendChild(clonedOptions[i].cloneNode(true));
		}
	}
}

// REPLACE CHRS - TITLE CASE

function RReplace(sStr, sStrToFilterOut) {
    var s = '';
    for (var i = 0; i < sStr.length; i++) {
        if (sStr.charAt(i) != sStrToFilterOut) s += sStr.charAt(i);
    } return s;
}


function MakeTitleCase(obj)
{
 obj.value = obj.value.toLowerCase()
 obj.value = obj.value.substr(0,1).toUpperCase() + obj.value.substr(1,obj.value.length-1)
 for (i=0; i<obj.value.length; i++) 
  {
   if (obj.value.substr(i,1)==" ") 
    { obj.value = obj.value.substr(0,i+1) + obj.value.substr(i+1,1).toUpperCase() + obj.value.substr(i+2,obj.value.length-i) }
  }
 obj.value = RReplace(obj.value, '/'); 
}


// REPLACE CHRS - LOWER CASE



function MakeLowerCase(obj){
 obj.value = obj.value.toLowerCase()
 }

function ChangePostcode(obj) {
 if (obj.value.length<5 || obj.value.length>9)
  {
   alert("Invalid Postcode. Please enter postcode correctly, i.e. AB12 3CD")
  } 
 else
  {
   if (obj.value.indexOf(' ')==-1)
    {
     var postcodeset1=obj.value
     var postcodeset2=obj.value
     postcodeset1=obj.value.substring(0,obj.value.length-3);
     postcodeset2=obj.value.substring(obj.value.length-3,99);
     temppostcodestr=postcodeset1+" "+postcodeset2;
     obj.value=temppostcodestr.toUpperCase()
    }
   else
    {
     obj.value=obj.value.toUpperCase()
    }  
  }
}

// VERIFY CONTACT FORM


function verifycontact() {
	var themessage = "Please make sure you complete the following fields: ";
	if (document.cform.name.value=="")
		themessage = themessage + "\n - Your first name";
	 if (document.cform.surname.value=="")
		themessage = themessage + "\n - Your surname";
	 if (document.cform.tel.value=="")
		themessage = themessage + "\n - First telephone number";
	if (document.cform.email.value.indexOf('@', 0) == -1 || document.cform.email.value.indexOf('.', 0) == -1)
		themessage = themessage + "\n - A valid e-mail address";
    if (document.cform.message.value=="")
		themessage = themessage + "\n - Comments";
	 if (themessage == "Please make sure you complete the following fields: ")
		return true;
	else {
		alert(themessage);
		return false; 
	}
	
}


// VERIFY FORM 1

function verify1() {
	var themessage = "Please make sure you complete the following fields: ";
	if (document.form.name.value=="")
		themessage = themessage + "\n - Your first name";
	 if (document.form.surname.value=="")
		themessage = themessage + "\n - Your surname";
	 if (document.form.address1.value=="")
		themessage = themessage + "\n - First line of address";
	 if (document.form.city.value=="")
		themessage = themessage + "\n - Your town or city";
	if (document.form.postcode.value=="")
		themessage = themessage + "\n - Your postcode";
	if (document.form.password.value=="")
		themessage = themessage + "\n - Your password";
	if (document.form.password2.value=="")
		themessage = themessage + "\n - Your password confirmation";
	if (document.form.worktel.value=="" && document.form.hometel.value=="")
		themessage = themessage + "\n - A contact telephone number";
	 if (themessage == "Please make sure you complete the following fields: ")
		return true;
	else {
		alert(themessage);
		return false; 
	}
	
}

// VERIFY FORM 2

function verify2() {
	var themessage = "Please make sure you complete the following fields: ";
	if (document.form.bank.value=="")
		themessage = themessage + "\n - Your bank";
	if (document.form.bankaddress.value=="")
		themessage = themessage + "\n - Your bank address";
	if ((document.form.sort.value=="") || (document.form.sort.value.length < 6))
		themessage = themessage + "\n - A valid sort code";
	if ((document.form.accountno.value=="") || (document.form.accountno.value.length < 8))
		themessage = themessage + "\n - A valid account number";		
	if ( (document.form.terms.checked == false ))
      themessage = themessage + "\n - Agree to terms & conditions";
	 if (themessage == "Please make sure you complete the following fields: ")
		return true;
	else {
		alert(themessage);
		return false; 
	}
	
}





function verifypart() {
	var themessage = "Please make sure you complete the following fields: ";
	if (document.form.name.value=="")
		themessage = themessage + "\n - Your first name";
	 if (document.form.surname.value=="")
		themessage = themessage + "\n - Your surname";
	 if (document.form.address1.value=="")
		themessage = themessage + "\n - First line of address";
	 if (document.form.city.value=="")
		themessage = themessage + "\n - Your town or city";
	if (document.form.postcode.value=="")
		themessage = themessage + "\n - Your postcode";
	if (document.form.password.value=="")
		themessage = themessage + "\n - Your password";
	if (document.form.password2.value=="")
		themessage = themessage + "\n - Your password confirmation";
	if (document.form.worktel.value=="" && document.form.hometel.value=="")
		themessage = themessage + "\n - A contact telephone number";
		if ( (  document.form.quote[0].checked == true ) 
	&& ( document.form.continent.selectedIndex == 0 ) 
	 
	)
	themessage = themessage + "\n - Geographical region";

	if ( (  document.form.quote[0].checked == true ) 
	&& ( document.form.country.selectedIndex == 0 ) 
	 
	)
	themessage = themessage + "\n - Country";

	if ( (  document.form.quote[0].checked == true )
    	&& ( document.form.pax.selectedIndex == 0 )
	
	 
	)
	themessage = themessage + "\n - Passengers";

	if ( (  document.form.quote[0].checked == true )
							
	 && ( document.form.deptdate.value == "dd/mm/yy")
	 
	)
	themessage = themessage + "\n - Departure date";

	if ( (  document.form.quote[0].checked == true )
    	&& ( document.form.carhire[0].checked == false )
	 && ( document.form.carhire[1].checked == false )
	
	 
	)
	themessage = themessage + "\n - Car hire";

	if ( (  document.form.quote[0].checked == true )
							
	 && ( document.form.flightclass[0].checked == false )
	 && ( document.form.flightclass[1].checked == false )
	  && ( document.form.flightclass[2].checked == false )
	   && ( document.form.flightclass[3].checked == false )
	 
	)
	themessage = themessage + "\n - Flight class";

	

	if ( (  document.form.quote[0].checked == true )
							
	 && ( document.form.hotel[0].checked == false )
	 && ( document.form.hotel[1].checked == false )
	 
	)
	themessage = themessage + "\n - Hotel";
	
	
	if ( (  document.form.creditcard[0].checked == true )
							
	 && ( document.form.cardname.value=="" ))
	 
	 
	themessage = themessage + "\n - Credit card name";
	
	if ( (  document.form.creditcard[0].checked == true )
							
	 && ( document.form.cardNumber.value=="" ))
	 
	 
	themessage = themessage + "\n - Credit card number";
	
	
	if ( (  document.form.creditcard[0].checked == true )
							
	 && ( document.form.secode.value=="" ))
	 
	 
	themessage = themessage + "\n - CV2 code";
	
	if ( (  document.form.creditcard[0].checked == true )
    	&& ( document.form.startMonth.selectedIndex == 0 )
	
	 
	)
	themessage = themessage + "\n - Credit card start month";
	
	if ( (  document.form.creditcard[0].checked == true )
    	&& ( document.form.startYear.selectedIndex == 0 )
	
	 
	)
	themessage = themessage + "\n - Credit card start year";
	
	if ( (  document.form.creditcard[0].checked == true )
    	&& ( document.form.expMonth.selectedIndex == 0 )
	
	 
	)
	themessage = themessage + "\n - Credit card end month";
	
	if ( (  document.form.creditcard[0].checked == true )
    	&& ( document.form.expYear.selectedIndex == 0 )
	
	 
	)
	themessage = themessage + "\n - Credit card end year";


	 if (themessage == "Please make sure you complete the following fields: ")
		return true;
	else {
		alert(themessage);
		return false; 
	}
	
}


function verifytravelpref() {
    var themessage = "Please make sure you complete the following fields: ";
	
	if ( (  document.form.quote[0].checked == true ) 
	&& ( document.form.continent.selectedIndex == 0 ) 
	 
	)
	themessage = themessage + "\n - Geographical region";

	if ( (  document.form.quote[0].checked == true ) 
	&& ( document.form.country.selectedIndex == 0 ) 
	 
	)
	themessage = themessage + "\n - Country";

	if ( (  document.form.quote[0].checked == true )
    	&& ( document.form.pax.selectedIndex == 0 )
	
	 
	)
	themessage = themessage + "\n - Passengers";

	if ( (  document.form.quote[0].checked == true )
							
	 && ( document.form.deptdate.value == "dd/mm/yy")
	 
	)
	themessage = themessage + "\n - Departure date";

	if ( (  document.form.quote[0].checked == true )
    	&& ( document.form.carhire[0].checked == false )
	 && ( document.form.carhire[1].checked == false )
	
	 
	)
	themessage = themessage + "\n - Car hire";

	if ( (  document.form.quote[0].checked == true )
							
	 && ( document.form.flightclass[0].checked == false )
	 && ( document.form.flightclass[1].checked == false )
	  && ( document.form.flightclass[2].checked == false )
	   && ( document.form.flightclass[3].checked == false )
	 
	)
	themessage = themessage + "\n - Flight class";

	

	if ( (  document.form.quote[0].checked == true )
							
	 && ( document.form.hotel[0].checked == false )
	 && ( document.form.hotel[1].checked == false )
	 
	)
	themessage = themessage + "\n - Hotel";
	

	
	 if (themessage == "Please make sure you complete the following fields: ")
		return true;
	else {
		alert(themessage);
		return false; 
	}
	
}

function verifyunsub() {
    var themessage = "Please make sure you complete the following fields: ";
	if (document.unsubform.NAME.value=="")
		themessage = themessage + "\n - Your name";
	if (document.unsubform.EMAIL.value.indexOf('@', 0) == -1 || document.unsubform.EMAIL.value.indexOf('.', 0) == -1)
		themessage = themessage + "\n - A valid e-mail address";
	 if (themessage == "Please make sure you complete the following fields: ")
		return true;
	else {
		alert(themessage);
		return false; 
	}
	
}


// BOTH FIELDS IDENTICAL - EMAIL

function BothFieldsIdenticalCaseSensitive() {
var one = document.form.email.value;
var another = document.form.email2.value;
if(one == another) { return true; }
alert("Both email addresses have to be identical");
return false;
}

function BothFieldsIdenticalCaseInsensitive() {
var one = document.form.email.value.toLowerCase();
var another = document.form.email2.value.toLowerCase();
if(one == another) { return true; }
alert("Both email addresses have to be identical");
return false;
}


// BOTH FIELDS IDENTICAL - PASSWORD

function BothFieldsIdenticalCaseSensitive2() {
var one = document.form.password.value;
var another = document.form.password2.value;
if(one == another) { return true; }
alert("Both passwords have to be identical");
return false;
}

function BothFieldsIdenticalCaseInsensitive2() {
var one = document.form.password.value.toLowerCase();
var another = document.form.password2.value.toLowerCase();
if(one == another) { return true; }
alert("Both passwords have to be identical");
return false;
}



function goUnsecure(URLString) {
	var Location;
	Location = "http://" + document.location.hostname;
	if(arguments.length != 0) {
		if (URLString.substring(1,1) == "") {
			Location = Location + URLString;
		}
		else {
			Location = Location + "/" + URLString ;
		};
	};
	document.location.href = Location ;	
};




// CLEAR TEXT FROM EMAIL NEWSLETTER FIELD

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

 
 
// EXCHANGE HTTPS LINKS FOR HTTP

 function xchangelink(URLString) {
	var Location;
	Location = "http://" + document.location.hostname;
	if(arguments.length != 0) {
		if (URLString.substring(1,1) == "") {
			Location = Location + URLString;
		}
		else {
			Location = Location + "/" + URLString ;
		};
	};
	document.location.href = Location ;	
};

// Verify Quick Quote Form
function verifyquickQuote() {
	var themessage = "Please make sure you complete the following fields: ";
	if (document.quickQuote.NAME.value=="")
		themessage = themessage + "\n - Name";
	 if (document.quickQuote.EMAIL.value=="")
		themessage = themessage + "\n - Email";
	 if (document.quickQuote.COMMENTS.value=="")
		themessage = themessage + "\n - Enquiry";
	 if (themessage == "Please make sure you complete the following fields: ")
		return true;
	else {
		alert(themessage);
		return false; 
	}
	
}




function removeSpace(string) {
 return string.split(' ').join('');

}

function removeHyphen(string) {
 return string.split('-').join('');

}


