var xmlDoc;
var actualduration;
var themeselected;
var duration_strt;
var duration_end;
var link;

//Specify path to xml file
var xmlsource="/packagedata.xml";
//var tickercontainer='';

////No need to edit beyond here////////////
//load xml file

if (window.ActiveXObject)
	xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
else if (document.implementation && document.implementation.createDocument)
	xmlDoc= document.implementation.createDocument("","doc",null);


if (typeof xmlDoc!="undefined"){
//document.write(tickercontainer)
	xmlDoc.load(xmlsource)
}

function findtour()
{
if(document.myform.themes.selectedIndex==0)
{
	alert("Please select a theme of your visit to India");
	return false;
}else
{
	themeselected = document.myform.themes.options[document.myform.themes.selectedIndex].value;
}

if(document.myform.duration.selectedIndex==0)
{
	alert("Please select the approximate duration of your visit");
	return false;
}else
{
	actualduration = document.myform.duration.options[document.myform.duration.selectedIndex].value;
}

if(actualduration == "R1")
{
	duration_strt = 2;
	duration_end = 5;
}
if(actualduration == "R2")
{
	duration_strt = 6;
	duration_end = 8;
}
if(actualduration == "R3")
{
	duration_strt = 9;
	duration_end = 12;
}
if(actualduration == "R4")
{
	duration_strt = 13;
	duration_end = 16;
}
if(actualduration == "R5")
{
	duration_strt = 17;
	duration_end = 20;
}
if(actualduration == "R6")
{
	duration_strt = 21;
	duration_end = 31;
}


// old data was here//

var xmlobj = xmlDoc.getElementsByTagName("xmlticker")[0];
var xmlobj_len = xmlDoc.getElementsByTagName("xmlticker").length;

var themeslen = xmlobj.childNodes.length;

var messobj = xmlDoc.getElementsByTagName(themeselected)[0];  // select object on the basis of selected theme
var messlen = messobj.childNodes.length;
var firstchildvalue;
var pkg_shortlisted="";


//alert(messobj.childNodes[0].length);

for(i=0;i<messlen;i++)
{
	if (window.ActiveXObject)
	{
	actualduration = messobj.childNodes[i].getAttribute("duration");
	link = messobj.childNodes[i].getAttribute("url");
	firstchildvalue = messobj.childNodes[i].firstChild.nodeValue;

if((actualduration >= duration_strt) && (actualduration <=duration_end))
{
		pkg_shortlisted += "<A href=/luxury-tours-india/"+link+">" + firstchildvalue + "</A>" + "<BR>";
	
}	
	
	
	}else
	{
//	alert(messobj.childNodes[i].nodeName +"   "+ messobj.childNodes[i].firstchildvalue);
	if(messobj.childNodes[i].nodeName == "message")
	{
		actualduration = messobj.childNodes[i].getAttribute("duration");
		link = messobj.childNodes[i].getAttribute("url");
		firstchildvalue = messobj.childNodes[i].firstChild.nodeValue;

if((actualduration >= duration_strt) && (actualduration <=duration_end))
{
		pkg_shortlisted += "<A href=/luxury-tours-india/"+link+">" + firstchildvalue + "</A>" + "<BR>";
	
}

	}
	}
	

}

showpackage(pkg_shortlisted);
return false;
}

function showpackage(pkg)
{
if(pkg!="")
{
document.getElementById("container").innerHTML = "<B>Tour(s) Found</B><BR>"+pkg+"<BR>";
}else{
document.getElementById("container").innerHTML="<B>Sorry ! No tour found</B><BR>Try changing your criteria";
}
return false;
}


// flashfixit

function flashobj()
{
objects = document.getElementsByTagName("object");
for (var i = 0; i < objects.length; i++)
{
    objects[i].outerHTML = objects[i].outerHTML;
}
}

/*Wish list*/

var wishlistCookie="";

expires2 = new Date();
expires2.setTime (expires2.getTime() + 60 * 60 * 5 * 1000);

