// JavaScript Document
var feddTot
var feedPlaceID = 0;
function initdefault(){
	//alert("Helloo")
	QE_setDefaultScreen();
	//feddTot = document.getElementById('TOTfeed').value - 1; 
 
}

function findPackFrmGet(frmNA){
 	var checkbox_choices = 0;
	var checkbox_values = '';
	var strToURL
	var strcitysIDNA
	var citysID
	var citysNA
	var strIDNA
	//alert(frmNA)
	var form
  		form = document.getElementById 
    	? document.getElementById(frmNA) 
    	: document.forms[frmNA]; 
		//alert(form)
	var boxlength = form.findPacks.length
	//alert(boxlength)
	if (boxlength == undefined){
		boxlength = 1
			//alert(boxlength)
			checkbox_values =  form.findPacks.value;
			//alert(checkbox_values)
			strcitysIDNA = checkbox_values.split('|')
			//if (checkbox_choices == 1){
				citysID = strcitysIDNA[0]
				citysNA = strcitysIDNA[1]
			//checkbox_values =  frmFindPack.findPacks[counter].value;
			//}
	}
	else{
		for (counter = 0; counter < boxlength; counter++){
			if (form.findPacks[counter].checked){ 
				checkbox_choices = checkbox_choices + 1;
				checkbox_values =  form.findPacks[counter].value;
				//alert(checkbox_values)
				strcitysIDNA = checkbox_values.split('|')
				if (checkbox_choices == 1){
					citysID = strcitysIDNA[0]
					citysNA = strcitysIDNA[1]
					//checkbox_values =  frmFindPack.findPacks[counter].value;
				}
				if (checkbox_choices > 1){ 
					
					if (citysID.indexOf(strcitysIDNA[0]) > -1){
						//do nothin
					}
					else{
					citysID = citysID +','+ strcitysIDNA[0]
					citysNA = citysNA +'_'+ strcitysIDNA[1]
					//checkbox_values = checkbox_values +'@'+ frmFindPack.findPacks[counter].value;
					}
					
				}
			}
		}
	}
	//alert(checkbox_values +' = check')
	//alert(citysID +' ID')
	//alert(citysNA +' NA')
	if (citysID == undefined){
		alert('Please check at least one box. Thanks!');
		return;
	}
	else{
		form.allID.value = citysID
		form.allNA.value = citysNA
		form.action = "/Find_Package_to_"+ citysNA +".aspx"
		//document.frmFindPack.action = "/AAA_Find_Packs_CO.asp" //"/Build_Package_to_"+ strToURL +".aspx"
		//document.frmBuildVac.action = "/Build_Itinerary.aspx"
		//alert(document.frmBuildVac.action)
		form.submit()
	}
}


// ***** AJAX TO SHOW PLACE PACK FEEDBACKS *****
function callFeedBacks(IDplace,IDfeed){ 
    document.getElementById('eachFeed').innerHTML = '<img src="/images/wait.gif">';
	url = '/A_Get_PlaceFeedBack.aspx?PlaceID='+ IDplace +'&FeedID=' + IDfeed
	//alert(url)
	//http_request.onreadystatechange = FeedContents;
	Fhttp_request=FeedXmlHttpObject(FeedContents)
	Fhttp_request.open('GET', url, true); 
	Fhttp_request.send(null); 
} 

function FeedContents() { 
	if (Fhttp_request.readyState == 4) { 
	   if (Fhttp_request.status != '') { 
		 divFeedContent =  Fhttp_request.responseText;
		  setTimeout ("document.getElementById('eachFeed').innerHTML =  divFeedContent", 50 );
		  document.getElementById('linkSee').style.display = "block"
 } 
	   else { 
		   alert('There was a problem with the request.'); 
		   document.getElementById('eachFeed').innerHTML =  '';
		} 
	} 

}
function FeedXmlHttpObject(handler){
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This City selector doesn't work in Opera")
		return
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){
		var FstrName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
				FstrName="Microsoft.XMLHTTP"
			}
			try{
				FobjXmlHttp=new ActiveXObject(FstrName)
				FobjXmlHttp.onreadystatechange=handler
				return FobjXmlHttp
			}
			catch(e){
				alert("Error. Scripting for ActiveX might be disabled")
				return
			}
	}
	if (navigator.userAgent.indexOf("Firefox")>=0){
	FobjXmlHttp=new XMLHttpRequest()
	FobjXmlHttp.onload=handler
	FobjXmlHttp.onerror=handler
	return FobjXmlHttp
	}
	if (navigator.userAgent.indexOf("Safari")>=0){
 	FobjXmlHttp=new XMLHttpRequest()
 	FobjXmlHttp.onload=handler
 	FobjXmlHttp.onerror=handler
 	return FobjXmlHttp
 	}
}
// ***** FEEDBACKS NAAVEGATE 

