/****************************************************************
Source File 	    :include/AjaxUserInterface.js<BR>
Description         : file description
Copyright           :Bunnik Tours 
Modified date		:24/10/08
Modified by  : Elecom Software Pvt. Ltd., Kolkata
@author : Tuhin Som
*****************************************************************/
var req;

var doesNotSupport = true;

//var BaseAddr="http://www.cstage-one.com/";
//var BaseAddr="http://www.bunniktours.com.au/";
//var BaseAddr="http://localhost/bunniktours-live/";

function AjaxObjectCreate()

{

	if (window.XMLHttpRequest) {

        req = new XMLHttpRequest;

    } else if (window.ActiveXObject) {

        req = new ActiveXObject("Microsoft.XMLHTTP");

    }

	return req;

}



/* Get Country Info Starts */

function GetCountryInfo(countries_id)

{				

	req=AjaxObjectCreate();    

    if(req) 

	{

      	 //alert(BaseAddr+"tour_country_info_process.php?countries_id="+countries_id);

	   req.onreadystatechange = processReqCountryInfo;	   

	   req.open("GET","tour_country_info_process.php?countries_id="+countries_id,true);

       req.send(null);

    } 

}



function processReqCountryInfo() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {			   
					//alert(req.responseText);
					document.getElementById('country_info').innerHTML = req.responseText;				 

           } 

      }

}

/* Get Country Info Ends */



/* Details Content Starts */

function GetDetailsContentBlock(url,messg)

{				

	req=AjaxObjectCreate();    

    if(req) 

	{

      	 

	   req.onreadystatechange = processdetailsSpeed;	   

	    req.open("GET",url+"&messg="+messg,true);

       req.send(null);

    } 

}



function processdetailsSpeed() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {			   
					
					document.getElementById('details_content').innerHTML = req.responseText;				 

           } 

      }

 }

/* Details Content Ends */



/* From Preview Details Content Starts */

function GetDetailsContentBlockFromPreview(url,messg)

{				

	req=AjaxObjectCreate();    

    if(req) 

	{

      	 

	   req.onreadystatechange = processGetDetailsContentBlockFromPreview;	   

	    req.open("GET",url+"&messg="+messg,true);

       req.send(null);

    } 

}



function processGetDetailsContentBlockFromPreview() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {			   

					document.getElementById('details_content').innerHTML = req.responseText;				 

           } 

      }

 }

/* From Preview Details Content Starts */



/* Submit FrmEcard Starts */

function SubmitFrmEcard()

{				

	req=AjaxObjectCreate();    

    if(req) 

	{

      	 var poststr = "YourName=" + document.getElementById("YourName").value+"&YourEmail=" + document.getElementById("YourEmail").value+"&RecipientName=" + document.getElementById("RecipientName").value+"&RecipientEmail=" + document.getElementById("RecipientEmail").value+"&YourComments=" + document.getElementById("YourComments").value+"&gallery_image_id=" + document.FrmEcard.gallery_image_id.value+"&tour_id=" + document.getElementById("tour_id").value;

		req.onreadystatechange = processSubmitFrmEcard;	   

		req.open("GET","tour_gallery_ecard_process.php?"+poststr,true);

		req.send(null);

    } 

}



function processSubmitFrmEcard() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {		

		   		

		   		var msg_no=trim(req.responseText).substr(0,1);

				var msg_test=trim(req.responseText).substr(2);

				if(msg_no == 1)

				{

					document.getElementById("ecard_errmsg").innerHTML = "";	

					document.getElementById("RecipientName").value="";

					document.getElementById("RecipientEmail").value="";

					document.getElementById("YourComments").value="";

					document.getElementById("ecard_content").style.display = 'none';

					document.getElementById("ecard_msg").innerHTML = "E-card is sent successfully.";					

				}

				else

				{

					document.getElementById("ecard_errmsg").innerHTML = "";

					document.getElementById("ecard_errmsg").innerHTML = msg_test;

				}				 

           } 

      }

}

/* Submit FrmEcard Ends */



/* Submit FrmEcard From Preview Starts */

function SubmitFrmEcardFromPreview(imgId)

