
var galleryImage = 1;

function onloadEvent(funcToLoad) {

  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = funcToLoad;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      funcToLoad();
    }
  }
}


function changeImage(imageId){
	if(slideShowEnabled == 1) disableSlideShow();
	if(document.getElementById('mainImage') && document.getElementById('img'+imageId)){
		document.getElementById('mainImage').src = document.getElementById('img'+imageId).src;
		imgNumber = imageId;
	}
}
var lastClickedValue =1;
function changeGalleryPagination(value,maxPages,index){
	if(document.getElementById('galPag'+value)){
		document.getElementById('galPag'+value).style.display = 'block';
	}
	if(value != galleryImage ){
	if(document.getElementById('galPag'+galleryImage)) {
		document.getElementById('galPag'+galleryImage).style.display = 'none';
			var href = document.getElementById('galpos'+value).getAttribute("href");
			    this.document.getElementById('galpos'+value).setAttribute('href_bak', href);
				this.document.getElementById('galpos'+value).style.color="gray";
				this.document.getElementById('galpos'+value).removeAttribute('href'); 
	}

		for(var k=0;k<maxPages;k++){
		if(k==index ){
		var href_bak= document.getElementById('galpos'+lastClickedValue).getAttribute("href_bak");
		if(href_bak == null){
		href_bak = document.getElementById('galpos'+lastClickedValue).getAttribute("href");
		}
		this.document.getElementById('galpos'+lastClickedValue).setAttribute('href', href_bak);
		this.document.getElementById('galpos'+lastClickedValue).style.color="#2EB135";
		}
	}


	}
	
	
	galleryImage = value;
	lastClickedValue = value;
}

/*function attachclicks (value) { 
 if (document.getElementById)
	 { 
	 var clickedonce = 1; 
	 document.getElementById('galpos'+value).onclick = function() 
			{ 
			 if (clickedonce==1)
				 {  
					 alert('already submitted');
					 document.getElementById('galpos'+value).style.color="gray"; 
					 
document.getElementById('galpos'+value).removeAttribute('href'); 
					 return false; 
				 } 
			 clickedonce=1; 
			};
	 } 
}
*/

function changerDisplay(id){
	if(document.getElementById(id)){
		if(document.getElementById(id).style.position == 'absolute'){
			document.getElementById(id).style.position = 'static';
			document.getElementById(id).style.left = '0px';
		} else if(document.getElementById(id).style.position == 'static'){
			document.getElementById(id).style.position = 'absolute';
			document.getElementById(id).style.left = '-500000px';
		}
	}
	
}
function playSlideShow(){
	if(slideShowEnabled == 1){
		if(document.getElementById('img'+slideShowImage)){
			if(document.getElementById('mainImage') && document.getElementById('img'+slideShowImage)){
				document.getElementById('mainImage').src = document.getElementById('img'+slideShowImage).src;
				imgNumber = slideShowImage;
				if(slideShowImage < maxNumber){
					++slideShowImage;
				} else {
					slideShowImage = 1;
				}
			}
			t=setTimeout("playSlideShow()",4000);
		}
	}
}

function enableSlideShow(){
	slideShowEnabled = 1;
	if(document.getElementById('playSlide')) document.getElementById('playSlide').style.display = 'none';
	if(document.getElementById('stopSlide')) document.getElementById('stopSlide').style.display = 'inline';
}

function disableSlideShow(){
	slideShowEnabled = 0;
	clearTimeout(t);
	if(document.getElementById('playSlide')) document.getElementById('playSlide').style.display = 'inline';
	if(document.getElementById('stopSlide')) document.getElementById('stopSlide').style.display = 'none';
}

function getSiMigrationId(){
	var c_name = "SIVISITOR";
	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 "";
}

// Help Page Query string
function getQueryString () {
 var strTheQuery = document.getElementById('theURL').value;
 var strURL1 = "http://thomascooknew.custhelp.com/cgi-bin/thomascooknew.cfg/php/enduser/std_alp.php?p_cv=&p_pv=&p_prods=0&p_cats=&p_hidden_prods=&p_page=1&p_allorg=&advsearchmode=&p_search_text=";
 var strURL2 = "&p_new_search=1&prod_lvl1=0";
 //alert(strURL1);
 //alert(strTheQuery);
 //alert(strURL2);
window.location.href =  strURL1 + strTheQuery + strURL2;
}


