

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 GetRefLinkObject(div,id)
{
// check if div exist (for loading inside)
	idDiv=document.getElementById(div);
	if(idDiv==null)
		return null;

/* check link back to our website */
	idElt=document.getElementById(id);
	if(idElt != "http://www.holidaysitecentral.com/")
	{
		idDiv.innerHTML="Please copy strictly our HTML code ; variations may not work (check URL)";
		return null;
	}
	return idElt;
}
	
function ValidateKeyword(obj,keyword)
{
	/**/
	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=640;
var wCalSqw=680;
var hCalSqw=630;

function ShowCalendar(id,type,lng)
{
// check link back to our website
	idElt=document.getElementById("rtCalendar");
	if(idElt != "http://www.holidaysitecentral.com/")
		return false;

	txt=idElt.innerHTML;
	txt=txt.toLowerCase();
	if((txt!="booking calendar") && (txt!="availability calendar"))
		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+",toolbar=no,status=no,left=350,top=300");
	return false;
}

function ShowCalendar_subscribed(id,type,lng)
{
// check link back to our website
	idElt=document.getElementById("rtCalendar");
	if(idElt != "http://www.holidaysitecentral.com/")
		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+",toolbar=no,status=no,left=350,top=300");
	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 calendar div exist (for loading inside)
	idDiv=document.getElementById("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=document.getElementById("rtLoadCalendar");
	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!="booking calendar") && (txt!="availability calendar"))
	{
		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=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=document.getElementById("divBookingEnquiry");
	if(idDiv==null)
		return false;

/* check link back to our website */
	idElt=document.getElementById("rtLoadBookingEnquiryForm");
	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!="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 ShowGoogleMap(id,lng)
{
// check link back to our website
	idElt=document.getElementById("rtLoadGMap");
	if(idElt != "http://www.holidaysitecentral.com/")
		return false;
		
	txt=idElt.innerHTML;
	txt=txt.toLowerCase();
	if((txt!="google map") && (txt!="property map"))
		return false;
	window.open("http://www.holidaysitecentral.com/eng/page-googlemap.php?index="+id+"&lngc="+lng,"wclose","width="+wGMap+",height="+hGMap+",toolbar=no,status=no,left=350,top=300");
	return false;
}

function LoadGoogleMap(id,lng)
{
// check GMap div exist (for loading inside)
	idDiv=document.getElementById("divGoogleMap");
	if(idDiv==null)
		return false;

// check link back to our website
	idElt=document.getElementById("rtLoadGMap");
	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!="google map") && (txt!="property map"))
	{
		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=wGMap;
	idDiv.style.height=hGMap;
	idDiv.innerHTML='<IFRAME id="frameCal" frameborder="0" height="'+hGMap+'" width="'+wGMap+'" src="http://www.holidaysitecentral.com/eng/page-googlemap.php?index='+id+'&lngc='+lng+'" scrolling="auto"></IFRAME>';
	
	return true;
}

// -----------------------------------
// 	Facilities Widget APIs
// -----------------------------------

var wFacilitiesWidget=640;
var hFacilitiesWidget=380;

function LoadFacilities(id,lng)
{
	obj=GetRefLinkObject("divFacilities","rtLoadFacilities");
	if(obj==null)
		return false;
	
	bOK=ValidateKeyword(obj,"rental website creation") | ValidateKeyword(obj,"create vacation website");
	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;
}