{				

	req=AjaxObjectCreate();    

    if(req) 

	{

      	 var poststr = "YourName=" + document.getElementById("YourName").value+"&YourEmail=" + document.getElementById("YourEmail").value+"&RecipientName=" + document.getElementById("RecipientName").value+"&RecipientEmail=" + document.getElementById("RecipientEmail").value+"&YourComments=" + document.getElementById("YourComments").value+"&gallery_image_id=" + imgId+"&tour_id=" + document.getElementById("tour_id").value+"&submit_from=preview";

		req.onreadystatechange = processSubmitFrmEcardFromPreview;	   

		req.open("GET","tour_gallery_ecard_process.php?"+poststr,true);

		req.send(null);

    } 

}



function processSubmitFrmEcardFromPreview() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {				   		

		   		GetDetailsContentBlock(req.responseText);													

           } 

      }

}

/* Submit FrmEcard From Preview Ends */





/* Ecard Preview Starts */

function EcardPreview()

{				
//alert(document.FrmEcard.gallery_image_id.value);
	req=AjaxObjectCreate();    

    if(req)
	{

      	 var poststr = "YourName=" + document.getElementById("YourName").value+"&YourEmail=" + document.getElementById("YourEmail").value+"&RecipientName=" + document.getElementById("RecipientName").value+"&RecipientEmail=" + document.getElementById("RecipientEmail").value+"&YourComments=" + document.getElementById("YourComments").value+"&gallery_image_id=" + document.FrmEcard.gallery_image_id.value+"&tour_id=" + document.getElementById("tour_id").value;
//alert(poststr);
		req.onreadystatechange = processEcardPreview;	   

		req.open("GET","tour_gallery_ecard_preview.php?"+poststr,true);

		req.send(null);

    } 

}



function processEcardPreview() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {				   										

				var msg_no=trim(req.responseText).substr(0,1);

				var msg_test=trim(req.responseText).substr(2);

				if(msg_no == 1)

				{
//alert(msg_test);
					document.getElementById('details_content').innerHTML = msg_test;					

				}

				else

				{

					document.getElementById("ecard_errmsg").innerHTML = "";

					document.getElementById("ecard_errmsg").innerHTML = msg_test;

				}	

           } 

      }

}

/* Ecard Preview Ends */



/* Ecard Preview Starts */

function GetDepartureDates(tour_id)

{			

	req=AjaxObjectCreate();    

    if(req) 

	{

		var poststr = "tour_id=" + tour_id+"&preferred_departure_date=" + document.getElementById("preferred_departure_date").value;		

		req.onreadystatechange = processGetDepartureDates;	   

		req.open("GET","booking-date-process.php?"+poststr,true);

		req.send(null);

    } 

}



function processGetDepartureDates() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {			   		

				var msg_no=trim(req.responseText).substr(0,1);

				var msg_test=trim(req.responseText).substr(2);

				if(msg_no == 1)

				{

//					var obj = document.getElementById('departure_date');					
					var obj = document.getElementById('departure_date_div');					

//					eval(msg_test);	
					obj.innerHTML=msg_test;

				}

				else

				{

					alert(msg_test);

				}	

           } 

      }

}

/* Ecard Preview Ends */
/* state field population starts */

function GetStateFields()

{			

	req=AjaxObjectCreate();    

    if(req) 
	{		

		req.onreadystatechange = processGetStateFields;	   

		req.open("GET","state-pop.php?cid="+document.getElementById("country").value,true);

		req.send(null);

    } 

}



function processGetStateFields() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {

				var msg_test=req.responseText;
				//alert(msg_test+"\n"+msg_no);
				
					var obj = document.getElementById('stateDiv');					
					obj.innerHTML=msg_test;
	

           } 

      }

}

/* state field population ends */
/* state field population for information request page starts */

function GetStateFieldsInf()

{			

	req=AjaxObjectCreate();    

    if(req) 
	{		

		req.onreadystatechange = processGetStateFieldsInf;	   

		req.open("GET","state-pop.php?cid="+document.getElementById("country").value+"&page=inf",true);

		req.send(null);

    } 

}



function processGetStateFieldsInf() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {

				var msg_test=req.responseText;
				//alert(msg_test+"\n"+msg_no);
				
					var obj = document.getElementById('stateDiv');					
					obj.innerHTML=msg_test;
	

           } 

      }

}

/* state field population ends */

/*Date process in banner manager starts*/
var opt;

function GetDateFields(optn)

