var vClose = false;
var t;
//ARRAY OF ALL POPUP WINDOWS
var arrAllPopups = new Array();
arrAllPopups[0] = "popupBox";
arrAllPopups[1] = "popupBoxLarge";
arrAllPopups[2] = "reviewBoxLarge";
arrAllPopups[3] = "currencyEuro";
arrAllPopups[4] = "currencySterling";
arrAllPopups[5] = "popupBooked";
//RUN THROUGH ALL WONDOWS AND REMOVE THEM (BEFORE OPENING NEW ONE)
function closeAllPreviousPopups(){
for (i=0;i<arrAllPopups.length;i++)
{
var Pop=arrAllPopups[i];
var Pop = document.getElementById(Pop);
if (Pop == null) {
	}
	//do nothing
	else {
Pop.style.visibility= 'hidden';
	}
}
} //END IF
/////////////////////////////////////////////////////////////////////////////////////
//POPUP FOR SMALL BOX ADD TO SHORTLIST
function ShowPopup(pnum,c_name){
//CLEAR ANY EXISTING TIMER TO STOP GREY OUTER
clearTimeout(t);
//IF PNUM ISN'T BLANK
if (!pnum == "") {
var popupBoxID='popupBox';
var vPopupBox = document.getElementById(popupBoxID);
var vBlockUI = document.getElementById('blockUI');

var vW = 0, vH = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    vW = window.innerWidth;
    vH = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    vW = document.documentElement.clientWidth;
    vH = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    vW = document.body.clientWidth;
    vH = document.body.clientHeight;
  }
  
   var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
var vY = Math.round((vH/3) + scrOfY)
var vBlockUIHeight = scrOfY+vH+1000
var vW = 500;
//var vH = 1000;
var vX = Math.round((document.body.clientWidth/2)-(vW/2))
//var vY =Math.round((document.body.clientHeight/2)-(vH/2))
vBlockUI.style.display= "block";
vBlockUI.style.height= vBlockUIHeight+"px";
vPopupBox.style.left= vX +"px";
vPopupBox.style.top= vY +"px";
setOpacity(vPopupBox, 0);
vPopupBox.style.visibility= 'visible';
fadeIn(popupBoxID,0);
//ADD PROPERTY NUMBER 
document.getElementById('pnum').innerHTML = pnum;
//CALL THE VALUE OF THE COOKIE BY NAME
cook=getCookie(c_name);
//IF THIS PROPNUM IS NOT ALREADY IN COOKIE 
if (cook.indexOf("'"+pnum+"'")==-1){
//IS THERE ANYTHING IN THE COOKIE
if (cook.indexOf(",")== -1){
// check if its empty - one will give us no comm but lenght of prop num
if (cook.length > 0) {
var shortcount = 2;
}
else {
	//its empty
var shortcount = 1;
}
}
else 
{
//COUNT HOW MANY ITEMS ARE IN COOKIE
var arrCookCount = cook.split(",");
var shortcount = arrCookCount.length +1;
}
//CHANGE THE TOTAL SHORTLIST COUNT - header
document.getElementById('shortlistcount').innerHTML = 'My Shortlist ('+shortcount+')';
//CHANGE THE TOTAL SHORTLIST COUNT - popup
document.getElementById('shortlistcount2').innerHTML = 'My Shortlist ('+shortcount+')';
	if (parseInt(shortcount) == 1){
document.getElementById('acount').innerHTML = '<strong>Your Shortlist now has 1 property</strong>';
	}
	else
	{
document.getElementById('acount').innerHTML = '<strong>Your Shortlist now has '+shortcount+' properties</strong>';
	}
var propshortlistbutton = document.getElementById('viewshortlist');
	if (propshortlistbutton == null) {
	}
	//do nothing
	else {
	propshortlistbutton.innerHTML = '<a href="javascript:;" onClick="largePopup(\'../\');_gaq.push(\'_trackEvent\',\'Navigation_buttons\',\'shortlist-view\',\'popup-'+pnum+'\');"><img src="../graphics/button-main.gif" width="129" height="26" border="0" /></a><div style="position:absolute; left:20px; top:5px; width: 122px; height: 18px;"><a href="javascript:;" onClick="largePopup(\'../\');_gaq.push(\'_trackEvent\',\'Navigation_buttons\',\'shortlist-view\',\'popup-'+pnum+'\');" class="white">My Shortlist ('+shortcount+')</a></div>';
	}

//ADD TO COOKIE LIST
checkCookie('cFav',pnum);
} //END IF PROP IS ALREADY IN COOKIE
//FIRE THE SPINNING STAR
so.write("flashcontent");
//CLOSE BOX AUTOMATICALLY

t=setTimeout("ClosePopup('popupBox')",7000);//***************************************
} //IF PNUM NOT BLANK
}//END MAKE FUNCTION .........................................................