function wishlist(item)
{
			var noitem = true;
if( (cookie = getwishlistCookie("wishlistID")) > ""){
	if(cookie.indexOf(item)>=0)
	{
		alert("Item already added");
		noitem = false;
		}
	}


if(noitem)
{
if(wishlistCookie == "")
{
	wishlistCookie = item;
}else{
	wishlistCookie += "|" + item;
}
wishlistCookie +="|";

setWishlist("wishlistID",wishlistCookie);
//return true;
}
}

function getWishlist(){
if( (cookie = getwishlistCookie("wishlistID")) > ""){
	Values = cookie.split("|");
	var places = "";
	var actualPlaces = '<TABLE WIDTH="200" BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="#FFFFE8">';
	if (Values.length >= 0){
		for(i=0;i<Values.length;i+=2)
		{
			actualPlaces += "<TR><TD CLASS='mdl'>";
			actualPlaces += Values[i] + "</TD><TD>" + "<A href='javascript:removeitem("+'"'+Values[i]+'"'+")' class='sml'>remove</A>";
			//places += Values[i] + "<BR>";
			actualPlaces += "</TD></TR>";
		}
	}
	actualPlaces += "<TR><TD ALIGN='left' CLASS='sml'><br>[<A HREF='#' ONCLICK='asktour();return false' style='color:#0000ff;'>Enqiure Now</A>]</TD><TD ALIGN='right' CLASS='sml'><br><A HREF='#' ONCLICK='hidefadebox();return false' style='color:#FF0000;'>Close</A></TD>";
	actualPlaces += "</TABLE>"
	//alert(places);
//document.write(places);
}
return actualPlaces;
}

function setWishlist(name, value){
if (value.length > 0)
 document.cookie = name + "=" + escape(value)+ ";"+"expires=" + expires2.toGMTString()+";"+"path=/;"

alert("The Item has been added to your wish list");
//hidefadebox();
return false;
}

function getwishlistCookie(Name) {
          var search = Name + "="
          if (document.cookie.length > 0) { // if there are any cookies
                    offset = document.cookie.indexOf(search) 
                    if (offset != -1) { // if cookie exists 
                              offset += search.length 
                              // set index of beginning of value
                              end = document.cookie.indexOf(";", offset) 
                              // set index of end of cookie value
                              if (end == -1) end = document.cookie.length
                              return unescape(document.cookie.substring(offset, end))
                    } 
          }
return "";
}

function removeitem(itno)
{
if( (cookie = getwishlistCookie("wishlistID")) > ""){
	newitem = "|"+itno+"|"
	newitem2 = itno+"||";
	if(cookie.indexOf(newitem)>0)
	{
	newcookie = cookie.replace(newitem,'');
	}else
	{
	newcookie = cookie.replace(newitem2,'');
	}
}
if (newcookie.length > 0)
 document.cookie = "wishlistID" + "=" + escape(newcookie)+ ";"+"expires=" + expires2.toGMTString()+";"+"path=/;"

initfunction();
}


/*function asktour()
{
if( (cookie = getwishlistCookie("wishlistID")) > ""){
Values = cookie.split("|");
var enq_string="";
for(i=0;i<Values.length;i=i+2)
	{
	if(enq_string == "")
		//tg=document.write("<font color='red'>Your Wish List : </font>");
		enq_string = "Your Wish List : "+Values[i];
	else
		enq_string += ","+"+"+Values[i];
	}
}else{
	alert("No item found.");
}
window.location.href = "/tour-enquiry.html?tour="+enq_string;
}
*/

function asktour()
{
if( (cookie = getwishlistCookie("wishlistID")) > ""){
Values = cookie.split("|");
var enq_string="";
for(i=0;i<Values.length;i=i+2)
	{
	if(enq_string == "")
		//tg=document.write("<font color='red'>Your Wish List : </font>");
		enq_string = "Your Wish List : "+Values[i];
	else
		enq_string += ","+"+"+Values[i];
	}
}else{
	alert("No item found.");
}
window.location.href = "/tour-enquiry.html?tour="+enq_string;
document.dataform.TBL_LEAD_DESCRIPTION.value = enq_string;
}



