// JavaScript Document
var http_request = false;
var divFeedID = 'eachFeed'
var divFeedTOP = 'eachFeedtop'
var divFeedContent

function initdefault(){
	
	makeRounded();
		
}


function findObj(elemID){
	var obj=false;
	if(document.all){
		obj=document.all(elemID);
	}
	else{
		if(document.getElementById){
			obj=document.getElementById(elemID);
		}
		else{
			if(document.laers){
				obj=document.laers[elemID];
			}
		}
	}
	return obj;	
}

function displayDiv(divID,display){
	oDiv=findObj(divID);
	if (display){
		oDiv.style['display'] = "";
	}
	else{
		oDiv.style['display'] = "none";
	}
}


function makeRounded() {
  var divs=document.getElementsByTagName('div');
  var numDivs=divs.length;
  var roundedDivs= new Array();
  for(i=0;i<numDivs;i++) {
    if(/\brounded\b/.test(divs[i].className)) {
      roundedDivs[roundedDivs.length]=divs[i];
	 }
  }
  var numRoundedDivs=roundedDivs.length;
  for(i=0;i<numRoundedDivs;i++) {
    var brdiv=roundedDivs[i];
    var tldiv=document.createElement('div');
    brdiv.className=brdiv.className.replace('rounded','');
    tldiv.className='rounded';
    brdiv.parentNode.replaceChild(tldiv,brdiv);
	brdiv.className='brdiv';
    trdiv=document.createElement('div');
	bldiv=document.createElement('div');
    tldiv.appendChild(trdiv);
	trdiv.appendChild(bldiv);
	trdiv.className='trdiv';
	bldiv.appendChild(brdiv);
	bldiv.className='bldiv';
	
  }
}

/*  *****************   AJAX   ************************   */
//var divClose = "<div class='Description' align='right' style='padding:2px 15px 2px 5px;'><a href='/Close' onClick='hiddDiv(); return false'> close <span class='Orange-Arial14'>X</span></a></div>"
var divClose = "<div class='Description' align='right' style='padding:2px 15px 2px 5px;'><a href='/Close' onClick='hiddefeedback(); return false'> close <span class='Orange-Arial14'>X</span></a></div>"
function hiddDiv(){
	displayDiv(divFeedTOP,false);
	document.getElementById('customEach').style.display = 'none';
	document.getElementById('eachFeedFRM').style.visibility= 'hidden' // = 'none';
	document.getElementById(divFeedID).innerHTML ='';
}
function callFeedBacks(PackID,HwMy){ 
	//alert(PackID +' | '+ HwMy)
	displayDiv(divFeedTOP,true)
	document.getElementById(divFeedID).innerHTML = '<img src="/images/wait.gif">';
	 
   url = '/A_Get_PackFeedBack.aspx?PackID='+ PackID +'&HowMany=' + HwMy
   //http_request.onreadystatechange = FeedContents;
   http_request=GetXmlHttpObject(FeedContents)
   http_request.open('GET', url, true); 
   http_request.send(null); 
} 
function FeedContents() { 
	if (http_request.readyState == 4) { 
	   if (http_request.status != '') { 
		 divFeedContent = divClose + http_request.responseText;
		 //document.getElementById(divFeedID).innerHTML = divFeedContent;
		  setTimeout ("document.getElementById(divFeedID).innerHTML =  divFeedContent", 500);
		  setTimeout ("document.getElementById('customEach').style.display = 'block'", 500);
		  setTimeout ("document.getElementById('eachFeedFRM').style.visibility= 'visible'", 500);
		 
 	   } 
	   else { 
		   alert('There was a problem with the request.'); 
		    document.getElementById(divFeedID).innerHTML =  '';
		} 
	} 

}

function GetXmlHttpObject(handler){
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This City selector doesn't work in Opera")
		return
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){
		var strName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
				strName="Microsoft.XMLHTTP"
			}
			try{
				objXmlHttp=new ActiveXObject(strName)
				objXmlHttp.onreadystatechange=handler
				return objXmlHttp
			}
			catch(e){
				alert("Error. Scripting for ActiveX might be disabled")
				return
			}
	}
	if (navigator.userAgent.indexOf("Firefox")>=0 || navigator.userAgent.indexOf("Safari")>=0){
	objXmlHttp=new XMLHttpRequest()
	objXmlHttp.onload=handler
	objXmlHttp.onerror=handler
	return objXmlHttp
	}
}

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

 	}

}

// ***** 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,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 = 'Text_12_BlueBold'
			
			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 = 'Text_Arial12_navy'

	}



}

// ***** 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 );

 } 

	   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'

}
var win = true;	
function NewWindow(mypage,myname,w,h,scroll){
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 triptaketo(cotogo){
var goparts = cotogo.split('|');
var plid = goparts[1];
var plna = goparts[0];
window.location = "/tkby"+ plid +"_Trips_Taken_to_"+ plna +".aspx"
}

function highlight(field)
{
  field.focus();
  field.select();
}
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
		 }
		 
		 //NewWindow('/E-Mails/RecordTableMail.asp','1','600','250','yes');
 		 return true					
	}

function ValidateForm(){
	var emailID = document.SiteEmialList.emailID.value
	var userID = document.SiteEmialList.userID.value
	
	if (emailID==""){
		alert("Please Enter your Email ID")
		document.SiteEmialList.emailID.focus()
		return false
	}
	if (echeck(emailID)==false){
		document.SiteEmialList.emailID.value=""
		document.SiteEmialList.emailID.focus()
		return false
	}
	
	NewWindow('/E-Mails/RecordTableMail.asp?email='+ emailID +'&userID='+ userID +'','1','600','250','yes');return false
	//return true
 }
