

function include(fileName){
document.write("<script type='text/javascript' src='"+fileName+"'></script>" );
}
// -----------------------------------
// 	Generic widgets
// -----------------------------------

function DenyFreePlanInFrame(obj)
{
	widget=document.getElementById(obj);
	if(widget!=null)
	{
		if(top != self)		// We re in a Frame
		{
			idElt=document.getElementById("err");
			if(idElt!=null)
			{
				// hide calendar
				err.style.visibility = "visible"; 
				widget.style.visibility = "hidden"; 
				return ;
			}
		}
		widget.style.visibility = "visible"; 
	}
}

function GetDivContainer(div)
{
// check if div exist (for loading inside)
	idDiv=document.getElementById(div);
	if(idDiv==null)
		return null;
	return idDiv;
}
	
function GetRefLinkObject(id)
{
/* check link back to our website */
	idElt=document.getElementById(id);
	if(idElt==null)
		return null;
		
	if(idElt != "http://www.holidaysitecentral.com/")
	{
		alert("Please copy strictly our HTML code ; variations may not work (check URL)");
		return null;
	}
	return idElt;
}
	
function ValidateKeyword(obj,keyword)
{
	if(obj==null)
		return false;
		
	/**/
	txt=obj.innerHTML;
	txt=txt.toLowerCase();
	if(txt!=keyword)
	{
		return false;
	}
	return true;
}

// -----------------------------------
// 	Image Gallery APIs
// -----------------------------------
var wGal=520;
var hGal=430;

// SmoothGallery classes
include("/class/extern/smoothgallery/scripts/mootools.v1.11.js");
include("/class/extern/smoothgallery/scripts/jd.gallery.js");

function LoadGallery(id,legend,thumbnail,speed,lng)
{

//TODO : use new APIs GetRefLinkObject and ValidateKeyword everywhere in Loads...

// check gallery div exist (for loading inside)
	idDiv=document.getElementById("divGallery");
	if(idDiv==null)
		return false;

// check link back to our website
	idElt=document.getElementById("rtLoadGallery");
	if(idElt != "http://www.holidaysitecentral.com/")
	{
		idDiv.innerHTML="Please copy strictly our HTML code ; variations may not work"
		return false;
	}
	txt=idElt.innerHTML;
	txt=txt.toLowerCase();
	if(txt!="image gallery")
	{
		idDiv.innerHTML="Please copy strictly our HTML code ; variations may not work"
		return false;
	}
// resize div properly and inject frame into it
	idDiv.style.width=wGal;
	idDiv.style.height=hGal;
	idDiv.innerHTML='<IFRAME id="frameGal" frameborder="0" height="'+hGal+'" width="'+wGal+'" src="http://www.holidaysitecentral.com/eng/page-image-gallery.php?index='+id+'&legend='+legend+'&thumbnail='+thumbnail+'&speed='+speed+'" scrolling=no frameborder=0 marginheight=0 marginwidth=0 wtransparency=true ></IFRAME>';
	
	return true;
}


// -----------------------------------
// 	calendar APIs
// -----------------------------------

var wCalRow=685;
var hCalRow=675;
var wCalSqw=680;
var hCalSqw=665;

function ShowCalendar(id,type,lng)
{
	obj=GetRefLinkObject("rtCalendar");
	if(obj==null)
	{
		// does the div contain the property ID attached to it??
		obj=GetRefLinkObject("rtCalendar"+id);
		if(obj==null)
			return false;
	}
	
	bOK=ValidateKeyword(obj,"booking calendar") | ValidateKeyword(obj,"availability calendar");
	if(!bOK)
	{
		alert("Please copy strictly our HTML code ; variations may not work (check keyword)");
		return false;
	}		
	
	if (type==1)
		{
		 w=wCalRow;
		 h=hCalRow;
		}
	else
		{
		 w=wCalSqw;
		 h=hCalSqw;
		}
	window.open("http://www.holidaysitecentral.com/eng/page-calendar.php?index="+id+"&lngc="+lng+"&caltyp="+type+"&minsubsreq=6","wclose","width="+w+",height="+(h+10)+",toolbar=no,status=no,left=350,top=250");
	return false;
}

function ShowCalendar_subscribed(id,type,lng)
{
// check link back to our website
	obj=GetRefLinkObject("rtCalendar","rtCalendar");
	if(obj==null)
		return false;

	if (type==1)
		{
		 w=wCalRow;
		 h=hCalRow;
		}
	else
		{
		 w=wCalSqw;
		 h=hCalSqw;
		}
// todo : check the user is really subscribed (paying..)
	window.open("http://www.holidaysitecentral.com/eng/page-calendar.php?index="+id+"&lngc="+lng+"&caltyp="+type+"&minsubsreq=6","wclose","width="+w+",height="+(h+25)+",toolbar=no,status=no,left=350,top=200");
	return false;
}

function LoadCalendar(id,type,lng)
{
	return _loadCalendar(id,type,lng,true);
}