function isReturnPressed(event){
	var keyCode=0;
	if(navigator.appName=="Netscape")
	{
		keyCode=event.which;
		
	}
	else{
		keyCode=event.keyCode;
		
	}
	if(keyCode == 13){
		
		if(navigator.appName=="Netscape"){
			event.stopPropagation();
			event.preventDefault();
		}else{
			window.event.cancelBubble = true;
	        window.event.returnValue = false;
		}
	    getQueryString();
	}
}


// Blank method introduced to avoid java-script error when live chat is turned off
/**
function lpAddVars(scope,name,value) {
	
}
**/

/*
function addLeaglNoticeText(){
	var domainName = document.domain;
	var isDestinationsLandingPage = false;
	var locationStr = document.location+"";
	var urlSplit = locationStr.split("/");
	var siteArray = new Array();
	siteArray[0] = "crestaholidays.co.uk";siteArray[1] = "tcsignature.com";siteArray[2] = "thomascooktours.com";
	var isDomainMatch = false;
	var i=0;
	for(i=0; i< siteArray.length;i++){
		if(domainName.indexOf(siteArray[i]) != -1){
			isDomainMatch = true;
			break;
		}
	}

	if(isDomainMatch){
	var hrefAddr = new Array();
	hrefAddr[0]="http://www.crestaholidays.co.uk/legal-notices";
	hrefAddr[1]="http://www.tcsignature.com/legal-notices";
	hrefAddr[2]="http://www.thomascooktours.com/legal-notices";

		var legalFooterPipe = document.createElement('li');
		legalFooterPipe.innerHTML = '| '

		var legalFooter = document.createElement('li');
		legalFooter.innerHTML = '<a rel="NOFOLLOW" href="'+hrefAddr[i]+'">Legal Notice</a>'

	if(document.getElementById('thomas-cook-footer') != null){
		var index=0;
		if(document.getElementById('thomas-cook-footer').childNodes[1] != null)
		index=1;

		//alert(document.getElementById('thomas-cook-footer').childNodes[index]);
		document.getElementById('thomas-cook-footer').childNodes[index].appendChild(legalFooterPipe);
			document.getElementById('thomas-cook-footer').childNodes[index].appendChild(legalFooter);
		}
		else{
			setTimeout ( "addLeaglNoticeText()", 1000 );
		}
	}
}
*/

/*
function pageNotFoundDefaultSearchPanel(){
	var domainName = document.domain;
	var isDestinationsLandingPage = false;
	var locationStr = document.location+"";
	var urlSplit = locationStr.split("/");
	var siteArray = new Array();
	var searchPanels = new Array();
	siteArray[0] = "crestaholidays.co.uk";siteArray[1] = "tcsignature.com";
	//siteArray[0] = "cresta-local.com";siteArray[1] = "tcsignature.com";
	searchPanels[0] = '<iframe width="220" height="1000" frameborder="0" scrolling="no" src="http://ww7.crestaholidays.co.uk/jsp/IframeLogin.jsp?restrictCities=false" id="frmSearch" name="frmSearch" allowtransparency="true"/>';
	searchPanels[1] = '<iframe width="220" height="1000" frameborder="0" scrolling="no" src="http://ww7.tcsignature.com/jsp/IframeLogin.jsp?iframeType=packages" id="frmSearch" name="frmSearch" allowtransparency="true"/>';
	var isDomainMatch = false;
	var isPageNotFound = false;
	var i=0;
	for(i=0; i< siteArray.length;i++){
		if(domainName.indexOf(siteArray[i]) != -1){
			isDomainMatch = true;
			break;
		}
	}
	if(locationStr.indexOf("common/pageNotFound.jsp") != -1)
		isPageNotFound=true;

	if(isDomainMatch && isPageNotFound){
		if(document.getElementById('searchrightcont') != null){
			document.getElementById('searchrightcont').innerHTML="";
			document.getElementById('searchrightcont').innerHTML =searchPanels[i];
		}
		else
			setTimeout ( "pageNotFoundDefaultSearchPanel()", 1000 );
	}
}
*/

//setTimeout ( "addLeaglNoticeText()", 1000 );
//setTimeout ( "pageNotFoundDefaultSearchPanel()", 1000 );