/////////////////////////////////////////////////////////////////////////////////////
//LARGE SHORTLIST FUNCTION //////////////////////////////////////////////////////////
function largePopup(path){
//CHECK ALL PREVIOUS POPUPS ARE CLOSED
closeAllPreviousPopups();
//CLEAR ANY EXISTING TIMER TO STOP GREY OUTER
clearTimeout(t);
//CALL SHORTLIST
showShortlist('cFav',path);
var popupBoxID='popupBoxLarge';
var vPopupBox = document.getElementById(popupBoxID);
var vBlockUI = document.getElementById('blockUI');
var vW = 780;
var vX = Math.round((document.body.clientWidth/2)-(vW/2))
var vY = 100;//Math.round((document.body.clientHeight/2)-(vH/2))
vBlockUI.style.display= "block";
vPopupBox.style.left= vX +"px";
vPopupBox.style.top= vY +"px";
setOpacity(vPopupBox, 0);
vPopupBox.style.visibility= 'visible';
fadeIn(popupBoxID,0);
vClose=false;
}//END MAKE FUNCTION .........................................................
/////////////////////////////////////////////////////////////////////////////////////
//POPUP FOR CURRENCY
function CurrencyPopUp(name){
//CHECK ALL PREVIOUS POPUPS ARE CLOSED
closeAllPreviousPopups();
//CLEAR ANY EXISTING TIMER TO STOP GREY OUTER
clearTimeout(t);
//SET TRUE TO STOP FADE ON ANY EXISTING POPUPS
vClose=true;
var popupBoxID=name;
var vPopupBox = document.getElementById(popupBoxID);
var vBlockUI = document.getElementById('blockUI');
var vW = 500;
var vX = Math.round((document.body.clientWidth/2)-(vW/2))
var vY = 250;//Math.round((document.body.clientHeight/2)-(vH/2))
vBlockUI.style.display= "block";
vPopupBox.style.left= vX +"px";
vPopupBox.style.top= vY +"px";
setOpacity(vPopupBox, 0);
vPopupBox.style.visibility= 'visible';
fadeIn(popupBoxID,0);
//SET TO FALSE SO IT WILL CLOSE WHEN WE WANT THIS ONE TO CLOSE
vClose=false;
//CLOSE BOX AUTOMATICALLY

t=setTimeout("ClosePopup('"+name+"')",3000);//***************************************
}//END MAKE FUNCTION .........................................................

////////////////////////////////////////////////////////////////////////////////////
//CALL WHEN YOU REMOVE A PROEPRTY FROM YOUR SHORLTIST WHEN YOU ARE LOOKING AT IT 
//IT REMAKES IT AND REFILS THE POPUP
function remakePopup(count,path){
	var newCount = parseInt(count) -1
	document.getElementById('shortlistdiv').innerHTML = '';
	if ( parseInt(newCount) == 1){
	document.getElementById('acount').innerHTML = '<strong>Your Shortlist now has 1 property</strong>';
	}
	else {
	document.getElementById('acount').innerHTML = '<strong>Your Shortlist now has '+newCount+' properties</strong>';
	}
	//CHANGE THE TOTAL SHORTLIST COUNT
	if (parseInt(newCount) == 0){
	document.getElementById('shortlistcount').innerHTML = 'My Shortlist (Empty)';
	//MAKE SHORTLIST BUTTON GREY (PROP PAGE ONLY)
	var propshortlistbutton = document.getElementById('viewshortlist')
	if (propshortlistbutton == null) {
	}
	//do nothing
	else {
	propshortlistbutton.innerHTML = '<img src="../graphics/button-main-grey.gif" width="129" height="26" border="0" /><div style="position:absolute; left:33px; top:5px; width: 122px; height: 18px;" class="mainText">My Shortlist</div>';
	}
	} //END IF COUNT = 0
	else //IF COUNT GREATER THAN 0
	{
	document.getElementById('shortlistcount').innerHTML = 'My Shortlist ('+newCount+')';
	//IF THE VIEW SHORTLIST BUTTON IS GREY MAKE RED (PROP PAGE ONLY)
	var propshortlistbutton = document.getElementById('viewshortlist')
	if (propshortlistbutton == null) {
	//do nothing
	}
	else {
	propshortlistbutton.innerHTML = '<a href="javascript:;"onclick="largePopup(\'../\');pageTracker._trackPageview(\'/cottage-holidays/shortlist-view/prop\.asp\');"><img src="../graphics/button-main.gif" width="129" height="26" border="0" /></a><div style="position:absolute; left:20px; top:5px; width: 122px; height: 18px;"><a href="javascript:;" class="white" onclick="largePopup(\'../\');pageTracker._trackPageview(\'/cottage-holidays/shortlist-view/prop\.asp\');">My Shortlist ('+newCount+')</a></div>'
	}
	} //END IF COUNT GREATER THAN 0
	//remake shortlist
 	showShortlist('cFav',path);

}//END MAKE FUNCTION ...........................................................
/////////////////////////////////////////////////////////////////////////////////////
//REVIEW FUNCTION ///////////////////////////////////////////////////////////////////
function reviews(prop,path,star){
//CHECK ALL PREVIOUS POPUPS ARE CLOSED
closeAllPreviousPopups();
//CLEAR ANY EXISTING TIMER TO STOP GREY OUTER
clearTimeout(t);
//SET TRUE TO STOP FADE ON ANY EXISTING POPUPS
vClose=true;
	showReviews(prop,path,star);
var popupBoxID='reviewBoxLarge';
var vPopupBox = document.getElementById(popupBoxID);
var vBlockUI = document.getElementById('blockUI');
var vW = 610;
var vX = Math.round((document.body.clientWidth/2)-(vW/2))
var vY = 150;//Math.round((document.body.clientHeight/2)-(vH/2))
vBlockUI.style.display= "block";
vPopupBox.style.left= vX +"px";
vPopupBox.style.top= vY +"px";

setOpacity(vPopupBox, 0);
vPopupBox.style.visibility= 'visible';
fadeIn(popupBoxID,0);
//SET TO FALSE SO IT WILL CLOSE WHEN WE WANT THIS ONE TO CLOSE
vClose=false;
}//END MAKE FUNCTION .........................................................
//////////////////////////////////////////////////////////////////////////////////////
//CLOSE POPUPS - USE FOR ALL - SEND NAME OF THE DIVIDE
function ClosePopup(name){
//CHECK FOR FALSE AS ANY TRUE MEANS ANOTHER POPUP UP AND STOP REMOVING OUTER GREY
if(vClose==false){
var blockUIID='blockUI';
var vBlockUI = document.getElementById(blockUIID);
vBlockUI.style.display ="none";
}
var popupBoxID=name;
var vPopupBox = document.getElementById(popupBoxID);
//CHECK TO SEE IF ITS THERE BEFORE CLOSING
//alert(vPopupBox.style.opacity);
if (vPopupBox.style.opacity > 0){
fadeOut(popupBoxID,100);
}//END IF
}//END MAKE FUNCTION ...........................................................