function LoadCalendarNoBookingRequest(id,type,lng)
{
	return _loadCalendar(id,type,lng,false);
}

function _loadCalendar(id,type,lng,bBookingReq)
{
// check Booking Enquiry div exist (for loading inside)
	idDiv=GetDivContainer("divCalendar");
	if(idDiv==null)
	{
		// does the div contain the property ID attached to it??
		idDiv=document.getElementById("divCalendar"+id);
		if(idDiv==null)
			return false;
	}
		
/* check link back to our website */
	idElt=GetRefLinkObject("rtLoadCalendar");
	bOK=ValidateKeyword(idElt,"booking calendar") | ValidateKeyword(idElt,"availability calendar");
	if(!bOK)
	{
		alert("Please copy strictly our HTML code ; variations may not work (check keyword)");
		return false;
	}		

// resize div properly and inject frame into it
	idDiv.style.width=wCalRow;
	idDiv.style.height=hCalRow;
	if(bBookingReq)
		idDiv.innerHTML='<IFRAME id="frameCal" frameborder="0" height="'+hCalRow+'" width="'+wCalRow+'" src="http://www.holidaysitecentral.com/eng/page-calendar.php?index='+id+'&lngc='+lng+'&caltyp='+type+'&minsubsreq=7&booking=true" scrolling="auto"></IFRAME>';
	else
		idDiv.innerHTML='<IFRAME id="frameCal" frameborder="0" height="'+hCalRow+'" width="'+wCalRow+'" src="http://www.holidaysitecentral.com/eng/page-calendar.php?index='+id+'&lngc='+lng+'&caltyp='+type+'&minsubsreq=7&booking=false" scrolling="auto"></IFRAME>';
	
	return true;
}


// -----------------------------------
// 	Booking enquiry APIs
// -----------------------------------

var wBookingEnquiryForm=620;
var hBookingEnquiryForm=405;

function LoadBookingEnquiryForm(id,lng)
{
// check Booking Enquiry div exist (for loading inside)
	idDiv=GetDivContainer("divBookingEnquiry");
	if(idDiv==null)
		return false;
		
/* check link back to our website */
	idElt=GetRefLinkObject("rtLoadBookingEnquiryForm");
	bOK=ValidateKeyword(idElt,"booking form") | ValidateKeyword(idElt,"booking enquiry form");
	if(!bOK)
	{
		alert("Please copy strictly our HTML code ; variations may not work (check keyword)");
		return false;
	}		

	/**/
	txt=idElt.innerHTML;
	txt=txt.toLowerCase();
	if((txt!="booking enquiry form") && (txt!="booking form"))
	{
		idDiv.innerHTML="Please copy strictly our HTML code ; variations may not work"
		return false;
	}
// resize div properly and inject frame into it
	idDiv.style.width=wBookingEnquiryForm;
	idDiv.style.height=hBookingEnquiryForm;
	idDiv.innerHTML='<IFRAME id="frameCal" frameborder="0" height="'+hBookingEnquiryForm+'" width="'+wBookingEnquiryForm+'" src="http://www.holidaysitecentral.com/eng/page-booking-enquiry-form.php?index='+id+'&lngc='+lng+'" scrolling="auto"></IFRAME>';
	return true;
}

// -----------------------------------
// 	Googlemap APIs
// -----------------------------------
 
var wGMap=640;
var hGMap=370;

function initGoogleMap(type,lat,lon,zoom,ismarker,text)
  {
	
// check link back to us
//	idElt=document.getElementById("advertPoweredBy");
//	if(idElt != "http://www.holidaysitecentral.com/")
//		return;
//	if(idElt.innerText != "Holiday Site Central")
//		return;
		
	if (GBrowserIsCompatible())
	{
		var map = new GMap2(document.getElementById("goomap"));
		map.addMapType(type);
		map.setMapType(type);
			
		var centerPoint = new GLatLng(lat,lon);
		map.setCenter(centerPoint,zoom)
		if(ismarker)
		{
				var marker = new GMarker(centerPoint, {draggable: false});
				map.addOverlay(marker);
				
			    GEvent.addListener(map, 'click', function(marker, point) 
				{
			      if (marker) 
				  {
			       marker.openInfoWindowHtml('<div id="gooballoon" class="gooballoon">'+text+'</div>');
			      }
			    });
		}
	}
  }

function ShowGoogleMapEx(id,lng,w,h)
{
	wGMap=w;
	hGMap=h;
	return ShowGoogleMap(id,lng);
}

function ShowGoogleMap(id,lng)
{
// check link back to our website
	obj=GetRefLinkObject("rtLoadGMap");
	bOK=ValidateKeyword(obj,"property map") | ValidateKeyword(obj,"google map");
	if(!bOK)
	{
		alert("Please copy strictly our HTML code ; variations may not work (check keyword)");
		return false;
	}		

	window.open("http://www.holidaysitecentral.com/eng/page-googlemap.php?index="+id+"&lngc="+lng+"&w="+(wGMap-40)+"&h="+(hGMap-50),"wclose","width="+wGMap+",height="+hGMap+",toolbar=no,status=no,left=350,top=300");
	return false;
}

