

//functionto open up the check availability form in a new popup window
function openCheckAvailabilityPopup(url){

	window.open(url, "","height=255,width=615,resizable=1,menubar=0,toolbar=0,location=0,directories=0,scrollbars=0,status=0");


}

function submitSearchForm(){

	var input = window.opener.document.getElementById('formHandlerDepartureGroup');
	input.value = document.getElementById('departureAirport').value;



	input = window.opener.document.getElementById('formHandlerDepartureDate');
	input.value = document.getElementById('departureDate').value;

	input = window.opener.document.getElementById('formHandlerDurationGroup');
	input.value = document.getElementById('inputnights').value;


	input = window.opener.document.getElementById('formHandlerBoardBasis');
	input.value = document.getElementById('inputboard').value;
	
	input = window.opener.document.getElementById('formHandlerBudget');
	input.value = document.getElementById('inputbudget').value;


	input = window.opener.document.getElementById('formHandlerInputchildren');
	input.value = document.getElementById('inputchildren').value;

	input = window.opener.document.getElementById('formHandlerInputadults');
	input.value = document.getElementById('inputadults').value;

	input = window.opener.document.getElementById('formHandlerAccommCode');
	input.value = document.getElementById('accommCode').value;
	window.opener.document.forms["productSearchForm"].mbs.click();
	window.close();

}
/*
 * This method is used redirect the destinationresortaccommodation 
 * page on deals page with set parameters on search form
 */
function submitSearchFromCatalogPage() {
	document.getElementById("changeParameter").value = true;
	document.getElementById("search_button1").click();
}
/*
 * This method is used to redirect the destination landing page on deals page.
 */
function submitSearchFromDestinationLandingPage() {
	resetPaxMix();
	document.getElementById("formLocation").value = true;
	submitSearchFromCatalogPage();
}
/*
 * This method is show/hide div of checkAvaialbility button on the destination , resort accommodation
 */
function showAvailabilityDiv(divPassed)
{
  thisDiv = document.getElementById(divPassed);
  if (thisDiv)
  {
    if (thisDiv.style.display == "none") {
      thisDiv.style.display = "block";
    }
  }
}

function redirectToNewDestinationPage(){
	var domainName = document.domain;
	var isDestinationsLandingPage = false;
	var locationStr = document.location+"";
	var urlSplit = locationStr.split("/");
	var siteArray = new Array();
	siteArray[0] = "crestaholidays";siteArray[1] = "thomascookgroupagent";siteArray[2] = "tcsignature";siteArray[3] = "thomascooktours";
	var isDomainMatch = false;

	for(var i=0; i< siteArray.length;i++){
		if(domainName.indexOf(siteArray[i]) != -1){
			isDomainMatch = true;
			break;
		}
	}

	if(urlSplit[urlSplit.length-1] == "destinations" || (urlSplit[urlSplit.length-1] == "" && urlSplit[urlSplit.length-2] == "destinations"))
		isDestinationsLandingPage = true;

	if(isDomainMatch && isDestinationsLandingPage)
		document.location="/destination";
}

redirectToNewDestinationPage();


  function getElementsByClassName(classname, node) {
      if(!node) node = document.getElementsByTagName("body")[0];
      var a = [];
      var re = new RegExp('\\b' + classname + '\\b');
      var els = node.getElementsByTagName("*");
      for(var i=0,j=els.length; i<j; i++)
      if(re.test(els[i].className))a.push(els[i]);
      return a;
   }

   
   function styleCorrection(){
	
	if(document.getElementById('thomas-cook-footer') != null){
		var isCustRev = (document.location+"").indexOf('CustomerReviews');
		if(document.getElementById("rightcont").parentNode.id != null && document.getElementById("rightcont").parentNode.id == 'mainWrapper' && isCustRev != -1){
			var divObj = getElementsByClassName("fourlinkul")[0];
			var menuObj = getElementsByClassName("menuPosition")[0];
			var clearObj = getElementsByClassName("clear",document.getElementById('maincont'));
			var taReviewOverviewObj = getElementsByClassName("taReviewOverview")[0];
			taReviewOverviewObj.style.fontSize = "0.7em";
			clearObj[5].className="none";
			document.getElementById("leftcont").appendChild(divObj);
			document.getElementById("leftcont").appendChild(document.getElementById("shareLink"));
			document.getElementById("maincont").appendChild(document.getElementById("rightcont"));
			document.getElementById("mainWrapper").appendChild(menuObj);
			document.getElementById("mainWrapper").appendChild(document.getElementById("mainhead"));
		}
	}else{
		setTimeout ( "styleCorrection()", 1000 );
	}
	
}

function changeDestinationPageText(){
	var domainName = document.domain;
	var isDestinationsLandingPage = false;
	var locationStr = document.location+"";
	var urlSplit = locationStr.split("/");
	var siteArray = new Array();
	siteArray[0] = "directholidays.co.uk";siteArray[1] = "directholidays.ie";siteArray[2] = "panoramaholidays.ie";siteArray[3] = "sunworld.ie";
	var isDomainMatch = false;
	var i=0;
	for(i=0; i< siteArray.length;i++){
		if(domainName.indexOf(siteArray[i]) != -1){
			isDomainMatch = true;
			break;
		}
	}

	if(urlSplit[urlSplit.length-1] == "destinations" || (urlSplit[urlSplit.length-1] == "" && urlSplit[urlSplit.length-2] == "destinations"))
		isDestinationsLandingPage = true;

	if(isDomainMatch && isDestinationsLandingPage){
	var destText = new Array();
	destText[0]="<p>Direct Holidays offers package holidays and flights to destinations all over the world.</p><p>Our Destination section provides you with loads of travel information, including thousands of videos, pictures and details about countries, resorts and hotels across the world. From family favourites like Majorca and Florida to exotic destinations such as Cuba and The Maldives - we are here to make choosing your next holiday a breeze.</p>";
	
	destText[1]="<p>Direct Holidays offers package holidays and flights to destinations all over the world.</p><p>Our Destination section provides you with loads of travel information, including videos, pictures and details about countries, resorts and hotels across the world. From family favourites like Majorca & Tenerife and summer hotspots such as Egypt and Turkey - we are here to make choosing your next holiday a breeze.</p>";
	
	destText[2]="<p>Panorama offers package holidays and flights to destinations all over the world.</p><p>Our Destination section provides you with loads of travel information, including videos, pictures and details about countries, resorts and hotels across the Europe. From holidays in the Balearics to ski breaks in Andorra - we are here to make choosing your next holiday a breeze.</p>";
	
	destText[3]="<p>Sunworld offers package holidays to destinations all over Europe.</p><p>Our Destination section provides you with loads of travel information, including videos, pictures and details about countries, resorts and hotels across the Europe. From breaks in the Algarve to holidays in Turkey - we are here to make choosing your next holiday a breeze.</p>";
	
		if(document.getElementById('destlandlefttop') != null){
			document.getElementById('destlandlefttop').innerHTML = destText[i];
		}
		else{
			setTimeout ( "changeDestinationPageText()", 1000 );
		}
	}
}

changeDestinationPageText();

setTimeout ( "styleCorrection()", 1000 );

setTimeout ( "changeDestinationPageText()", 1000 );