function setOpacity(obj, opacity, vChoice){
  	opacity = (opacity == 100)?99.999:opacity;
// IE/Win
  	obj.style.filter = "alpha(opacity:"+opacity+")";
// Safari<1.2, Konqueror
  	obj.style.KHTMLOpacity = opacity/100;
// Older Mozilla and Firefox
  	obj.style.MozOpacity = opacity/100;
// Safari 1.2, newer Firefox and Mozilla, CSS3
  	obj.style.opacity = opacity/100;
}//END MAKE FUNCTION ............................................................
function fadeIn(objId,opacity){
  	if(document.getElementById){
    	obj = document.getElementById(objId);
    		if(opacity <= 100){
      			setOpacity(obj, opacity);
      			opacity += 10;
      			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 30);
    		}//END IF
  	}//END IF
}//END MAKE FUNCTION ...........................................................
function fadeOut(objId,opacity){
  	if(document.getElementById){
    	obj = document.getElementById(objId);
    		if(opacity >=0){
      			setOpacity(obj, opacity);
      			opacity -=10;
      			window.setTimeout("fadeOut('"+objId+"',"+opacity+")",10);
				if(opacity<5){
					var popupBoxID=objId;
					var vPopupBox = document.getElementById(popupBoxID);
					vPopupBox.style.visibility= 'hidden';
				}//END IF
    		}//END IF
  	}//END IF
}//END MAKE FUNCTION ...........................................................
/////////////////////////////////////////////////////////////////////////////////////
//POPUP FOR BOOKED
function bookedPopUp(name){
//CHECK ALL PREVIOUS POPUPS ARE CLOSED
closeAllPreviousPopups();
//CLEAR ANY EXISTING TIMER TO STOP GREY OUTER
clearTimeout(t);

//SET TRUE TO STOP FADE ON ANY EXISTING POPUPS
vClose=true;
var popupBoxID=name;
var vPopupBox = document.getElementById(popupBoxID);
var vBlockUI = document.getElementById('blockUI');
var vW = 300;
var vX = Math.round((document.body.clientWidth/2)-(vW/2))
var vY = 200;//Math.round((document.body.clientHeight/2)-(vH/2))
vBlockUI.style.display= "block";
vPopupBox.style.left= vX +"px";
vPopupBox.style.top= vY +"px";
setOpacity(vPopupBox, 0);
vPopupBox.style.visibility= 'visible';
fadeIn(popupBoxID,0);
//SET TO FALSE SO IT WILL CLOSE WHEN WE WANT THIS ONE TO CLOSE
vClose=false;
//CLOSE BOX AUTOMATICALLY

t=setTimeout("ClosePopup('"+name+"')",11000);//*******************************
}//END MAKE FUNCTION .........................................................