{			

	req=AjaxObjectCreate(); 
	if(optn=='1')
	{
		opt="120px";	
	}
	if(optn=='2')
	{
		opt="45px";	
	}
	if(optn=='')
	{
		opt="20px";	
	}

    if(req) 

	{

		var poststr = "dispOption=" + document.getElementById("dispOption").value;				

		req.onreadystatechange = processGetDateFields;	   

		req.open("GET","banner_date_fields.php?"+poststr,true);

		req.send(null);

    } 

}



function processGetDateFields() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {

				var msg_test=req.responseText;
				//alert(msg_test+"\n"+msg_no);
				
					var obj = document.getElementById('date_div');	
					obj.style.height=opt;
					obj.innerHTML=msg_test;
	

           } 

      }

}

/*Date process in banner manager starts*/

/*Email Check starts*/

function chkEmail()

{			

	req=AjaxObjectCreate(); 
	
    if(req) 

	{

		req.onreadystatechange = processChkEmail;	   

		req.open("GET","chkmail.php?email="+document.frm_registration.contact_email.value,true);

		req.send(null);

    } 

}



function processChkEmail() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {

				var msg_no=trim(req.responseText);


				if(msg_no == "1")

				{

					document.frm_registration.emailValid.value=2;
					document.frm_registration.contact_email.value="";
					document.frm_registration.contact_password.value="";
					document.frm_registration.confirm_password.value="";
					alert('The email / username is already registered. Please login or use a different email address to register.');
					document.frm_registration.contact_email.focus();

				}

				if(msg_no == "2")

				{
					document.frm_registration.emailValid.value=2;
					document.frm_registration.contact_email.value="";
					document.frm_registration.contact_password.value="";
					document.frm_registration.confirm_password.value="";					
					alert('Username(Email) required.');	
					document.frm_registration.contact_email.focus();
				}
				if(msg_no == "0")

				{
					document.frm_registration.emailValid.value=1;
				}
				
	

           } 

      }

}
function chkEmailforNL()

{			

	req=AjaxObjectCreate(); 
	
    if(req) 

	{

		req.onreadystatechange = processChkEmailforNL;	   

		req.open("GET","chkmailforNL.php?email="+document.form.Email.value,true);

		req.send(null);

    } 

}



function processChkEmailforNL() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {

				var msg_no=trim(req.responseText);
				if(msg_no == "1")
				{
					document.getElementById('NLdiv').style.display='none';
					document.getElementById('is_newsletter').checked=false;
				}
				if(msg_no == "0")
				{
					document.getElementById('NLdiv').style.display='block';
				}
           } 

      }

}

/*Email Check ends*/
/*Date process in banner manager starts*/

/*about us staff-tab section starts*/
var glob_tab_id;
var fromLinkType;/*next button 1, prev button 2*/
function getStaff(tab_id,fromTypeId)
{		
//	alert("1")
	document.getElementById('city2').style.display= 'none';
	document.getElementById('city1').style.display= '';	
	fromLinkType=fromTypeId;
	glob_tab_id=tab_id;
	req=AjaxObjectCreate(); 
	document.getElementById('prev_nxt').innerHTML="";
	
	if(fromTypeId==1)
	fromVal=parseInt(document.getElementById('fromVal').value)+6;
	if(fromTypeId==2)	
	fromVal=parseInt(document.getElementById('fromVal').value)-6;
	if(fromTypeId==null)	
	fromVal=0;
	
	document.getElementById('fromVal').value=fromVal;
	//alert(fromVal);
    if(req) 

	{

		req.onreadystatechange = processGetStaff;	   

		req.open("GET","staff_list.php?tab_id="+glob_tab_id+"&fromValue="+fromVal,true);

		req.send(null);

    } 

}



function processGetStaff() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {
				document.getElementById('staff_description').innerHTML='';		
				var msg_html=trim(req.responseText);
				
				var obj = document.getElementById('country');	
					document.getElementById('prev_nxt').innerHTML="";
					obj.innerHTML=msg_html;
				
				document.getElementById('country1_a').className = "";
				document.getElementById('country2_a').className = "";	
				document.getElementById('country3_a').className = "";
				
				document.getElementById('country'+glob_tab_id+'_a').className = "selected";
				
				//alert(msg_html)
				/*if(glob_tab_id==1)
				{
					//alert(glob_tab_id)
					var obj = document.getElementById('country'+glob_tab_id);	
					document.getElementById('prev_nxt').innerHTML="";
					obj.innerHTML=msg_html;
					//getPrevNxtBtn(glob_tab_id,fromLinkType);
					//alert(obj.innerHTML);
					//alert(document.getElementById('prev_nxt_temp').innerHTML);
					//obj.style.display = '';
				}*/
				

				document.getElementById('prev_nxt').innerHTML = document.getElementById('prev_nxt_temp').innerHTML;

           } 

      }

}
/*for melbourn starts*/