//////////////// wish list end here   ////////////////////////////


//Specify display mode. 3 possible values are:
//1) "always"- This makes the fade-in box load each time the page is displayed
//2) "oncepersession"- This uses cookies to display the fade-in box only once per browser session
//3) integer (ie: 5)- Finally, you can specify an integer to display the box randomly via a frequency of 1/integer...
// For example, 2 would display the box about (1/2) 50% of the time the page loads.

var displaymode="0"

var enablefade="yes" //("yes" to enable fade in effect, "no" to disable)
var autohidebox=["no", 5] //Automatically hide box after x seconds? [yes/no, if_yes_hide_after_seconds]
var showonscroll="yes" //Should box remain visible even when user scrolls page? ("yes"/"no)
var IEfadelength=1 //fade in duration for IE, in seconds
var Mozfadedegree=0.05 //fade in degree for NS6+ (number between 0 and 1. Recommended max: 0.2)

////////No need to edit beyond here///////////

if (parseInt(displaymode)!=NaN)
var random_num=Math.floor(Math.random()*displaymode)

function displayfadeinbox(){
var ie=document.all && !window.opera
var dom=document.getElementById
iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
objref=(dom)? document.getElementById("fadeinbox") : document.all.fadeinbox
var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset
var docwidth=(ie)? iebody.clientWidth : window.innerWidth
docheight=(ie)? iebody.clientHeight: window.innerHeight
var objwidth=objref.offsetWidth
objheight=objref.offsetHeight
objref.style.left=docwidth/2-objwidth/2+"px"
objref.style.top=scroll_top+docheight/2-objheight/2+"px"
/////////////////// Getting data - Raj Narang ///////////////////////////////
xyz=getWishlist();
//alert(xyz);

var noitem = "<div class='sml'>No Item Found<BR><BR><A HREF='#' ONCLICK='hidefadebox();return false'>Hide Box</A></div>";

if(xyz==undefined)
{
	objref.innerHTML = noitem;
}else{
objref.innerHTML=xyz
}
////////// my entry ends here ///////////
if (showonscroll=="yes")
showonscrollvar=setInterval("staticfadebox()", 50)

if (enablefade=="yes" && objref.filters){
objref.filters[0].duration=IEfadelength
objref.filters[0].Apply()
objref.filters[0].Play()
}
objref.style.visibility="visible"
if (objref.style.MozOpacity){
if (enablefade=="yes")
mozfadevar=setInterval("mozfadefx()", 90)
else{
objref.style.MozOpacity=1
controlledhidebox()
}
}
else
controlledhidebox()
}

function mozfadefx(){
if (parseFloat(objref.style.MozOpacity)<1)
objref.style.MozOpacity=parseFloat(objref.style.MozOpacity)+Mozfadedegree
else{
clearInterval(mozfadevar)
controlledhidebox()
}
}

function staticfadebox(){
var ie=document.all && !window.opera
var scroll_top=(ie)? iebody.scrollTop : window.pageYOffset
objref.style.top=scroll_top+docheight/2-objheight/2+"px"
}

function hidefadebox(){
objref.style.visibility="hidden"
if (typeof showonscrollvar!="undefined")
clearInterval(showonscrollvar)
}

function controlledhidebox(){
if (autohidebox[0]=="yes"){
var delayvar=(enablefade=="yes" && objref.filters)? (autohidebox[1]+objref.filters[0].duration)*1000 : autohidebox[1]*1000
setTimeout("hidefadebox()", delayvar)
}
}

function initfunction(){
setTimeout("displayfadeinbox()", 100)
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

/*
if (displaymode=="oncepersession" && get_cookie("fadedin")=="" || displaymode=="always" || parseInt(displaymode)!=NaN && random_num==0){
if (window.addEventListener)
window.addEventListener("load", initfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", initfunction)
else if (document.getElementById)
window.onload=initfunction
document.cookie="fadedin=yes"
}
*/