function feedbackward(){
//alert(fnum)
	if (fnum>0){
		window.status=''
		fnum--
		if (fnum==0){
			fnum = 1
		}
		callFeedBacks(feedPlaceID,fedd[fnum])
		//var fcomm = FeedComm[fnum]
		//eval("document.getElementById('eachFeed').innerHTML=fcomm");
		eval("document.getElementById('feedNo').innerHTML=[fnum]+'/'+ feddTot");
		//eval("document.getElementById('feedNoUp').innerHTML=[fnum]+'/'+ feddTot");
	}
}
function feedforward(){
	//alert(fnum)
	if (fnum == 0){
		fnum = 1
	}
	if (fnum<fedd.length-1){
		fnum++
		callFeedBacks(feedPlaceID,fedd[fnum])
		//var comm = FeedComm[fnum]
		//eval("document.getElementById('eachFeed').innerHTML=comm");
		eval("document.getElementById('feedNo').innerHTML=[fnum]+'/'+ feddTot");
		//eval("document.getElementById('feedNoUp').innerHTML=[fnum]+'/'+ feddTot");
	}
	else window.status='End of Customer Feed backs'
}

function openInfo(proid,pic){
	if (pic == ''){
		var pic1 = document.getElementById('pic'+proid).src
		idxpic = pic1.indexOf('Plus')
	}
	else{
		idxpic = pic.indexOf('Plus')
	}
	
	divPro = 'divv'+proid
	thisimg = 'pic'+proid
	thisanch = 'anch'+proid
	//idxpic = pic.indexOf('Plus')
	if (idxpic > 0){
		
		if (document.getElementById(divPro) != null){
			document.getElementById(divPro).style.display = 'block'
			document.getElementById(thisimg).src = '/images/Minus.jpg' //id="pic<%=prodID%>" src="/images/Plus.jpg"
			document.getElementById(thisanch).className = 'Text_12_BlueBold'
			callPackInfo(proid)
		}
		else{
			alert("Not description available")
		}
	}
	else{
		document.getElementById(divPro).style.display = 'none'
		document.getElementById(thisimg).src = '/images/Plus.jpg'
		document.getElementById(divPro).innerHTML = ''
		document.getElementById(thisanch).className = 'Text_Arial12_navy'
	}

}
// ***** AJAX TO CALL PACK INFORMATION *****
var packID
var divPack
function callPackInfo(prodID){ 
//alert(prodID)
	packID = prodID
	divPack = 'divv'+prodID
    document.getElementById(divPack).innerHTML = '<img src="/images/wait.gif">';
	url = '/A_Get_PackInfo.aspx?PackID='+ packID +'&placeID=0&PlaceURL=Home'
	Phttp_request=PackXmlHttpObject(PackContents)
	Phttp_request.open('GET', url, true); 
	Phttp_request.send(null); 
} 

function PackContents() { 
	if (Phttp_request.readyState == 4) { 
	   if (Phttp_request.status != '') { 
		 divPackContent =  Phttp_request.responseText;
		  setTimeout ("document.getElementById('"+ divPack +"').innerHTML =  divPackContent", 50 );
		  setTimeout ("Custom.initP(packID)",100);
 } 
	   else { 
		   alert('There was a problem with the request.'); 
		   document.getElementById(divPack).innerHTML =  '';
		} 
	} 

}
function PackXmlHttpObject(handler){
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This City selector doesn't work in Opera")
		return
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){
		var PstrName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
				PstrName="Microsoft.XMLHTTP"
			}
			try{
				PobjXmlHttp=new ActiveXObject(PstrName)
				PobjXmlHttp.onreadystatechange=handler
				return PobjXmlHttp
			}
			catch(e){
				alert("Error. Scripting for ActiveX might be disabled")
				return
			}
	}
	if (navigator.userAgent.indexOf("Firefox")>=0){
	PobjXmlHttp=new XMLHttpRequest()
	PobjXmlHttp.onload=handler
	PobjXmlHttp.onerror=handler
	return PobjXmlHttp
	}
	if (navigator.userAgent.indexOf("Safari")>=0){
 	PobjXmlHttp=new XMLHttpRequest()
 	PobjXmlHttp.onload=handler
 	PobjXmlHttp.onerror=handler
 	return PobjXmlHttp
 	}
}
// ***** AJAX TO SHOW PACK FEEDBACKS *****
var idpackshow
var totPfeed
var idsPfeed
var PACKfeed