var glob_tab_id_mel;
var fromLinkType_mel;/*next button 1, prev button 2*/
function getStaff_mel(tab_id_mel,fromTypeId_mel)
{		
	fromLinkType_mel=fromTypeId_mel;
	glob_tab_id_mel=tab_id_mel;
	req=AjaxObjectCreate(); 
	document.getElementById('prev_nxt_mel').innerHTML="";
	
	if(fromTypeId_mel==1)
	fromVal_mel=parseInt(document.getElementById('fromVal_mel').value)+6;
	if(fromTypeId_mel==2)	
	fromVal_mel=parseInt(document.getElementById('fromVal_mel').value)-6;
	if(fromTypeId_mel==null)	
	fromVal_mel=0;
	
	document.getElementById('fromVal_mel').value=fromVal_mel;
	//alert(fromVal);
    if(req) 

	{

		req.onreadystatechange = processGetStaff_mel;	   

		req.open("GET","staff_list-mel.php?tab_id="+glob_tab_id_mel+"&fromValue="+fromVal_mel,true);

		req.send(null);

    } 

}



function processGetStaff_mel() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {
				document.getElementById('staff_description_mel').innerHTML='';		
				var msg_html=trim(req.responseText);
				
				var obj = document.getElementById('country_mel');	
					document.getElementById('prev_nxt_mel').innerHTML="";
					obj.innerHTML=msg_html;
				
				document.getElementById('country1_a_mel').className = "";
				document.getElementById('country2_a_mel').className = "";	
				document.getElementById('country3_a_mel').className = "";
				
				document.getElementById('country'+glob_tab_id_mel+'_a_mel').className = "selected";
				
//				alert(msg_html)
				/*if(glob_tab_id==1)
				{
					//alert(glob_tab_id)
					var obj = document.getElementById('country'+glob_tab_id);	
					document.getElementById('prev_nxt').innerHTML="";
					obj.innerHTML=msg_html;
					//getPrevNxtBtn(glob_tab_id,fromLinkType);
					//alert(obj.innerHTML);
					//alert(document.getElementById('prev_nxt_temp').innerHTML);
					//obj.style.display = '';
				}*/
				

				document.getElementById('prev_nxt_mel').innerHTML = document.getElementById('prev_nxt_temp_mel').innerHTML;

           } 

      }

}

/*for melbourn ends*/
/*about us ajax starts*/
var globalAboutUsId;
function GetAboutUsContent(aboutus_id)
{
	globalAboutUsId=aboutus_id;
	req=AjaxObjectCreate(); 
    if(req) 

	{

		req.onreadystatechange = processGetAboutUsContent;	   

		req.open("GET","aboutus_section.php?aboutus_id="+aboutus_id,true);

		req.send(null);

    } 
}



