// JavaScript Document
var feddTot

var feedPlaceID = 0;

function initdefault(){

	//alert("Helloo")

	//QE_setDefaultScreen();

	feddTot = document.getElementById('TOTfeed').value - 1; 

 

}
// ***** 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

 	}

}


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 callPackFeed(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){
	PobjXmlHttp=new XMLHttpRequest()
	PobjXmlHttp.onload=handler
	PobjXmlHttp.onerror=handler
	return PobjXmlHttp
	}
}

/* *************  Combine cities *************** */

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()
	}
}


/* ****************************  */
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'
}

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 = ""
	}
	
}

function openInfo(proid,pic,plcid){

	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.gif' //id="pic<%=prodID%>" src="/images/Plus.jpg"

			document.getElementById(thisanch).className = 'TDBlue-Arial12'
			
			callPackInfo(proid,plcid)

		}

		else{

			alert("Not description available")

		}

	}

	else{
		
		document.getElementById(divPro).style.display = 'none'

		document.getElementById(thisimg).src = '/images/plus.gif'

		document.getElementById(divPro).innerHTML = ''

		document.getElementById(thisanch).className = 'TDBlue-Arial12'

	}



}
// ***** AJAX TO CALL PACK INFORMATION *****
var packID

var divPack
function callPackInfo(prodID,plcID){ 

//alert(prodID)

	packID = prodID

	placeID=plcID

	divPack = 'divv'+prodID

    document.getElementById(divPack).innerHTML = '<img src="/images/wait.gif">';

	url = '/A_Get_PackInfo.aspx?PackID='+ packID +'&placeID='+placeID+'&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

 	}

}

// ***** 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(){

	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'

}

var win = true;	
var winloc = window.location.href
function NewWindowLP(mypage,myname,w,h,scroll){
	
	if (myname !=1){
		
	mypage = '/Mail_Forms/SendPageFriend.asp?PageURL=' + winloc
	}
	
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		 return
	}

function ValidateForm(){
	var emailID=document.SiteEmialList.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
	NewWindowLP('/E-Mails/RecordTableMail.asp','1','600','250','yes');return false
	//return true
 }