function callfeed(packid,packna){
	idpackshow = packid
	nameanchor = 'anch'+packid
	//alert(nameanchor)
	//COgetAnchorPosition(nameanchor)
	//document.getElementById('feed'+ packid).style.display = 'block';
	//document.getElementById('feedControls'+ packid).style.display = 'block';
	callPackFeed(packid,0)
	
}

function hidePopup(hiddid){
	document.getElementById('feedControls'+ hiddid).style.display = 'none';
	document.getElementById('feed'+ hiddid).style.display = 'none';
	if (document.getElementById('cont'+idpackshow)!=null){
		document.getElementById('cont'+idpackshow).innerHTML = ""
	}
	
}

var Fpackval

function callPackFeed(IDpack,Fpack){ 
   // alert(IDpack+' | '+ Fpack)
	Fpackval = Fpack
	document.getElementById('cont'+idpackshow).innerHTML = '<img src="/images/wait.gif">';
	url = '/A_Get_FeedBack_for_Pack.aspx?packID='+ IDpack +'&packF='+ Fpack
	//http_request.onreadystatechange = FeedContents;
	Pshttp_request=PacksFeedXmlHttpObject(PacksFeedContents)
	Pshttp_request.open('GET', url, true); 
	Pshttp_request.send(null); 
} 

function PacksFeedContents() { 
	if (Pshttp_request.readyState == 4) { 
	   if (Pshttp_request.status != '') { 
		 divPsFeedContent =  Pshttp_request.responseText;
		  setTimeout ("document.getElementById('cont'+idpackshow).innerHTML =  divPsFeedContent", 0 );
		  if (Fpackval == 0){
		  	setTimeout ("Ppassval()", 100);
		  }
		  	  
 } 
	   else { 
		   alert('There was a problem with the request.'); 
		   document.getElementById('cont'+idpackshow).innerHTML =  '';
		} 
	} 

}
function PacksFeedXmlHttpObject(handler){
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This City selector doesn't work in Opera")
		return
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){
		var PsstrName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
				PsstrName="Microsoft.XMLHTTP"
			}
			try{
				PsobjXmlHttp=new ActiveXObject(PsstrName)
				PsobjXmlHttp.onreadystatechange=handler
				return PsobjXmlHttp
			}
			catch(e){
				alert("Error. Scripting for ActiveX might be disabled")
				return
			}
	}
	if (navigator.userAgent.indexOf("Firefox")>=0){
	PsobjXmlHttp=new XMLHttpRequest()
	PsobjXmlHttp.onload=handler
	PsobjXmlHttp.onerror=handler
	return PsobjXmlHttp
	}
	if (navigator.userAgent.indexOf("Safari")>=0){
 	PsobjXmlHttp=new XMLHttpRequest()
 	PsobjXmlHttp.onload=handler
 	PsobjXmlHttp.onerror=handler
 	return PsobjXmlHttp
 	}
}

/* ****************************  */
/* ****************************  */
var idsPart
function Ppassval(){
		
	if (document.getElementById('totIDsFeed') != null){
		PACKnum = 0
		idsPfeed = document.getElementById('totIDsFeed').value;
		totPfeed = document.getElementById('totPackFeed').value;
		idsPart = idsPfeed.split('|');
		callPackFeed(idpackshow,idsPart[0])
		document.getElementById('feedTot'+ idpackshow).innerHTML = totPfeed
		document.getElementById('feed'+ idpackshow).style.display = 'block';
		document.getElementById('feedControls'+ idpackshow).style.display = 'block';
		
	}
}
function Hfeedbackward(){
	if (PACKnum>0){
		window.status=''
		PACKnum--
		callPackFeed(idpackshow,idsPart[PACKnum])
		PACKcount = PACKcount - 1
		eval("document.getElementById('HfeedNo'+idpackshow).innerHTML=PACKcount");
	}
}
function Hfeedforward(){
	
	if (PACKnum<totPfeed-1){
		PACKnum++
		callPackFeed(idpackshow,idsPart[PACKnum])
		PACKcount = PACKnum + 1
		eval("document.getElementById('HfeedNo'+idpackshow).innerHTML=PACKcount");
	}
	else window.status='End of Customer Feed backs'
}