function processGetAboutUsContent() 
{//alert(req.readyState+"-"+req.status);
       if(req.readyState == 4) 
	   {
           if(req.status == 200) 
		   {
				var msg_test=req.responseText;
				if (globalAboutUsId==23)
				{
					document.getElementById('staff_div').style.display='block';
					var obj = document.getElementById('about_us_div');	
					obj.innerHTML='';
					document.getElementById('city1_a').className = "selected";
					document.getElementById('city2_a').className = "";
					
					/*melbourn office section start*/
					document.getElementById('country1_a_mel').className = "selected";
					document.getElementById('country2_a_mel').className = "";	
					document.getElementById('country3_a_mel').className = "";
					/*melbourn office section end*/
					/*Adelaide office section start*/
					document.getElementById('country1_a').className = "selected";
					document.getElementById('country2_a').className = "";	
					document.getElementById('country3_a').className = "";
					/*Adelaide office section ends*/
					
					
					/*melbourn office section start*/
					if(document.getElementById(holdId_mel))
					{
						//alert(document.getElementById(holdId).innerHTML);
						document.getElementById(holdId_mel).style.display = 'none';
						document.getElementById(holdImgId_mel).style.border='0px';
						document.getElementById(holdTdId_mel).style.background='none';
						//alert(document.getElementById(holdId).innerHTML);
						holdId_mel='';					
					}
					document.getElementById('staff_description_mel').innerHTML='';
					fromVal=0;
					document.getElementById('fromVal_mel').value=0;
					glob_tab_id_mel=null;
					//alert("in if"+document.getElementById('fromVal_mel').value);
					//document.getElementById('prev_nxt_mel').innerHTML='';
					getStaff_mel(1,null);
					if(document.getElementById('prev_nxt_mel') && document.getElementById('prev_nxt_temp_mel'))
					{
					document.getElementById('prev_nxt_mel').innerHTML = document.getElementById('prev_nxt_temp_mel').innerHTML;
					}
					/*melbourn office section end*/
					/*Adelaide office section start*/
					if(document.getElementById(holdId))
					{
						//alert(document.getElementById(holdId).innerHTML);
						document.getElementById(holdId).style.display = 'none';
						document.getElementById(holdImgId).style.border='0px';
						document.getElementById(holdTdId).style.background='none';
						//alert(document.getElementById(holdId).innerHTML);
						holdId='';					
					}
					document.getElementById('staff_description').innerHTML='';
					fromVal=0;
					document.getElementById('fromVal').value=0;
					//alert(document.getElementById('fromVal').value);
					glob_tab_id=null;
					
					//getStaff(1,null);
					
					//alert(document.getElementById('prev_nxt').innerHTML);
					if(document.getElementById('prev_nxt') && document.getElementById('prev_nxt_temp'))
					{
					document.getElementById('prev_nxt').innerHTML = document.getElementById('prev_nxt_temp').innerHTML;
					}
					
					/*Adelaide office section ends*/
				}
				else
				{
					
					var obj = document.getElementById('about_us_div');	
					document.getElementById('staff_div').style.display='none';
					obj.innerHTML=msg_test;
										
					/*melbourn office section start*/
					document.getElementById('country_mel').innerHTML="";
					if(document.getElementById(holdId_mel))
					{
						holdId_mel='';
					}
					document.getElementById('staff_description_mel').innerHTML='';
					document.getElementById('fromVal_mel').value=0;
					glob_tab_id_mel=null;
					fromVal_mel=0;
					//alert("in else");
					getStaff_mel(1,null);
					/*melbourn office section end*/
					/*Adelaide office section start*/
					document.getElementById('country').innerHTML="";
					if(document.getElementById(holdId))
					{
						holdId='';
					}
					document.getElementById('staff_description').innerHTML='';
					document.getElementById('fromVal').value=0;
					glob_tab_id=null;
					fromVal=0;
					getStaff(1,null);
				}

           } 

      }

}

/*about us ajax ends*/
/*select country combo for information request starts*/
var globTypeId='';
function selectCountryRegionCombo(comboVal,typeid)
{

	globTypeId=typeid;
	req=AjaxObjectCreate();
    if(req) 

	{

		req.onreadystatechange = processCountryRegionCombo;	   

		req.open("GET","select-information-request-combo.php?countries_id="+comboVal.value+"&selectType="+typeid,true);

		req.send(null);

    } 

}



function processCountryRegionCombo() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {

				var msg_test=trim(req.responseText);
				if(globTypeId == 1)
				{

					var obj = document.getElementById('regionDiv');	
					obj.innerHTML=msg_test;

				}

				if(globTypeId == 2)
				{
					var obj = document.getElementById('countryDiv');	
					obj.innerHTML=msg_test;
				}
				
           } 

      }

}

/*select country combo for information request ends*/

/*Referral Combo Starts*/
//set Referral Combo
function setReferalDetailCombo(obj)
{
var refDetlId=obj.value;
	if(refDetlId!='')
	{	
		req=AjaxObjectCreate();
		if(req) 
	
		{
	
			req.onreadystatechange = processSetReferalDetailCombo;	   
	
			req.open("GET","referal_detail_combo.php?refDetlId="+refDetlId,true);
	
			req.send(null);
	
		} 
	}
	else
	{
		var obj1 = document.getElementById('referal-detail-div');	
					obj1.innerHTML='';
	}

}



function processSetReferalDetailCombo() 

{

       if(req.readyState == 4) 

	   {

           if(req.status == 200) 

		   {

				var msg_test=trim(req.responseText);

					var obj = document.getElementById('referal-detail-div');
					obj.innerHTML = "";
					obj.innerHTML=msg_test;

           } 

      }

}

/*Referral Combo ends*/