function LoadGoogleMapEx(id,lng,w,h)
{
	wGMap=w;
	hGMap=h;
	return LoadGoogleMap(id,lng);
}

function LoadGoogleMap(id,lng)
{
	idDiv=GetDivContainer("divGoogleMap");
	if(idDiv==null)
	{
		// does the div contain the property ID attached to it??
		idDiv=document.getElementById("divGoogleMap"+id);
		if(idDiv==null)
			return false;
	}
		
	obj=GetRefLinkObject("rtLoadGMap");
	bOK=ValidateKeyword(obj,"property map") | ValidateKeyword(obj,"google map") | ValidateKeyword(obj,"online reservation system");
	if(!bOK)
	{
		alert("Please copy strictly our HTML code ; variations may not work (check keyword)");
		return false;
	}		

// resize div properly and inject frame into it
	idDiv.style.width=wGMap;
	idDiv.style.height=hGMap;
	idDiv.innerHTML='<IFRAME id="frameCal" frameborder="0" height="'+(hGMap+50)+'" width="'+wGMap+'" src="http://www.holidaysitecentral.com/eng/page-googlemap.php?index='+id+'&lngc='+lng+'&w='+(wGMap-40)+'&h='+(hGMap-50)+'" scrolling="auto"></IFRAME>';
	
	return true;
}

// -----------------------------------
// 	Facilities Widget APIs
// -----------------------------------

var wFacilitiesWidget=640;
var hFacilitiesWidget=380;

function SetFacilitiesHeight(h)
{
	hFacilitiesWidget=h;
}

function SetFacilitiesWidth(w)
{
	wFacilitiesWidget=w;
}

function LoadFacilities(id,lng)
{
	idDiv=GetDivContainer("divFacilities");
	if(idDiv==null)
		return false;
		
	obj=GetRefLinkObject("rtLoadFacilities");
	bOK=ValidateKeyword(obj,"rental website creation") | ValidateKeyword(obj,"online booking system");
	if(!bOK)
	{
		alert("Please copy strictly our HTML code ; variations may not work (check keyword)");
		return false;
	}		
// resize div properly and inject frame into it
	idDiv.style.width=wFacilitiesWidget;
	idDiv.style.height=hFacilitiesWidget;
	idDiv.innerHTML='<IFRAME id="frameCal" frameborder="0" height="'+hFacilitiesWidget+'" width="'+wFacilitiesWidget+'" src="http://www.holidaysitecentral.com/eng/page-facilities.php?index='+id+'&lngc='+lng+'" scrolling="auto"></IFRAME>';	
	return true;
}

// -----------------------------------
// 	Flight Booking Widget APIs
// -----------------------------------

var wFlightWidget=470;
var hFlightWidget=252;
var FlightAdvert=0;

function SetFlightBookingHeight(h)
{
	hFlightWidget=h;
}

function SetFlightBookingWidth(w)
{
	wFlightWidget=w;
}

function LoadFlightBookingEx(id,type)
{
	switch(type)
	{
		default:
		case 0: // ADV_300_250_SKYSCANNER_FLIGHTSEARCH
		  SetFlightBookingWidth(310);
		  SetFlightBookingHeight(260);
		  break;
		  
		case 1: // ADV_120_600_SKYSCANNER_FLIGHTSEARCH
		  SetFlightBookingWidth(130);
		  SetFlightBookingHeight(610);
		  break;
		  
		case 2: // ADV_468_60_SKYSCANNER_FLIGHTSEARCH
		  SetFlightBookingWidth(477);
		  SetFlightBookingHeight(70);
		  break;
		  
		case 3: // ADV_468_250_LILIGOTRAVEL
		  SetFlightBookingWidth(477);
		  SetFlightBookingHeight(260);
		  break;
	}
	
	FlightAdvert=type;
	return LoadFlightBooking(id);
}

function LoadFlightBooking(id)
{
	idDiv=GetDivContainer("divFlightBooking");
	if(idDiv==null)
		return false;
		
	obj=GetRefLinkObject("rtLoadFlightBooking");
	bOK=ValidateKeyword(obj,"online booking system");
	if(!bOK)
	{
		alert("Please copy strictly our HTML code ; variations may not work (check keyword)");
		return false;
	}		
// resize div properly and inject frame into it
	idDiv.style.width=wFlightWidget;
	idDiv.style.height=hFlightWidget;
	idDiv.innerHTML='<IFRAME id="frameCal" frameborder="0" height="'+hFlightWidget+'" width="'+wFlightWidget+'" src="http://www.holidaysitecentral.com/eng/page-bookflight.php?index='+id+'&type='+FlightAdvert+'" scrolling="no"></IFRAME>';	
	return true;
}


