
function translate_language(key_name){
	if (language_script_array[key_name]==null || language_script_array[key_name]==''){
		return key_name.replace(/_/g,' ');
	}else{
		return language_script_array[key_name];
	}
}


function closePopUp() {


	featureImageUploadOBJ = document.getElementById('featureImageUpload');
	//alert("eliot"+featureImageUploadOBJ.value);
	//if(featureImageUploadOBJ.value==""){
	//alert("No picture is selected!");
	//return false;
	//}

	document.uploadPicture.submit();
	document.body.style.overflow= "";
	document.getElementById('divDialogBodyMask').style.display = 'none';
	document.getElementById('LoginDialogBox').style.display = 'none';
	//document.body.style.overflow= "";
}

function saveRegionDetails() {

//	alert(document.getElementById('history').value);
//if(document.getElementById('history').value==""){
	
	//alert(translate_language("History_is_empty"));
	//return false;
//}

document.region_details.submit();

}



function DeleteFromFeatureListOnclickHandler()
{
	//alert("eliot");
	featureListFinalOBJ = document.getElementById('featureListFinal');
	//var length=featureListOBJ.options.lenght;
	for(var i=0;i<featureListFinalOBJ.options.length;i++)
	{
		if(featureListFinalOBJ.options[i].selected==true)
		featureListFinalOBJ.remove(i);


	}
}
function featureListOnchangeHandler()
{

	featureListOBJ = document.getElementById('featureList');
	feature=featureListOBJ.value;
	feature=feature.replace(/ /g, '+');
//	alert(pid);
	var url="ajax_features.php?mode=addPro&pid="+pid+"&feature="+feature;

	//alert(url);
	ajax_action_users(url,'addProductFeaturesPanel');
	document.getElementById('featureList').value="";


}

function addExtraFeatureProductHandler()
{



	var url="ajax_features.php?mode=extraPro&pid="+pid;

	//alert(url);
	ajax_action_users(url,'addProductFeaturesPanel','N');



}


function cFeatureListOnChangeHandler()
{

	cFeatureListOBJ = document.getElementById('cFeatureList');
	cid= document.addCategory.cid.value;
	feature=cFeatureListOBJ.value;
	feature=feature.replace(/ /g, '+');
	var url="ajax_features.php?mode=add&cid="+cid+"&feature="+feature;

//	alert(url);
	ajax_action_users(url,'addFeaturesPanel');

	//Set the selected value to blank
	document.getElementById('cFeatureList').value="";


	//window.frames[0].document.iform.selectedFeature.value=cFeatureListOBJ.value;

}

function addExtraFeatureHandler()
{



	var url="ajax_features.php?mode=extra&cid="+cid;

	ajax_action_users(url,'addFeaturesPanel');



}






function addOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;

	//featureImageUploadOBJ = document.getElementById('featureImageUpload');
	//featureImageUploadOBJ.value="";
	selectbox.options.add(optn);
}

function producttypeOnchangeHandler()
{
	//alert("eliot2");
	producttypeOBJ = document.getElementById('productType');
	starRatingOBJ = document.getElementById('starRating');

	//alert("eliot"+producttypeOBJ.value);
	if(producttypeOBJ.value=="accom") {
		starRatingOBJ.style.display='';
	}
	else
	{
		starRatingOBJ.style.display='none';
		var i;
		starAccomOBJ = document.getElementById('starAccom');
		//alert("eliot"+starAccomOBJ.options.length);
		starAccomOBJ.options[0].selected=true;
		//alert("eliot"+starAccomOBJ.options[0].selected);
	}

}

//var commissionRate=0.15

function fromdateValidate()
{
	var d=new Date()
	// alert("eliot");
	//alert("Eliot"+d.Date());

}

function getResultingPrice(){
	var commissionRate=document.addRulesPeriod.comm_rate.value;
	commissionRate=parseFloat(commissionRate);

	salePriceOBJ = document.getElementById('salePrice');
	if(IsNumeric(salePriceOBJ.value)==false){
		alert(translate_language("Display_price_has_to_be_a_number"));
		//StartDateOBJ.focus();
		//
		//salePriceOBJ.value="";
		//salePriceOBJ.focus();
	}
	else{

		//alert(commissionRate);

		resultingPriceOBJ = document.getElementById('resultingPrice');
		resultingPriceOBJ.value=Math.round(salePriceOBJ.value/(1+commissionRate)*100)/100;

	}
}


function getSalePrice(){

	var commissionRate=document.addRulesPeriod.comm_rate.value;
	commissionRate=parseFloat(commissionRate);

	//alert(document.addRulesPeriod.pid.value);
	resultingPriceOBJ = document.getElementById('resultingPrice');
	if(IsNumeric(resultingPriceOBJ.value)==false){
		alert(translate_language("Agent_profit_has_to_be_a_number"));
		//StartDateOBJ.focus();
		//resultingPriceOBJ.focus();
		//salePriceDIVOBJ.value="";
	}
	else{
		salePriceOBJ = document.getElementById('salePrice');

		//alert(commissionRate);
		//alert(commissionRate);
		//alert(11+commissionRate);
		salePriceOBJ.value=Math.round(resultingPriceOBJ.value*(1+commissionRate)*100)/100;
	}
}

function getPriceForExtra(_extraInputId){
	var commissionRate=document.addRulesPeriod.comm_rate.value;
	commissionRate=parseFloat(commissionRate);
	_extraId = _extraInputId.match(/\d+\.?\d*/g)[0];
	if (_extraInputId == 'priceExtraOption'+_extraId){
		_sourceId = 'priceExtraOption'+_extraId;
		_resultId = 'agentExtraOption'+_extraId;
		_comCal = 1/(1+commissionRate);
	}else{
		_sourceId = 'agentExtraOption'+_extraId;
		_resultId = 'priceExtraOption'+_extraId;
		_comCal = 1+commissionRate;
	}
	//_extraId = parseInt(_extraId);
	sourcePriceOBJ = document.getElementById(_sourceId);
	if(IsNumeric(sourcePriceOBJ.value)==false){
		alert(translate_language("Display_price_has_to_be_a_number"));
		//StartDateOBJ.focus();
		//salePriceOBJ.value="";
		//salePriceOBJ.focus();
	}else{
		//alert(commissionRate);
		resultingPriceOBJ = document.getElementById(_resultId);
		resultingPriceOBJ.value=Math.round(sourcePriceOBJ.value*_comCal*100)/100;
	}
}

function DIV_getResultingPrice(){
	var commissionRate=document.addRulesPeriod.comm_rate.value;
	commissionRate=parseFloat(commissionRate);
	salePriceOBJ = document.getElementById('DIV_salePrice');
	if(IsNumeric(salePriceOBJ.value)==false){
		alert(translate_language("Display_price_has_to_be_a_number"));
		//StartDateOBJ.focus();
		salePriceOBJ.focus();
		//salePriceOBJ.value="";
	}
	else{
		resultingPriceOBJ = document.getElementById('DIV_resultingPrice');
		resultingPriceOBJ.value=Math.round(salePriceOBJ.value/(1+commissionRate)*100)/100;

	}
}


function getSalePriceDIV(){

	var commissionRate=document.addRulesPeriod.comm_rate.value;
	commissionRate=parseFloat(commissionRate);

	ResultingPriceDIVOBJ = document.getElementById('aprofit');
	if(IsNumeric(ResultingPriceDIVOBJ.value)==false){
		alert(translate_language("Agent_profit_has_to_be_a_number"));
		//StartDateOBJ.focus();
		ResultingPriceDIVOBJ.focus();
		//salePriceDIVOBJ.value="";
	}
	else{


		salePriceDIVOBJ = document.getElementById('dprice');
		salePriceDIVOBJ.value=Math.round(ResultingPriceDIVOBJ.value*(1+commissionRate)*100)/100;
	}

}


function getResultingPriceDIV(str){

	var commissionRate=document.addRulesPeriod.comm_rate.value;
	commissionRate=parseFloat(commissionRate);
	var OriginalPriceDIVOBJ = document.getElementById('dpriceDIV');
	// alert("ResultingPriceDIVOBJ"+OriginalPriceDIVOBJ.value);
	salePriceDIVOBJ = str;
	///alert("eliot1"+str);
	if(IsNumeric(OriginalPriceDIVOBJ.value)==false){
		//alert("Display price has to be a number");
		//StartDateOBJ.focus();
		//salePriceDIVOBJ.focus();
		//salePriceDIVOBJ.value="";
	}

	else{
		//alert(123);
		ResultingPriceDIVOBJ = document.getElementById('aprofitDIV');
		//alert("eliot1"+ResultingPriceDIVOBJ.value);
		ResultingPriceDIVOBJ.value=Math.round(OriginalPriceDIVOBJ.value/(1+commissionRate)*100)/100;

	}
}



function IsNumeric(sText)

{
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;


	for (i = 0; i < sText.length && IsNumber == true; i++)
	{
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1)
		{
			IsNumber = false;
		}
	}
	return IsNumber;

}

function setPrice(){

	//alert("priceid"+document.getElementById('priceID').value);
	salePrice2OBJ = document.getElementById(document.getElementById('priceID').value);

	//alert(document.getElementById('priceID').value);
	salePriceDivOBJ = document.getElementById('dpriceDIV');
	salePrice2OBJ.value=salePriceDivOBJ.value;
	xpFloatStop();
	//document.getElementById('divDialogBodyMask').style.display = 'none';
	//document.getElementById('JoinDialogBox').style.display = 'none';
	//document.body.style.overflow= '';
	// pageScroll();


}

function resetPrice(){
	salePrice2OBJ = document.getElementById('salePrice2');
	salePriceDivOBJ = document.getElementById('salePriceDiv');
	salePriceDivOBJ.value=salePrice2OBJ.value;

}


// Get base url
url = document.location.href;
xend = url.lastIndexOf("/") + 1;
var base_url = url.substring(0, xend);

function ajax_do (url) {
	// Does URL begin with http?
	//alert("yeah"+url);
	if (url.substring(0, 4) != 'http') {
		url = base_url + url;
	}

	// Create new JS element
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;
	//alert("yeah"+url);
	// Append JS element (therefore executing the 'AJAX' call)
	document.body.appendChild (jsel);
}




//////////////////////////////////


function deleteFromFeatureList(str)
{

	var url="picture.php"
	url=url+"?featureid="+str+"&mode=del";
	ajax_do(url);

}


function deleteFromRegionPictureList(id)
{

	var url="picture_admin.php"
	url=url+"?id="+id+"&mode=del";
	
	region_id=document.getElementById('region_id').value;
	url=url+"&region_id="+region_id
	//alert(url);
	ajax_do(url);

}

//url="picture_admin.php?mode=region_details&region_id="+id;

	//ajax_do(url);

function deleteFromCategoryFeatureList(str)
{

	var url="picture_category.php";
	url=url+"?featureid="+str+"&mode=del";
	ajax_do(url);
	pageScroll();

}

function deleteFromProductFeatureList(str)
{

	var url="picture_product.php";
	url=url+"?featureid="+str+"&mode=del";
	ajax_do(url);
	pageScroll();

}



function deleteFromSessionList(str)
{

	var url="agent_add_session.php";
	url=url+"?sid="+str+"&mode=del";
	ajax_do(url);
	//pageScroll();

}

function deleteEcoRule(rid,pid)
{

	 url="ajax_agent.php?mode=eco_rule_del&rid="+rid+"&pid="+pid;
		
	ajax_action_front(url,'existing_eco_rules')
	
	//alert(url);
	//pageScroll();

}


var selectedEcoRule;

function editEcoRule(rid,pid)
{

	document.getElementById('EditEcoRules').style.display = 'inline';
	document.getElementById('AddEcoRules').style.display = 'none';
	
	
	document.getElementById('num_available_eco_Edit').value = '';
	
	TDID="TD"+rid;
	changeto(TDID,'#FFCCCC');
	
	selectedEcoRule=rid;
	


}

function deleteFromVideoList(str)
{

	if(document.addCategory){
		cid =document.addCategory.cid.value;
		var url="video.php"
		url=url+"?videoid="+str+"&mode=del"+"&cid="+cid;
	}
	else if(document.addProduct){
		pid =document.addProduct.pid.value;
		var url="video.php"
		url=url+"?videoid="+str+"&mode=del"+"&pid="+pid;
	}

	ajax_do(url);

}

function deleteFromVideoListRegionDetails(str)
{

	region_id =document.getElementById('region_id').value;
	var url="video_admin.php"
	url=url+"?videoid="+str+"&mode=del"+"&region_id="+region_id;
	ajax_do(url);

}
//////////////////////////////////////////////////////
function ini () {
	//Load the featurelist
	ajax_do('picture.php');
}


function ini_add_category(countryID,regionID,townID) {

	//cidOBJ = document.ifrom;
	//cid=window.frames[0].document.iform.cid.value;
	cid=document.addCategory.cid.value;
	

	url='picture_category.php?cid='+cid;
	url_video='video.php?cid='+cid;
	//Load the featurelist and videolist
	ajax_do(url);
	ajax_do(url_video);
    var url="ajax_region_town.php?mode=show&countryID="+countryID+"&regionID="+regionID+"&townID="+townID;
  // alert(url);

	ajax_action_front(url,'region_town_updator_category');


}

function ini_region_details(id) {


	url="picture_admin.php?mode=region_details&region_id="+id;

	ajax_do(url);
	
     url_video='video_admin.php?region_id='+id;
     	ajax_do(url_video);

}



function ini_add_product(address,countryID,regionID,townID,use_biz_add,use_biz_phone) {


	  if(document.addProduct.ecoProduct.value=='Y'){
  	
  	   document.addProduct.isEcoProduct.checked='true';
  	
     }
	
	
	//// Keep the selection after the submittion
	if(use_biz_add=="Y"){
		
		document.addProduct.use_biz_add.checked='true';
		var url="ajax_region_town.php?mode=show&countryID=&regionID=&townID=";
	    ajax_action_front(url,'region_town_updator_category');
	}
	
	//Only load the address when use_biz_add is not selected
	else{
		     ///load the address
	        document.addProduct.address.value=address;
			///// LOAD region and town list
			var url="ajax_region_town.php?mode=show&countryID="+countryID+"&regionID="+regionID+"&townID="+townID;
			//alert(url);
			ajax_action_front(url,'region_town_updator_category');
	}
	if(use_biz_phone=="Y"){
		
		document.addProduct.use_biz_phone.checked='true';
	}
	
	
	
	//pid=window.frames[0].document.iform.pid.value;
	pid=document.addProduct.pid.value;
	//alert("ini"+pid);
	url='picture_product.php?pid='+pid;
	ajax_do(url);
	
	
	
	// Handle the preload of star rating
	
	
	myDropdownList = document.addProduct.startRating;
	if(myDropdownList){
		stars= document.addProduct.stars;
	
	
		// Loop through all the items
		for (iLoop = 0; iLoop< myDropdownList.options.length; iLoop++)
		{
			if (myDropdownList.options[iLoop].value == stars.value)
			{
				// Item is found. Set its selected property, and exit the loop
				myDropdownList.options[iLoop].selected = true;
				break;
			}
		}
		
	
	}
	
	//room type
	myDropdownList = document.addProduct.roomType;
	if(myDropdownList){
		room_type= document.addProduct.room_type;
	
	
		// Loop through all the items
		for (iLoop = 0; iLoop< myDropdownList.options.length; iLoop++)
		{
			if (myDropdownList.options[iLoop].value == room_type.value)
			{
				// Item is found. Set its selected property, and exit the loop
				myDropdownList.options[iLoop].selected = true;
				break;
			}
		}
		
	
	}
	
	// Get a reference to the drop-down
	myDropdownList1 = document.addProduct.ecoRating;
	if(myDropdownList1){
		
		ecoRating= document.addProduct.eco;
	
	
		// Loop through all the items
		for (iLoop = 0; iLoop< myDropdownList1.options.length; iLoop++)
		{
			if (myDropdownList1.options[iLoop].value == ecoRating.value)
			{
				// Item is found. Set its selected property, and exit the loop
				myDropdownList1.options[iLoop].selected = true;
				break;
			}
		}
	
	}
	
	// Get a reference to the drop-down
	myDropdownList2 = document.addProduct.categoryList;
	if(myDropdownList2){
		

		category= document.addProduct.category;
	    	
	
		// Loop through all the items
		for (iLoop = 0; iLoop< myDropdownList2.options.length; iLoop++)
		{
			//alert(myDropdownList2.options[iLoop].value );
			if (myDropdownList2.options[iLoop].value == category.value)
			{
					
				// Item is found. Set its selected property, and exit the loop
				myDropdownList2.options[iLoop].selected = true;
				break;
			}
		}
	
	}
	
	useBizPhoneHandler();
	
	//give some time interval for ajax to return response XML
	setTimeout('useBizAddHandler();',300); 

}

function ini_edit_product(address,countryID,regionID,townID,use_biz_add,use_biz_phone) {

   
	pid=document.addProduct.pid.value;
	
	url_video='video.php?pid='+pid;
	
	ajax_do(url_video);
	
	
  if(document.addProduct.ecoProduct.value=='Y'){
  	
  	document.addProduct.isEcoProduct.checked='true';
  	
  }
	
	//// Keep the selection after the submittion
	if(use_biz_add=="Y"){
		
		document.addProduct.use_biz_add.checked='true';
		var url='ajax_region_town.php?mode=show&countryID='+countryID+'&regionID'+regionID+'=&townID='+townID;
	    //alert(url);
	    ajax_action_front(url,'region_town_updator_category');
	}
	//Only load the address when use_biz_add is not selected
	else{
		
		   
			///load the address
	        document.addProduct.address.value=address;
			///// LOAD region and town list
			var url="ajax_region_town.php?mode=show&countryID="+countryID+"&regionID="+regionID+"&townID="+townID;
			//alert(url);
			ajax_action_front(url,'region_town_updator_category');
			
	}
	if(use_biz_phone=="Y"){
		
		document.addProduct.use_biz_phone.checked='true';
	}
	

	
	pid =document.addProduct.pid.value;
	ptype= document.addProduct.ptype.value;

	if(ptype!="AM"){
		//alert(ptype);
		document.getElementById('addProduct_4').style.display = 'none';
	}

	url='picture_product.php?pid='+pid;
	ajax_do(url);

	// Get a reference to the drop-down
	myDropdownList = document.addProduct.startRating;
	if(myDropdownList){
		
		stars= document.addProduct.stars;
	
	
		// Loop through all the items
		for (iLoop = 0; iLoop< myDropdownList.options.length; iLoop++)
		{
			if (myDropdownList.options[iLoop].value == stars.value)
			{
				// Item is found. Set its selected property, and exit the loop
				myDropdownList.options[iLoop].selected = true;
				break;
			}
		}
	
	}
	
	// Get a reference to the drop-down
	myDropdownList = document.addProduct.roomType;
	if(myDropdownList){
		
		room_type= document.addProduct.room_type;
//	 	/alert(room_type.value);
	
		// Loop through all the items
		for (iLoop = 0; iLoop< myDropdownList.options.length; iLoop++)
		{
			if (myDropdownList.options[iLoop].value == room_type.value)
			{
				// Item is found. Set its selected property, and exit the loop
				myDropdownList.options[iLoop].selected = true;
				break;
			}
		}
	
	}
	
	// Get a reference to the drop-down
	myDropdownList1 = document.addProduct.ecoRating;
	if(myDropdownList1 && myDropdownList1.tagName.toString().toLowerCase()=='select'){
		
		ecoRating= document.addProduct.eco;
	
	
		// Loop through all the items
		for (iLoop = 0; iLoop< myDropdownList1.options.length; iLoop++)
		{
			if (myDropdownList1.options[iLoop].value == ecoRating.value)
			{
				// Item is found. Set its selected property, and exit the loop
				myDropdownList1.options[iLoop].selected = true;
				break;
			}
		}
	
	}
	
		// Get a reference to the drop-down
	myDropdownList2 = document.addProduct.categoryList;
	if(myDropdownList2){
		

		category= document.addProduct.category;
	    	
	
		// Loop through all the items
		for (iLoop = 0; iLoop< myDropdownList2.options.length; iLoop++)
		{
			//alert(myDropdownList2.options[iLoop].value );
			if (myDropdownList2.options[iLoop].value == category.value)
			{
					
				// Item is found. Set its selected property, and exit the loop
				myDropdownList2.options[iLoop].selected = true;
				break;
			}
		}
	
	}
	
	useBizPhoneHandler();
	
	//give some time interval for ajax to return response XML
	setTimeout('useBizAddHandler();',300); 

}



function editProductSubmit() {


 if(!document.addProduct.use_biz_phone.checked){
		
 	    // alert(123);
 	    phone_country=document.getElementById('phone_country').value;
		phone_area=document.getElementById('phone_area').value;
		phone_number=document.getElementById('phone_number').value;
		mobile_country=document.getElementById('mobile_country').value;
		mobile_number=document.getElementById('mobile_number').value;
		
		if(phone_country==""&&phone_area==""&&phone_number==""&&mobile_country==""&&mobile_number==""){
			
		
				alert(translate_language("Please_enter_at_least_one_phone_number"));
				return false;
		
		}

 }

 numSelectedCheckbox=0;
 for(i=0; i<document.addProduct.elements.length; i++)
	{
		if(document.addProduct.elements[i].type=="checkbox"&&document.addProduct.elements[i].checked==true&&document.addProduct.elements[i].name=='product_visibility[]')
		{

			numSelectedCheckbox++;
		}
	}
if(numSelectedCheckbox==0){
	
	alert(translate_language('product_visibility'));
	return false;
}
 
 if(document.getElementById('categoryList')){
 	

 	if(document.getElementById('categoryList').value==''){
 		
 		alert(translate_language("You_need_to_select_a_category"));
 		document.getElementById('categoryList').focus();
		return false;
 	}
 	
 }
 
 
 if(!document.addProduct.use_biz_add.checked){
 
	if(document.addProduct.address.value=="")
	{

		alert(translate_language("Address_is_empty"));
		return false;
	}
 	
 	
 	if(document.getElementById('country').value=="")
	{

		alert(translate_language("Country_is_empty"));
		return false;
	}
	
	if(document.getElementById('region').value=="")
	{

		alert(translate_language("Region_is_empty"));
		return false;
	}

	if(document.getElementById('town').value=="")
	{

		alert(translate_language("Town_is_empty"));
		return false;

	}
	
 }
	
 /* Set Cost per Extra Person to 0 if people_include==max_people*/
 if(document.getElementById('people_include')){
	people_include=document.getElementById('people_include').value;
	max_people=document.getElementById('max_people').value;
   
	if(people_include==max_people){
		
		document.getElementById('cost_extra_person').value=0;
	}
 }
 
	document.addProduct.submit(); 

}



function ini_edit_category(countryID,regionID,townID) {

	//cidOBJ = document.ifrom;
	cid=document.addCategory.cid.value;
	//alert(cidOBJ.value);
	// alert("eliot"+path);
	url='picture_category.php?cid='+cid;
	//alert(url);
	url_video='video.php?cid='+cid;
	//Load the featurelist and videolist
	ajax_do(url);
	ajax_do(url_video);


	//////LOAD region and town list
	var url="ajax_region_town.php?mode=show&countryID="+countryID+"&regionID="+regionID+"&townID="+townID;
	//alert(url);
	//document.getElementById('region_town_updator_category').innerHTML='test';
	ajax_action_front(url,'region_town_updator_category');
}

function useBizAddHandler(){
	//alert(456);
	
	//alert(document.getElementById('use_biz_add').checked);
	if(document.getElementById('use_biz_add').checked){
		
		/*document.addProduct.value="";
		document.addProduct.value="";
		document.addProduct.value="";
		document.addProduct.value="";
		document.addProduct.value="";*/
		document.addProduct.subtown.disabled=true;
		document.addProduct.postcode.disabled=true;
		document.addProduct.address.disabled=true;
		document.addProduct.address_2.disabled=true;
		document.addProduct.country.disabled=true;
		document.addProduct.region.disabled=true;
		document.addProduct.town.disabled=true;
		document.addProduct.latitude.disabled=true;
		document.addProduct.longitude.disabled=true;
		document.addProduct.zoom_level.disabled=true;
	}
	else{
		
		document.addProduct.subtown.disabled=false;
		document.addProduct.address.disabled=false;
		document.addProduct.address_2.disabled=false;
		document.addProduct.country.disabled=false;
		document.addProduct.region.disabled=false;
		document.addProduct.town.disabled=false;
		document.addProduct.postcode.disabled=false;
		document.addProduct.latitude.disabled=false;
		document.addProduct.longitude.disabled=false;
		document.addProduct.zoom_level.disabled=false;
	}
}


	function useBizPhoneHandler(){
	//alert(456);
	
	//alert(document.getElementById('use_biz_add').checked);
	if(document.getElementById('use_biz_phone').checked){
		
		/*document.addProduct.value="";
		document.addProduct.value="";
		document.addProduct.value="";
		document.addProduct.value="";
		document.addProduct.value="";*/
		document.addProduct.phone_country.disabled=true;
		document.addProduct.phone_area.disabled=true;
		document.addProduct.phone_number.disabled=true;
		document.addProduct.mobile_country.disabled=true;
		document.addProduct.mobile_number.disabled=true;
	}
	else{
		
		document.addProduct.phone_country.disabled=false;
		document.addProduct.phone_area.disabled=false;
		document.addProduct.phone_number.disabled=false;
		document.addProduct.mobile_country.disabled=false;
		document.addProduct.mobile_number.disabled=false;
	}
}

function addCategorySubmit(){



phone_country=document.getElementById('phone_country').value;
phone_area=document.getElementById('phone_area').value;
phone_number=document.getElementById('phone_number').value;
mobile_country=document.getElementById('mobile_country').value;
mobile_number=document.getElementById('mobile_number').value;

if(phone_country==""&&phone_area==""&&phone_number==""&&mobile_country==""&&mobile_number==""){
	

		alert(translate_language("Please_enter_at_least_one_phone_number"));
		return false;

}


	if(document.getElementById('country').value=="")
	{

		alert(translate_language("Country_is_empty"));
		return false;
	}
	
	if(document.getElementById('region').value=="")
	{

		alert(translate_language("Region_is_empty"));
		return false;
	}

	if(document.getElementById('town').value=="")
	{

		alert(translate_language("Town_is_empty"));
		return false;

	}
	document.addCategory.submit();
}

function country_onChange_category(country) {


	var url="ajax_region_town.php?mode=country&id="+country;
	//document.getElementById('region_town_updator_category').innerHTML='test';
	ajax_action_front(url,'region_town_updator_category');

}

var userEntryPoint='';  //flag for region or product category is selected first


function region_onChange_category(region) {
   
	
	var url="ajax_region_town.php?mode=region&id="+region;
	//alert(url);
	//document.getElementById('region_town_updator_category').innerHTML='test';
	ajax_action_front(url,'region_town_updator_category');

}

function town_onChange_category(subregion) {

    var url="ajax_region_town.php?mode=subregion&id="+subregion;
	//alert(url);
	//document.getElementById('region_town_updator_category').innerHTML='test';
	ajax_action_front(url,'region_town_updator_category');
}



function showSlide () {
	//Load the featurelist
	//alert("show");
	window.open ("slideshow.php","mywindow","location=1,menubar=no,toolbar=no,status=1,scrollbars=1,width=400,height=400");
	//ajax_do('slideshowtest.php');
}


function videoLinkOnblurHandler (mode) {


	
	if(mode=='cid'||mode=='business'){
		cid =document.addCategory.cid.value;
		url = document.addCategory.videoLink.value;
	}
	else{
		pid =document.addProduct.pid.value;
		url = document.addProduct.videoLink.value;
	}
	//document.write("<?echo $temp_cid?>");
	url=removeSpaces(url);


	splitstring = url.split("=");

	url=splitstring[1];
	////validation valid youtube URL//////////////////////////////////////////////////////////////////////////////
	url1=splitstring[0];
	url=removeSpaces(url);
	//alert(url1);
	splitstring1 = url1.split("?");
	validURL=splitstring1[0];
//	alert(validURL);
	if(validURL!="http://youtube.com/watch"&&validURL!="http://www.youtube.com/watch"){
		//alert(123);
		alert(translate_language("It_is_not_a_valid_youtube_URL"));
		return false;
	}
	/////////////////////////////////////////////////////////////////////////////////////
	
	
	if(mode=='cid'||mode=='business'){
		finalURL="video.php?mode=add&url="+url+"&cid="+cid;
	}
	else{
		finalURL="video.php?mode=add&url="+url+"&pid="+pid;
	}
	//alert("video"+finalURL);
	
	
	//alert("cid"+cid);
	ajax_do(finalURL);

}

function videoLinkOnClickHandler () {

//		alert(456);

	url = document.getElementById('videoLink').value;
	region_id =document.getElementById('region_id').value;

	url=removeSpaces(url);


	splitstring = url.split("=");

	url=splitstring[1];
	////validation valid youtube URL//////////////////////////////////////////////////////////////////////////////
	url1=splitstring[0];
	url=removeSpaces(url);
	//alert(url1);
	splitstring1 = url1.split("?");
	validURL=splitstring1[0];
//	alert(validURL);
	if(validURL!="http://youtube.com/watch"&&validURL!="http://www.youtube.com/watch"){
		//alert(123);
		alert(translate_language("It_is_not_a_valid_youtube_URL"));
		return false;
	}
	/////////////////////////////////////////////////////////////////////////////////////
	finalURL="video_admin.php?mode=add_region&url="+url+"&region_id="+region_id;
//	alert("video"+finalURL);
	//alert("cid"+cid);
	ajax_do(finalURL);

}

///Any spaces entered by the user will be removed

function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}

//var daysInAWeek=new Array("all","sun","mon","tue","wen" ,"thu","fri" ,"sat");

function allOnclickHandler(){
	//alert("eliot1");
	if(document.addRulesPeriod.all.checked==true){
		for(i=0; i<document.addRulesPeriod.elements.length; i++)
		{
			if(document.addRulesPeriod.elements[i].type=="checkbox"&&document.addRulesPeriod.elements[i].name!='all')
			{

				document.addRulesPeriod.elements[i].checked=false;
			}
		}


	}


}

function othersOnclickHandler(){

	document.addRulesPeriod.all.checked=false;

}

function addRulesPeriodsubmit(){


	var numberChecked=0; //the number of date checked
	var start=document.addRulesPeriod.StartDate.value;
	var end=document.addRulesPeriod.EndDate.value;
	


///////////////////////// Validation Start//////////////////////////////////////////

	if(document.addRulesPeriod.StartDate.value==""){
		alert(translate_language("From_is_empty"));
		return false;
	}
	if(document.addRulesPeriod.EndDate.value==""){
		alert(translate_language("To_is_empty"));
		return false;
	}

	if(!validate(start,end))
	return false;

	for(i=0; i<document.addRulesPeriod.elements.length; i++)
	{
		if(document.addRulesPeriod.elements[i].type=="checkbox"&&document.addRulesPeriod.elements[i].checked==true)
		{

			numberChecked++;
		}
	}

	if(numberChecked==0){
		alert(translate_language("Effective_day_is_empty"));
		return false;
	}

	 //alert(1);
	if(document.addRulesPeriod.ptype.value=="AT"||document.addRulesPeriod.ptype.value=="EV"){

		num_sessionOBJ=document.getElementById('num_session');
		if(num_sessionOBJ){
			// alert(2);
			if(num_sessionOBJ.value==0){
				alert(translate_language("No_session_is_added"));
				return false;
			}
		}
		else{
			alert(translate_language("No_session_is_added"));
			return false;
		}


	}

	else{

		if(document.addRulesPeriod.num_available.value==""){
			alert(translate_language("Quantity_available_is_empty"));
			return false;
		}
		if(document.addRulesPeriod.DisplayPrice.value==""||document.addRulesPeriod.DisplayPrice.value==0){
			alert(translate_language("Price_is_empty"));
			return false;
		}

	}

///////////////////////// Validation End//////////////////////////////////////////

	document.addRulesPeriod.save.value="save";
	document.addRulesPeriod.submit();

}




function validate(date1,date2){

	tmp = date1.split("-")
	//xDate = tmp[0]+"-"+tmp[1]+"-"+tmp[2];
	//alert(xDate);
	//refDate = calcJulian(xDate);

	tmp1 = date2.split("-")
	//xDate = tmp[0]+"-"+tmp[1]+"-"+tmp[2];
	//alert(xDate);
	//fwdDate = calcJulian(xDate);

	//Compare tew dates
	var start = new Date(tmp[2],tmp[1],tmp[0]);
	var end = new Date(tmp1[2],tmp1[1],tmp1[0]);

	start.setDate (start.getDate() + 6);
	if (start >= end)
	//if (new Date(tmp[2],tmp[1],tmp[0]) >= new Date(tmp1[2],tmp1[1],tmp1[0]) )
	{
		alert(translate_language('End_Date_Must_be_more_than_six_days_later_than_Start_Date'));
		return false;
		//document.forms.Form1.nDate2.value = "";
		//document.forms.Form1.nDate2.focus();
	}
	else
	return true;
}


function showAddIndividualPricePanel(startDate,selectedDate) {

	//alert(startDate);

	var pid=document.addRulesPeriod.pid.value;
	var ptype=document.addRulesPeriod.ptype.value;
	//alert("eliot");

	if(startDate)
	var url="agent_add_single_price.php?pid="+pid+"&ptype="+ptype+"&startDate="+startDate;
	else
	var url="agent_add_single_price.php?pid="+pid+"&ptype="+ptype;


	//alert(url);
	document.getElementById('FinishaddSinglePrice').style.display = 'inline';
	document.getElementById('addSinglePrice').style.display = 'none';
	document.getElementById('AddIndividualPricePanel').style.display = 'inline';
	//alert(url);
	ajax_do(url);
	if(startDate){
		//date=document.getElementById('date').value;
		tdID='td'+selectedDate;
		changeto(tdID,'#FFCCCC');
	}
	pageScroll();
	//pageScroll();
	//

}

function showAddOptionalExtrasPricePanel() {



	var pid=document.addRulesPeriod.pid.value;
	//var ptype=document.addRulesPeriod.ptype.value;
	
	document.getElementById('addOptionalExtrasPriceHide').style.display = 'inline';
	document.getElementById('addOptionalExtrasPrice').style.display = 'none';
	document.getElementById('addOptionalExtrasPricePanel').style.display = 'inline';
	
    var url="ajax_agent.php?mode=show_extra_options&pid="+pid;
	
    ajax_action_users(url,'addOptionalExtrasPricePanel');
	//ajax_do(url);


}

function hideAddIndividualPricePanel() {

	document.getElementById('FinishaddSinglePrice').style.display = 'none';
	document.getElementById('addSinglePrice').style.display = 'inline';
	document.getElementById('AddIndividualPricePanel').style.display = 'none';
	//stopScroll();
	//alert("eliot2");
	//

}

function hideAddOptionalExtrasPrice() {

	document.getElementById('addOptionalExtrasPriceHide').style.display = 'none';
	document.getElementById('addOptionalExtrasPrice').style.display = 'inline';
	document.getElementById('addOptionalExtrasPricePanel').style.display = 'none';
	//stopScroll();

}


/*
return the value of radio button list 
parameter: radio button object

*/
function getCheckedValue(radioObj) {
	
//	alert(radioObj.length+'eliot');
	for (var i=0; i <radioObj.length;i++)
	{
		if(radioObj[i].checked){
			return radioObj[i].value;
//             alert(123);
		}
	}

}

/*
 This function is to make ajax call to save prices for extra options 
*/

function saveExtraOptionsPrice(pid,fidList){
	
	var featureIdString='';
	var featurePriceString='';
	var typeString='';
	
	featureIdList=fidList.split('^');

	for(i=1;i<featureIdList.length;i++){
		
		fieldID='priceExtraOption'+featureIdList[i];
		typeID='type'+featureIdList[i];
		
		featureIdString=featureIdString+'^'+featureIdList[i];
		featurePriceString=featurePriceString+'^'+document.getElementById(fieldID).value;
		
		
		typeString=typeString+'^'+getCheckedValue(document.extra_optional_from[typeID]);
		

		
	}
//			alert(typeString);
	var url="ajax_agent.php?mode=edit_extra_options&pid="+pid+"&featurePriceString="+featurePriceString+"&featureIdString="+featureIdString+"&typeString="+typeString;
	
	 //alert(url);
     ajax_action_users(url,'addOptionalExtrasPricePanel');
	
}


function pageScroll() {
	//window.scrollBy(0,200); // horizontal and vertical scroll increments
	//scrolldelay = setTimeout('pageScroll()',100); // scrolls every 100 milliseconds

	setTimeout("window.scrollBy(0,400)",200);

}


/*
function to load google map
@param: 

*/
var map = null;
var geocoder = null;
var zoom_level = 13;
function load(lat,lng,zoom) 
{
//	/alert(zoom_level);
	if (GBrowserIsCompatible()) 
	{
		map = new GMap2(document.getElementById("map")); // map is the id of DIV to show google map
		//map.setCenter(new GLatLng(lat,lng), zoom_level);
		map.setCenter(new GLatLng(lat,lng), zoom);
		//var bounds = map.getBounds();
  		//var southWest = bounds.getSouthWest();
  		//var northEast = bounds.getNorthEast();
  		//var lngSpan = northEast.lng() - southWest.lng();
  		//var latSpan = northEast.lat() - southWest.lat();
		//var miles = (3958.75 * Math.acos(Math.sin(northEast.lat() / 57.2958) * Math.sin(southWest.lat() / 57.2958) + Math.cos(northEast.lat() / 57.2958) * Math.cos(southWest.lat() / 57.2958) * Math.cos(northEast.lng() / 57.2958 - southWest.lng() / 57.2958)))
		//miles = Math.abs(miles);
		//alert(miles);
		
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		//map.addControl(new GOverviewMapControl());
		var point = GPoint(lat,lng );
        var marker = new GMarker(new GLatLng(lat,lng));
        map.addOverlay(marker);
	}
	GEvent.addListener(	map,'dragstart',function(){	drag_flag = true; } );
	GEvent.addListener(	map,'dragend',	function(){	setTimeout("drag_flag = false;",100) } );
//	GEvent.addListener(	map,'click',	function(){	if(!drag_flag) window.close(); } );	
}


/////////////////////////////////////////////////////Show DIV START//////////////////////////////////////////////////////////////////////////////////////

var sf=false;


function addSinglePriceOnClickHandler(el,value,name,id)
{

	TDid="TD"+id;
	changeto(TDid,'#FFCCCC');

	xpFloatStop();
	if(sf) return;
	//var id = xpFloat(el);
	var id = xpFloat(el,'',70,23);

	
	
	var dprice=translate('Display Price');	
	var aprofit=translate('Agent Profit');	
	
	id.innerHTML = '<div id="popupmenu_popup"><div  align="right"> <A href="javascript:void(0);" onClick="xpFloatStop();changeBackTo(TDid,\'white\');"></div><font color=black>Close</A><br><DIV class=Content><DIV class=Label>'+dprice+'<INPUT id="dpriceDIV" name="dprice" onChange=getResultingPriceDIV(this.value) value="'+value+'"></DIV><DIV class=Label>'+aprofit+'<INPUT id="aprofitDIV" name="aprofit" readonly><INPUT id="priceID" name="priceID" type="hidden" value=""></DIV><br><DIV class=ButtonContainer><A href="javascript:void(0);" onClick="setPrice();"><IMG src="images/submit.gif" border=0 on></A></DIV><DIV class=MessageArea></DIV></DIV></div>';

	document.getElementById('dpriceDIV').focus();
	document.getElementById('priceID').value=name;


	pageScroll();

	
}

function googleMapShowByName(loactioName)
{
	document.getElementById('map').style.display='none';
	
	var aryLocation = new Array();
	aryLocation = loactioName.split(',');
	document.getElementById('map').style.display='block';
	load(aryLocation[0],aryLocation[1], parseInt(aryLocation[2])-1);
//	var geocoder = new GClientGeocoder();
//	if (geocoder)
//	{
//		geocoder.getLatLng(
//		loactioName,
//		function(point) {
//			if (!point) {
//				//alert(loactioName + " not found");
//			} else {
//				//save
//				//alert(point.lat(),point.lng());
//				document.getElementById('map').style.display='block';
//				//var miles = (3958.75 * Math.Acos(Math.Sin(latitude1 / 57.2958) * Math.Sin(latitude2 / 57.2958) + Math.Cos(latitude1 / 57.2958) * Math.Cos(latitude2 / 57.2958) * Math.Cos(longitude2 / 57.2958 - longitude1 / 57.2958)))
//				load(point.lat(),point.lng());
//			}
//		}
//		);
//	}
}

/*
show map for business
*/
function googleMapShow(el)
{



	xpFloatStop();
	if(sf) return;
	//var id = xpFloat(el);
	var id = xpFloat(el,'',70,23);



	id.innerHTML = '<div id="popupmenu_googlemap"><A href="javascript:void(0);" onClick="xpFloatStop();">X</A><div id="map" style="width: 400px; height: 300px" ></div></div>';
 
	//var lat=document.getElementById('lat').value;
	//var lng=document.getElementById('lng').value;
	
	var aryLocation = new Array();
	aryLocation = document.getElementById('map_').value.toString().split(',');
	load(aryLocation[0],aryLocation[1], parseInt(aryLocation[2])-1);
	
//	alert(lat+lng);
    //load(lat,lng);
	
}

/*
show map for business
*/
function googleMapShowProduct(el,pid)
{
	xpFloatStop();
	if(sf) return;
	//var id = xpFloat(el);
	var id = xpFloat(el,'',40,25);



	id.innerHTML = '<div id="popupmenu_googlemap"><A href="javascript:void(0);" onClick="xpFloatStop();">X</A><div id="map" style="width: 400px; height: 300px" ></div></div>';
 
//	latID='lat'+pid;
//	lngID='lng'+pid;
	
	
//	var lat=document.getElementById(latID).value;
//	var lng=document.getElementById(lngID).value;
	
	var aryLocation = new Array();
	aryLocation = document.getElementById('map_'+pid).value.toString().split(',');
	load(aryLocation[0],aryLocation[1], parseInt(aryLocation[2])-1);
	
//	alert(lat+lng);
//    load(lat,lng);
	
}

/*show product history on detail page*/

function showHistory(pid){
	
	historyDivID='history'+pid;
	historyButtonID='historyButton'+pid;
	
	document.getElementById(historyDivID).style.display='inline';
	document.getElementById(historyButtonID).style.display='none';
	
	
}


////////////////////////////////////////////////////Show Sessions Start//////////////////////////////////////////////////////////////////////////////////
var xmlHttp;
var globalDIV;
var CurrentPopUpDIv;
DIV = new Array('showSession','editSession','addSession','delSession');

var ajax_action_mode; //indicates showing picture or not


function ajax_action(el,url,left,top,div,mode) {

	ajax_action_mode=mode;
	//alert(123);

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert (translate_language("Browser_does_not_support_HTTP_Request"));
		return;
	}
	/*var url="agent_show_sessions.php";
	var pid=document.addRulesPeriod.pid.value;
	url=url+"?date="+date;
	url=url+"&pid="+pid;*/
	url=url+"&sid="+Math.random();
	//alert(url);


	for(var i=0;i<DIV.length;i++)
	{

		//Close all other opened DIV
		xpFloatStopNew(DIV[i]);

	}

	//alert(div);



	if(sf) return;
	var id = xpFloat(el,div,left,top);
	//xpFloatStopNew('showSession');
	globalDIV =id
	//setTimeout('globalDIV.innerHTML = xmlHttp.responseText',200);


	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function editSessionOnClickHandler(el,date) {

	tdID='td'+date;


	changeto(tdID,'#FFCCCC');

	var url="agent_show_sessions.php";
	var pid=document.addRulesPeriod.pid.value;
	url=url+"?date="+date;
	url=url+"&pid="+pid;
	url=url+"&mode=show";
	url=url+"&sid="+Math.random();

	//alert(url);

	ajax_action(el,url,300,23,'showSession','');


}

//Show sessions div from the existing rules table
function showSessions(el,rid){
	ajax_action_mode='noScrollDown';


	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert (translate_language("Browser_does_not_support_HTTP_Request"));
		return;
	}
	var url="agent_show_sessions.php";
	url=url+"?rid="+rid;
	url=url+"&sid="+Math.random();




	xpFloatStop();
	if(sf) return;
	var id = xpFloat(el,'',70,23);
	globalDIV =id
	CurrentPopUpDIv=id

	//alert(xmlHttp.readyState);
	setTimeout('globalDIV.innerHTML = xmlHttp.responseText',100);
	//alert(xmlHttp.readyState);


	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}


function stateChanged()
{
	
	//alert("eliot"+xmlHttp.readyState);
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(123);
		//document.getElementById("txtHint").innerHTML=xmlHttp.responseText
		globalDIV.innerHTML=xmlHttp.responseText
         
		//If the the slideshow is needed
		
		
		if(ajax_action_mode=='pic'||ajax_action_mode=='slideshow'||ajax_action_mode=='slideshowBusiness'){
		 setTimeout("showIndexPic(productID);",200);
		 //setTimeout("showIndexPic(productID,firstPictureID);",200);
		  
		}
	    else if (ajax_action_mode!='noScrollDown'){
	    
		       setTimeout("pageScroll();",200);
         }
		//startDate=document.getElementById('startDate').value;
		//showAddIndividualPricePanel(startDate);
		

	}
}/*
*/
////////////////////////////////////////////////////Show Sessions End//////////////////////////////////////////////////////////////////////////////////

function xpFloat(obj,id,left,top)
{

	//
	var opp=obj;
	if(!id) id = 'xpFloatDiv';
	var curleft = curtop = 0;
	if (obj.offsetParent) { curleft = obj.offsetLeft; curtop = obj.offsetTop;
	while (obj = obj.offsetParent) {curleft += obj.offsetLeft; curtop += obj.offsetTop;}
	}
	var div= document.createElement('div');
	//alert("show"+id);
	div.setAttribute('id',id);
	div.innerHTML = '';
	document.body.appendChild(div);
	var myid = document.getElementById(id);


	//document.getElementById('priceID').value=name;

	//alert(curleft+150 +"px")
	myid.style.position = "absolute";

	//alert(345);
	// myid.style.left = curleft-70 +"px";
	//myid.style.top = curtop+23 +"px";
	myid.style.left = curleft-left +"px";
	myid.style.top = curtop+top +"px";
	return myid;
}

function xpFloatStop(id){

	//alert("stop"+id);
	if(!id) id =document.getElementById('xpFloatDiv');
	if(!id) return;
	id.parentNode.removeChild(id);

}

//With particular id
function xpFloatStopNew(id){


	//alert("stop"+id);
	//if(!id) id =document.getElementById('xpFloatDiv');
	//if(!id) return;
	id =document.getElementById(id);
	if(!id) return;
	id.parentNode.removeChild(id);
	
	
	//popupShow='N'; // set the flag highlight is back to normal
	
	// unhighlight the cell upon closing the popup (Front End)
	if(document.getElementById('cellHighlighted')){
	highlightedID=document.getElementById('cellHighlighted').value;
	//document.getElementById(highlightedID).className = originalCellClass;
	document.getElementById(thID).style.background='white';
    }
}

function ini_agent_pricing(str,startDate,mode){

	if(mode=='save'){
			var ptype=document.addRulesPeriod.ptype.value;
			var url="agent_add_single_price.php?pid="+str+"&startDate="+startDate+"&ptype="+ptype;
			//alert(startDate);
		
			document.getElementById('FinishaddSinglePrice').style.display = 'inline';
			document.getElementById('addSinglePrice').style.display = 'none';
			document.getElementById('AddIndividualPricePanel').style.display = 'inline';
			ajax_do(url);
			pageScroll();
	
	}
	
	if(mode=='showRcoRules'){
	
	
    url="ajax_agent.php?mode=eco_rule_show&pid="+str;
		
	ajax_action_front(url,'existing_eco_rules')
	
	//alert(url);
	}
}

function goTo(str){

	//alert(str);
	var pid=document.addRulesPeriod.pid.value;
	var ptype=document.addRulesPeriod.ptype.value;
	var url="agent_add_single_price.php?pid="+pid+"&startDate="+str+"&ptype="+ptype;



	document.getElementById('FinishaddSinglePrice').style.display = 'inline';
	document.getElementById('addSinglePrice').style.display = 'none';
	document.getElementById('AddIndividualPricePanel').style.display = 'inline';
	ajax_do(url);
	xpFloatStopNew('showSession');
	xpFloatStopNew('editSession');
	xpFloatStopNew('delSession');
	pageScroll();

}

function addEcoRulesHandler(){
	
	pid =document.addRulesPeriod.pid.value;
	startDate =document.getElementById('StartDateEco').value;
	endDate =document.getElementById('EndDateEco').value;
	quantity =document.getElementById('num_available_eco').value;
	
	//Validation 
	     if(startDate==""){
			alert(translate_language("Please_enter_start_date"));
			document.getElementById('StartDateEco').focus();
			return false;
		}
			if(endDate==""){
			alert(translate_language("Please_enter_end_date"));
			document.getElementById('EndDateEco').focus();
			return false;
		}
	
			if(quantity==""){
			alert(translate_language("Please_enter_Quantity_available"));
			document.getElementById('num_available_eco').focus();
			return false;
			}
		   	
		   if(IsNumeric(quantity)==false){
		     alert(translate_language("Quantity_available_has_to_be_a_number"));
			return false;
		   }
		
	
	
    url="ajax_agent.php?mode=eco_rule_add&startDate="+startDate+"&endDate="+endDate+"&quantity="+quantity+"&pid="+pid;
		
	ajax_action_front(url,'existing_eco_rules')
	
	//alert(url);
	
}


function editEcoRulesHandler(){
	
	pid =document.addRulesPeriod.pid.value;

	quantity =document.getElementById('num_available_eco_Edit').value;
	
	     ///general validation  
	    if(quantity==""){
			alert(translate_language("Please_enter_Quantity_available"));
			document.getElementById('num_available_eco_Edit').focus();
			return false;
			}
		   	
		   if(IsNumeric(quantity)==false){
		     alert(translate_language("Quantity_available_has_to_be_a_number"));
		     document.getElementById('num_available_eco_Edit').focus();
			return false;
		   }
		   
		   ///logical validation  
	       bookingID="bookings"+selectedEcoRule;
	       bookings =document.getElementById(bookingID).value;
	       //alert(bookings);
	       if(quantity<bookings){
	       	
	       	alert(translate_language("Quantity_available_cannot_be_less_than_existing_bookings"));
			document.getElementById('num_available_eco_Edit').focus();
			return false;
	       	
	       }
	
    url="ajax_agent.php?mode=eco_rule_edit&quantity="+quantity+"&pid="+pid+"&rid="+selectedEcoRule;
		
	ajax_action_front(url,'existing_eco_rules')
	
	document.getElementById('AddEcoRules').style.display = 'inline';
	document.getElementById('EditEcoRules').style.display = 'none';
	
}

function addSessionOnClickHandler(str){

	//alert("eliot");

	pid =document.addRulesPeriod.pid.value;
	ptype =document.addRulesPeriod.ptype.value;


	if(ptype=="AT"){

		if(document.getElementById('L_HH').value==0&&document.getElementById('L_MM').value==0){
			alert(translate_language("Hours_and_Minutes_cannot_be_both_empty"));
			return false;
		}
	}

	if(ptype=="EV"){
		//alert(ptype);
		if(document.getElementById('L_HH').value==0&&document.getElementById('L_MM').value==0&&document.getElementById('L_DD').value==0){
			alert(translate_language("Days_Hours_and_Minutes_cannot_be_all_empty"));
			//alert(ptype);
			return false;
		}
	}


	if(document.getElementById('num_available').value==""){
		alert(translate_language("Quantity_available_is_empty"));
		return false;
	}

	if(document.getElementById('salePrice').value==""){
		alert(translate_language("Display_price_is_empty"));
		return false;
	}



	var from_MM=document.getElementById('MM').value;
	var from_HH=document.getElementById('HH').value;
	var from_AM_PM=document.getElementById('AM_PM').value;
	var L_MM=document.getElementById('L_MM').value;
	var L_HH=document.getElementById('L_HH').value;
	var A_num=document.getElementById('num_available').value;
	var salePrice=document.getElementById('salePrice').value;
	if(ptype=="EV"){
		var L_DD=document.getElementById('L_DD').value;
	}
	var timeOBJ=document.getElementById('time');
	var time="";
	if(timeOBJ)
	time=timeOBJ.value;

	//alert(from_MM+from_HH+from_AM_PM+L_MM+L_HH);
	if(ptype=="EV"){
	finalURL="agent_add_session.php?mode=add&from_MM="+from_MM+"&from_HH="+from_HH+"&from_AM_PM="+from_AM_PM+"&L_DD="+L_DD+"&L_MM="+L_MM+"&L_HH="+L_HH+"&pid="+pid+"&time="+time+"&A_num="+A_num+"&salePrice="+salePrice;
	}else{
	finalURL="agent_add_session.php?mode=add&from_MM="+from_MM+"&from_HH="+from_HH+"&from_AM_PM="+from_AM_PM+"&L_MM="+L_MM+"&L_HH="+L_HH+"&pid="+pid+"&time="+time+"&A_num="+A_num+"&salePrice="+salePrice;
	}

	//alert(finalURL);
	ajax_do(finalURL);

}


/////////////////////////////////////////////////////Show DIV END//////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////AJAX START///////////////////////////////////////////////////////////
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

//////////////////////////////////////AJAX END///////////////////////////////////////////////////////////


function setSinglePriceSubmit(el){


	var startTimeHourString="";
	var startTimeMinuteString="";
	var AM_PMString="";
	var l_HHString="";
	var l_MMString="";
	var l_DDString="";
	var dpricString="";
	var num_availableString="";
	var sidString="";


	//alert("eliot");
	num_session=document.getElementById('num_session').value;
	date=document.getElementById('date').value;
	var pid=document.addRulesPeriod.pid.value;

	for(var i=0;i<num_session;i++){

		startTimeHourID='startTimeHour'+i;
		startTimeMinuteID='startTimeMinute'+i;
		AM_PMID='AM_PM'+i;
		l_HHID='l_HH'+i;
		l_MMID='l_MM'+i;
		l_DDID='l_DD'+i;
		dpriceID='dprice'+i;
		num_availableID='num_available'+i;
		sidID='sid'+i;
		startTimeHour=document.getElementById(startTimeHourID).value;
		startTimeMinute=document.getElementById(startTimeMinuteID).value;
		AM_PM=document.getElementById(AM_PMID).value;
		l_HH=document.getElementById(l_HHID).value;
		l_MM=document.getElementById(l_MMID).value;
		l_DD=document.getElementById(l_DDID).value;
		dprice=document.getElementById(dpriceID).value;
		num_available=document.getElementById(num_availableID).value;
		sid=document.getElementById(sidID).value;

		var startTimeHourString =startTimeHourString+'-'+startTimeHour;
		var startTimeMinuteString =startTimeMinuteString+'-'+startTimeMinute;
		var AM_PMString =AM_PMString+'-'+AM_PM;
		var l_HHString =l_HHString+'-'+l_HH;
		var l_MMString =l_MMString+'-'+l_MM;
		var l_DDString =l_DDString+'-'+l_DD;
		var dpricString =dpricString+'-'+dprice;
		var num_availableString =num_availableString+'-'+num_available;
		var sidString =sidString+'-'+sid;



	}


	url="agent_show_sessions.php?mode=edit&num_session="+num_session+"&startTimeHourString="+startTimeHourString+"&startTimeMinuteString="+startTimeMinuteString+"&AM_PMString="+AM_PMString+"&l_HHString="+l_HHString+"&l_MMString="+l_MMString+"&l_DDString="+l_DDString+"&dpricString="+dpricString+"&num_availableString="+num_availableString+"&sidString="+sidString+"&date="+date+"&pid="+pid;

	//alert(url);
	//xpFloatStopNew('showSession');

	ajax_action(el,url,300,+20,'editSession','');
	pageScroll();
	//alert(startTimeHourString);
	//document.editSessionList.submit()

}


function sessionDeleteOnclickHandler(el,sid){
	//xpFloatStopNew('showSession');


	date=document.getElementById('date').value;
	pid=document.addRulesPeriod.pid.value;
	//alert(sid);
	url="agent_show_sessions.php?sessionid="+sid+"&mode=del&date="+date+"&pid="+pid;
	ajax_action(el,url,300,+20,'delSession','');
	startDate=document.getElementById('startDate').value;
	//delay the refresh of panel
	setTimeout("showAddIndividualPricePanel(startDate,date);",400);

}





function ShowaddASessionPanel(){

	//alert(123);
	document.getElementById('addNewSession').style.display='inline';
	document.getElementById('addNewSessionButton').style.display='none';
	pageScroll();

}

function addASessionOnClickHandler(el){



	// alert(123);
	startTimeHour=document.getElementById('DIV_HH').value;
	startTimeMinute=document.getElementById('DIV_MM').value;
	AM_PM=document.getElementById('DIV_AM_PM').value;
	l_DD=document.getElementById('DIV_L_DD').value;
	l_HH=document.getElementById('DIV_L_HH').value;
	l_MM=document.getElementById('DIV_L_MM').value;
	dprice=document.getElementById('DIV_salePrice').value;
	num_available=document.getElementById('DIV_num_available').value;
	date=document.getElementById('date').value;
	ptype=document.getElementById('ptype').value;

	////////////////////////Validation Start/////////////////////////////////////////////
	if(ptype=="EV")
	{
		if(	l_DD==0&&l_HH==0&&l_MM==0)
		{
			alert(translate_language("Days_hours_and_minutes_of_Length_cannot_be_all_empty"));
			return false;
		}
	}
	if(ptype=="AT")
	{
		if(	l_HH==0&&l_MM==0)
		{
			alert(translate_language("Hours_and_minutes_of_Length_cannot_be_all_empty"));
			return false;
		}
	}
	if(num_available==0)
	{
		alert(translate_language("Quantity_available_is_empty"));
		return false;
	}

	if(dprice==0)
	{
		alert(translate_language("Display_price_is_empty"));
		return false;
	}



	////////////////////////Validation End/////////////////////////////////////////////


	pid=document.addRulesPeriod.pid.value;
	var data=startTimeHour+'-'+startTimeMinute+'-'+AM_PM+'-'+l_HH+'-'+l_MM+'-'+dprice+'-'+num_available+'-'+l_DD;
	//alert(date);
	url="agent_show_sessions.php?mode=add&date="+date+"&pid="+pid+"&data="+data;
	//alert(url);

	ajax_action(el,url,300,+20,'addSession','');

	startDate=document.getElementById('startDate').value;

	//delay the refresh of panel
	setTimeout("showAddIndividualPricePanel(startDate,date);",400);

	//pageScroll();

	tdID='td'+date;
	//changeto(tdID,'#FFCCCC');
	//pageScroll();
	//setTimeout("",200);
	// changeto(tdID,'black');
	//document.getElementById(tdID).style.backgroundColor='black';
	//alert(123);
	//alert(startTimeHour+startTimeMinute+AM_PM+l_HH+l_MM+dprice+num_available);

}

var currentID='';
var Globalhighlightcolor='';
function changeto(id,highlightcolor){
    //alert(id);

	//alert("eliot"+highlightcolor);
	changeBackTo(currentID,'white');
	currentID=id;
	Globalhighlightcolor=highlightcolor;

	//alert(123);
	setTimeout("document.getElementById(currentID).style.backgroundColor=Globalhighlightcolor;",200);

	/*source=ie? event.srcElement : e.target
	if (source.tagName=="TABLE")
	return
	while(source.tagName!=highlightbehavior && source.tagName!="HTML")
	source=ns6? source.parentNode : source.parentElement
	if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
	source.style.backgroundColor=highlightcolor
	*/
}

function changeBackTo(id,highlightcolor)
{
	OBJToChange=document.getElementById(id);
	if(OBJToChange)
	OBJToChange.style.backgroundColor=highlightcolor;
}

function EditSessionPanelOnCloseHandler(div,date){

	xpFloatStopNew(div);
	tdID='td'+date;
	changeBackTo(tdID,'white');

}

function userSearchOnClickHandler(){

	var url="ajax_user.php?mode=search&utype="+document.getElementById('usertype').value;
	ajax_action_users(url,'userSearchResult');

}

function regionManageOnClickHandler(){

	document.getElementById('plus').style.display='none';
	document.getElementById('minus').style.display='inline';
	var url="ajax_website.php?mode=show";
	ajax_action_users(url,'regionManage');

}

function regionManageOnClickHandlerHide(){

	document.getElementById('plus').style.display='inline';
	document.getElementById('minus').style.display='none';
	document.getElementById('regionManage').innerHTML="";
	//var url="ajax_website.php?mode=show";
	//ajax_action_users(url,'regionManage');

}

function featureManageOnClickHandler(){

	document.getElementById('plus_features').style.display='none';
	document.getElementById('minus_features').style.display='inline';
	var url="ajax_website.php?mode=show&main=feature";
	ajax_action_users(url,'featureManage');

}

function featureManageOnClickHandlerHide(){

	document.getElementById('plus_features').style.display='inline';
	document.getElementById('minus_features').style.display='none';
	document.getElementById('featureManage').innerHTML="";
	//var url="ajax_website.php?mode=show";
	//ajax_action_users(url,'regionManage');

}


function hotOfferManageOnClickHandler(){

	document.getElementById('plus_hot_offers').style.display='none';
	document.getElementById('minus_hot_offers').style.display='inline';
	var url="ajax_website.php?mode=&main=hot_offer";
	ajax_action_users(url,'hotOfferManage');

}


function hotOfferManageOnClickHandlerHide(){

	document.getElementById('plus_hot_offers').style.display='inline';
	document.getElementById('minus_hot_offers').style.display='none';
	document.getElementById('hotOfferManage').innerHTML="";
	//var url="ajax_website.php?mode=show";
	//ajax_action_users(url,'regionManage');

}

function categorizationShow(){

	document.getElementById('plus_categorization').style.display='none';
	document.getElementById('minus_categorization').style.display='inline';
	var url="ajax_website.php?mode=&main=product_categorization";
	ajax_action_users(url,'categorizationManage');

}


function categorizationHide(){

	document.getElementById('plus_categorization').style.display='inline';
	document.getElementById('minus_categorization').style.display='none';
	document.getElementById('categorizationManage').innerHTML="";
	//var url="ajax_website.php?mode=show";
	//ajax_action_users(url,'regionManage');

}

function notificationShow(){

	document.getElementById('plus_notification').style.display='none';
	document.getElementById('minus_notification').style.display='inline';
	var url="ajax_website.php?mode=&main=notification";
	ajax_action_users(url,'notificationManage');

}


function notificationHide(){

	document.getElementById('plus_notification').style.display='inline';
	document.getElementById('minus_notification').style.display='none';
	document.getElementById('notificationManage').innerHTML="";
	//var url="ajax_website.php?mode=show";
	//ajax_action_users(url,'regionManage');

}

function currencyShow(){

	document.getElementById('plus_currency').style.display='none';
	document.getElementById('minus_currency').style.display='inline';
	var url="ajax_website.php?mode=&main=currency";
	ajax_action_users(url,'currencyManage');

}


function currencyHide(){

	document.getElementById('plus_currency').style.display='inline';
	document.getElementById('minus_currency').style.display='none';
	document.getElementById('currencyManage').innerHTML="";
	
}

function saveNotificaton(id){
	
	value=document.getElementById(id).value;
	if(value!=''){
		
	var url="ajax_website.php?mode=Save&main=notification&id="+id+"&value="+value;
	ajax_action_users(url,'notificationManage');
	}
	
}

function addCategoryHandler(type, obj){
		if(obj.value==""){
			alert(translate_language("No_category_is_entered"));
			obj.focus();
			return false;
		}
	//alert(country);
	var url="ajax_website.php?mode=add&main=product_categorization&data="+obj.value+"&type="+type;
	//alert(url);
	ajax_action_users(url,'categorizationManage');

}

function addFeatureHandler(type){

	if(type=='all'){

		var data=document.getElementById('all_room').value;
		if(data==""){
			alert(translate_language("No_feature_is_entered"));
			document.getElementById('all_room').focus();
			return false;
		}
	}
	if(type=='specific'){

		var data=document.getElementById('specific_room').value;
		if(data==""){
			alert(translate_language("No_feature_is_entered"));
			document.getElementById('specific_room').focus();
			return false;
		}
	}

	if(type=='extra'){

		var data=document.getElementById('extra_option').value;
		if(data==""){
			alert(translate_language("No_feature_is_entered"));
			document.getElementById('extra_option').focus();
			return false;
		}
	}
	
	if(type=='room_type'){

		var data=document.getElementById('room_type').value;
		if(data==""){
			alert(translate_language("No_room_type_is_entered"));
			document.getElementById('room_type').focus();
			return false;
		}
	}


	
	var url="ajax_website.php?mode=add&main=feature&type="+type+"&data="+encodeURIComponent(data);
	//alert(url);
	ajax_action_users(url,'featureManage');

}

function addCurrencyHandler(){
	
	var data=document.getElementById('currency').value;
	if(data==""){
			alert(translate_language("Currency_is_empty"));
			document.getElementById('currency').focus();
			return false;
		}
    var sign=document.getElementById('sign').value;
	if(sign==""){
			alert(translate_language("Sign_is_empty"));
			document.getElementById('sign').focus();
			return false;
		}
	var url="ajax_website.php?mode=add&main=currency&data="+data+"&sign="+sign;
	ajax_action_users(url,'currencyManage');
}

function addAreaHandler(type){

	var pid='';

	// if it is to add country
	if(type=='coun'){

		var data=document.getElementById('new_country').value;
		var lat=document.getElementById('new_country_lat').value;
		var lon=document.getElementById('new_country_lon').value;
		var zoom=document.getElementById('new_country_zoom').value;
		if(data==""){
			alert(translate_language("Country_is_empty"));
			document.getElementById('new_country').focus();
			return false;
		}
	}

	// if it is to add region

	if(type=='region'){

		var data=document.getElementById('new_region').value;
		var lat=document.getElementById('new_region_lat').value;
		var lon=document.getElementById('new_region_lon').value;
		var zoom=document.getElementById('new_region_zoom').value;
		var pid=document.getElementById('addRegionCountry').value;
		if(pid==""){
			alert(translate_language("Please_specify_a_country"));
			document.getElementById('addRegionCountry').focus();
			return false;
		}

		if(data==""){
			alert(translate_language("Region_is_empty"));
			document.getElementById('new_region').focus();
			return false;
		}
	}

	// if it is to add town

	if(type=='town'){

		var data=document.getElementById('new_town').value;
		var lat=document.getElementById('new_town_lat').value;
		var lon=document.getElementById('new_town_lon').value;
		var zoom=document.getElementById('new_town_zoom').value;
		var region=document.getElementById('addTownRegion').value;
		var country=document.getElementById('addTownCountry').value;
		pid=document.getElementById('addTownRegion').value;
		//alert(pid);
		if(country==""){
			alert(translate_language("Please_specify_a_country"));
			document.getElementById('addTownCountry').focus();
			return false;
		}

		if(region==""){
			alert(translate_language("Please_specify_a_region"));
			document.getElementById('addTownRegion').focus();
			return false;
		}

		if(data==""){
			alert(translate_language("Town_is_empty"));
			return false;
		}
	}
	//alert(country);
	var url="ajax_website.php?mode=add&type="+type+"&data="+data+"&lat="+lat+"&lon="+lon+"&zoom="+zoom+"&pid="+pid;
	//alert(url);
	ajax_action_users(url,'regionManage');

}

function deleteAreaHandler(id){

	var url="ajax_website.php?mode=del&id="+id;
	//alert(url);
	ajax_action_users(url,'regionManage');

}

function addRegionDetailsHandler(id){

	var url="add_region_details.php?id="+id;
	//alert(url);
	window.open(url);

}

function showRegionDetailsHandler(id){

	var url="add_region_details.php?mode=show&id="+id;
	//alert(url);
//	window.open=url;
	window.open(url);

}


function deleteFeatureHandler(id){

	var url="ajax_website.php?mode=del&main=feature&id="+id;
	//alert(url);
	ajax_action_users(url,'featureManage');

}

function deleteCurrencyHandler(id){

	var url="ajax_website.php?mode=del&main=currency&id="+id;
	ajax_action_users(url,'currencyManage');

}

function deleteCategoryHandler(id){

	var url="ajax_website.php?mode=del&main=product_categorization&id="+id;
	//alert(url);
	ajax_action_users(url,'categorizationManage');

}


function addTownCountryOnChangeHandlder(country){

	//alert(country);

	var url="ajax_website.php?mode=show&cid="+country;
	//alert(url);
	ajax_action_users(url,'regionManage');

}





////////////////////////////////////////////////////Search User Start//////////////////////////////////////////////////////////////////////////////////
var xmlHttp;
//var globalDIV;
var CurrentPopUpDIvUser;
var page_scroll;

function ajax_action_users(url,div,page_scroll) {

	CurrentPopUpDIvUser=div;
	page_scroll=page_scroll;

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert (translate_language("Browser_does_not_support_HTTP_Request"));
		return;
	}

	url=url+"&sid="+Math.random();

	xmlHttp.onreadystatechange=stateChangedUser
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}



function stateChangedUser()
{

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		if (xmlHttp.status == 200) {
			
			document.getElementById(CurrentPopUpDIvUser).innerHTML=xmlHttp.responseText;
			    }
		if(page_scroll=='Y'){
		  setTimeout("pageScroll();",200);
		}

	}
}
////////////////////////////////////////////////////Search User End//////////////////////////////////////////////////////////////////////////////////


//checkbox operation
function checkAll(flag, form, prefix) {
	if (!form)
	return;

	if (prefix)
	var reg = new RegExp("^"+prefix, "");
	for (var i = 0; i < form.elements.length; i++) {
		if (form.elements[i].type == "checkbox" && (!prefix || form.elements[i].name.search(reg) == 0) && !form.elements[i].disabled)
		form.elements[i].checked = flag;
	}
}

//checkbox operation
function deleteSelected(form, prefix,url) {

	var data='';

	if (!form)
	return;

	if (prefix)
	var reg = new RegExp("^"+prefix, "");
	for (var i = 0; i < form.elements.length; i++) {
		if (form.elements[i].type == "checkbox" && (!prefix || form.elements[i].name.search(reg) == 0) && !form.elements[i].disabled && form.elements[i].checked==true)
		data=data+'-'+form.elements[i].value;
	}

	var utype=document.getElementById('utype').value
	url=url+"?mode=del&data="+data+"&utype="+utype;
	//alert(url);
	ajax_action_users(url,'userSearchResult');

}

//checkbox operation
function refundSelected(form, prefix,url) {

	
	var data='';

	if (!form)
	return;


	for (var i = 0; i < form.elements.length; i++) {
		if (form.elements[i].type == "checkbox" && form.elements[i].checked==true&& !form.elements[i].disabled)
		data=data+'-'+form.elements[i].value;
	}
	
	document.getElementById('selectedOrders').value=data;
	form.submit();


}


function saveHotOffers(length){
	
	//alert(length);
	var form="document.selectHotOffer";
    var prefix="isHotOffer";
    var hotOfferString='';
    var idString='';
    var typeString='';
	
	
    //create hotOfferString
	if (prefix)
	var reg = new RegExp("^"+prefix, "");
	for (var i = 0; i < document.selectHotOffer.elements.length; i++) {
		//alert(123);
		if (document.selectHotOffer.elements[i].type == "checkbox" && (!prefix || document.selectHotOffer.elements[i].name.search(reg) == 0) && !document.selectHotOffer.elements[i].disabled)
		  
		if(document.selectHotOffer.elements[i].checked==true)
		    hotOfferString=hotOfferString+'-Y';
		 else
		    hotOfferString=hotOfferString+'-N';
		
		
	}
	
	//create idString and typeString
	for(i=0;i<length;i++){
		
		idID='id'+i;
		typeID='type'+i;
		idString=idString+'-'+document.getElementById(idID).value;
		typeString=typeString+'-'+document.getElementById(typeID).value;
		
	}
	
	
	region=document.getElementById('region').value;
	country=document.getElementById('country').value;
   
	
	var url="ajax_website.php?mode=modify_product_list&main=hot_offer&hotOfferString="+hotOfferString+"&idString="+idString+"&typeString="+typeString+"&country="+country+"&region="+region;
	//alert(url);
	ajax_action_users(url,'hotOfferManage');
}
//<a href="javascript: checkAll(true, document.processuserform, 'user');">Check all</a> / <a href="javascript: checkAll(false, document.processuserform, 'user');">Uncheck all</a>

//###################################################### Front END start################################################################################################################

var multipleAjax;  //indicate which page is in
var currentURL;
var refineSearch='N';
var sessionLanguage='en';
var ajax_command_array = new Array();
function ini_index(){
    if(document.getElementById('hiddenCurrency').value!='')
	document.getElementById('currency').value=document.getElementById('hiddenCurrency').value;
	
//	Carousel();
	main=document.getElementById('mode').value;
	selectedSearchOptionsOBJ=document.getElementById('selectedSearchOptions');
//	alert(selectedSearchOptionsOBJ.value);
	
	
/* if it is to refine search, load  users' selections */
	if(selectedSearchOptionsOBJ){
		     
		       refineSearch='Y';
		
/*	Accommodation	*/
		if(main==''){
				splitString=selectedSearchOptionsOBJ.value.split(',');
		        document.getElementById('minPrice').value=splitString[0];
		        document.getElementById('maxPrice').value=splitString[1];
		        document.getElementById('StartDate').value=splitString[8];
		        document.getElementById('startRating').value=splitString[2];
		        document.getElementById('roomType').value=splitString[3];
		        document.getElementById('keyword').value=splitString[10];
		        document.getElementById('selectedFeatures').value=splitString[4];
		        document.getElementById('selectedFeatureTypes').value=splitString[5];
		        document.getElementById('currency').value=splitString[11];
		        
		        selectedFeatures=splitString[4].split('^');
		        selectedFeatureType=splitString[5].split('^');
		       
		        /*Features */
		        for(i=1;i<selectedFeatures.length;i++){
		        	
		        	selectedFeatureID=selectedFeatureType[i]+'^'+selectedFeatures[i];
		//        	alert(selectedFeatureID);
		        	document.getElementById(selectedFeatureID).checked=true;
		
		        }
		        
		
		        
		         		
		       /*show the advanced search panel	*/
				collapse2.slideit();
			    showMoreOptions();
			    //alert(splitString[7]+splitString[6]);
//				advanceSearchAjaxUpdator(splitString[7],splitString[6]);
				url='';
				var url="ajax_search.php?mode=country&main="+main+"&startDate="+splitString[8]+"&id="+splitString[7]+"&region="+splitString[6];
		 }
/* Activity and tour */
		else{
			
			    splitString=selectedSearchOptionsOBJ.value.split(',');
		        document.getElementById('minPrice').value=splitString[0];
		        document.getElementById('maxPrice').value=splitString[1];
		        document.getElementById('StartDate').value=splitString[8];
		        document.getElementById('keyword').value=splitString[10];
		        selectedCategoriesArray=splitString[9].split('^');
		        var categoryList='';
		        	
		        for(i=0;i<selectedCategoriesArray.length;i++){
		        	   
		        	   categoryList+=","+selectedCategoriesArray[i]+"";
		
		        }	
		        
		         categoryList=categoryList.substring(1); 
//		         alert(splitString[7]+splitString[6]);
                  selectedCategories=categoryList;
//		         advanceSearchAjaxUpdator(splitString[7],splitString[6]);
		         url='';
		         
		         
			  	 var url="ajax_search.php?mode=restore_selection&country="+splitString[7]+"&startDate="+splitString[8]+"&main="+main+"&category="+categoryList+"&region="+splitString[6];
                  
			  	 /*show the advanced search panel	*/
				collapse2.slideit();
			    showMoreOptions();

		}
	}
/* not refine search	*/
	else{
	    
	    startDate = session_date!=''?session_date:get_today();
		var url="ajax_search.php?mode=show&main="+main+"&startDate="+startDate;
		document.getElementById('StartDate').value=session_date!=''?session_date:get_today();
		reloadIframe('flashSlideShow');	
        reloadIframe('youtubeSlideShow');	
	}


//	ajax_action_front(url,'col1');
//if(url!=''){
    ajax_command_array.push('ajax_action_front(\''+url+'\',\'searchPanelTop\')');
    if (!selectedSearchOptionsOBJ){
    	ajax_command_array.push('country_onChange()');
    }else{
    	ajax_command_array.push('advanceSearchAjaxUpdator(\''+splitString[7]+'\',\''+splitString[6]+'\', 1)');
    }
    
    eval(ajax_command_array.shift());
    
//}

    var preSelectedCountry=document.getElementById('preSelectedCountry').value;


    
    var url="ajax_search.php?load=auto&mode=show_hot_offer&main="+main+"&country="+preSelectedCountry;

	multipleAjax='index.php';
	currentURL=url;
	

	
}

/*
change language function
*/
//
//function changeLang(lang){
//	
//   var url="login.php?mode=change_lang&lang="+lang;
//   window.location = url;
//   return false;
//}

/*onload for accomm*/

function accomm_ini(){
	
//	alert(123);
	var priceDisplayMode=document.getElementById('showMinMaxPrice').value;
//	alert(priceDisplayMode);
	if(priceDisplayMode==''||priceDisplayMode=='min'){
		
		document.getElementById('Max').style.display='inline';
	}
	else{
		document.getElementById('Min').style.display='inline';
	}
	
}

/*onload for activity*/

function activity_ini(){
	

	priceDisplayMode=document.getElementById('showMinMaxPrice').value;

	if(priceDisplayMode==''||priceDisplayMode=='min'){
		
		document.getElementById('Max').style.display='inline';
	}
	else{
		document.getElementById('Min').style.display='inline';
	}
	
}

/*onload for tour*/

function tour_ini(){
	

	priceDisplayMode=document.getElementById('showMinMaxPrice').value;

	if(priceDisplayMode==''||priceDisplayMode=='min'){
		
		document.getElementById('Max').style.display='inline';
	}
	else{
		document.getElementById('Min').style.display='inline';
	}
	
}

function switchPriceDisplay(mode,ptype){
	
		document.getElementById('showMinMaxPrice').value=mode;
		if(ptype=='AM'){
		document.navigateSearchResult.submit();
		}
		if(ptype=='AT'){
		document.navigateSearchResultActivity.submit();
		}
		if(ptype=='EV'){
		document.navigateSearchResultTour.submit();
		}
}


function get_today(){
	
	var thedate = new Date( );
	var theyear = thedate.getFullYear( );
	var themonth = thedate.getMonth( ) + 1;
	var theday = thedate.getDate( );
	 if(parseInt(theday)<10){
	    	
	    	theday='0'+theday;
	    }
	 if(parseInt(themonth)<10){
	    	
	    	themonth='0'+themonth;
	    }
	var today=theday+'-'+themonth+'-'+theyear;

	if (document.getElementById('today_set').value){
		today = document.getElementById('today_set').value;
	}
	return today;
}
/*
cookie functions*/



var selectedCountry;
var showLoadingImage='Y';  //flag whether to show loading image while Ajax is being used.

function country_onChange(){
	zoom_level = 4;
	//document.getElementById('slideshowLoaction').innerHTML = translate_language('Location_Is') + document.search_form.country.options[document.getElementById('country').selectedIndex].text;
	//googleMapShowByName(document.search_form.country.options[document.getElementById('country').selectedIndex].text);
	if (!(document.getElementById('country').selectedIndex >= 0)){
		return;
	}
	var id = document.search_form.country.options[document.getElementById('country').selectedIndex].value;
	googleMapShowByName(document.getElementById('country_'+id).innerHTML);
//	xpWindow.CookieDelete('slider1');

    var d = new Date();
   
	
	displaySlideShow();
	reloadIframeBool='Y';
	
	country=document.getElementById('country').value;
	selectedCountry=document.getElementById('selectedCountry').value;
	if(country==selectedCountry){
		return;
	}
	
	document.getElementById('selectedCountry').value=country;
	
	
//	advanceSearchAjaxUpdator('','');  //update region and category list
	var url="ajax_search.php?mode=show_hot_offer&main="+main+"&country="+country;
	multipleAjax='index.php';
	currentURL=url;
    advanceSearchAjaxUpdator(country,''); 
	
	
	
	/*selectedCountry=document.getElementById('selectedCountry').value;
	country=document.getElementById('country').value;
	startDate=document.getElementById('StartDate').value;;

	main=document.getElementById('mode').value;
    
	if(country==selectedCountry){
		
		return;
	}
	
	document.getElementById('selectedCountry').value=country;

///show loading image
   if(showLoadingImage=='Y'){
   	  showLoadingImageDo('searchPanelTop');
   }
	
	var url="ajax_search.php?mode=country&main="+main+"&id="+country+"&startDate="+startDate;
	//	alert(url);
//	ajax_action_front(url,'col1');
    ajax_action_front(url,'searchPanelTop');


	var url="ajax_search.php?mode=show_hot_offer&main="+main+"&country="+country;

     	
     	 
	multipleAjax='index.php';
	currentURL=url;*/
	
}

function showLoadingImageDo(div){
		
//	document.getElementById(div).innerHTML='<br><div id=loading align=center style="color:white">loading... <img src="images/loading_animation_liferay.gif" alt="Loading payment summary" border="0"></div><br>';
    document.getElementById('country').disabled=true;
    document.getElementById('town').disabled=true;  
    if(document.getElementById('category'))
    document.getElementById('category').disabled=true; 
//    alert(123);
//    document.getElementById('searchButton').display='none';
}



function country_onChange_admin(){

	var country=document.getElementById('country').value;
   
	var url="ajax_website.php?mode=&main=hot_offer&country="+country;
	
	//	alert(url);
	ajax_action_users(url,'hotOfferManage');
}



function region_onChange_admin(){

	region=document.getElementById('region').value;
	country=document.getElementById('country').value;
   
	var url="ajax_website.php?mode=show_product_list&main=hot_offer&country="+country+"&region="+region;
	
   //alert(url);
	ajax_action_users(url,'hotOfferManage');
	
}


function displaySlideShow(){
	
	document.getElementById('intro').style.display='none';
	//document.getElementById('dymanicSplash').style.display='inline';
	document.getElementById('dymanicSplash').style.display='block';
}


function region_onChange(){
	var town = document.getElementById('town').value;
	if (hotterOffer!=0 && town==''){town='all';}
	
	var regionType = '';
	
	var slideshowLoaction = '';
	
	if(town==''){return;}
	if(town!='all'){
		var country = document.search_form.country.options[document.getElementById('country').selectedIndex].text;
		var objRegion = document.search_form.region.options[document.getElementById('town').selectedIndex];
		var regin = '';
		var subRegin = new String('');
		if(objRegion.className != 'lightblue'){
			subRegin = objRegion.text;
			subRegin = subRegin.substring(subRegin.indexOf('-')+1);
			for (var x = objRegion; x != null; x=x.previousSibling){
				if (x.className== 'lightblue'){
					regin = x.text;
					break;
				}
			}
			zoom_level = 13;
		}else{
				regin = objRegion.text;
				zoom_level = 6;
			};
		loactioName = subRegin + ' , ' + regin + ' , ' + country;
		
		if (subRegin==''){
			slideshowLoaction = regin + ' , ' + country;
		}else{
			slideshowLoaction = subRegin + ' , ' + regin + ' , ' + country;
		}
		//document.getElementById('slideshowLoaction').innerHTML = translate_language('Location_Is') + slideshowLoaction;
		//googleMapShowByName(loactioName);
		googleMapShowByName(document.getElementById('region_'+objRegion.value).value);
	}else{
		//document.getElementById('slideshowLoaction').innerHTML = translate_language('Location_Is') + document.search_form.country.options[document.getElementById('country').selectedIndex].text;
		var objCountry = document.search_form.country.options[document.getElementById('country').selectedIndex];
		googleMapShowByName(document.getElementById('country_'+objCountry.value).innerHTML);
	}
   
	myDropdownList = document.search_form.region;
	if(myDropdownList){
	
		// Loop through all the items
		for (iLoop = 0; iLoop< myDropdownList.options.length; iLoop++)
		{
			if (myDropdownList.options[iLoop].selected == true)
			{
				// Item is found. Set its selected property, and exit the loop
				regionType=myDropdownList.options[iLoop].id;
			}
		}
	}
	
//   alert(regionType);
	
   displaySlideShow();
   reloadIframeBool='Y';
    
    if(userEntryPoint==''){
    	
    	userEntryPoint='region';
    }
	var region=document.getElementById('town').value;          //region just selected
    var currentRegion=document.getElementById('selectedRegion').value;  //region previously selected
    var main=document.getElementById('mode').value;          //current tab (AT,EV,'')
    var currentRegionType=document.getElementById('currentRegionType').value   //type of region previously selected (region.subregion)
   /*if All regions are selected, show the hot offer from the selected country    */
    if(regionType=='all' || regionType==''){
    	    country=document.getElementById('country').value;          //country just selected
    	    if (hotterOffer == 1){
    	    	var url="ajax_search.php?mode=show_hot_offer&main="+main+"&country="+country+"&hotterOfferRefresh=1";
    	    	hotterOffer = 0;
    	    }else{
    	    	var url="ajax_search.php?mode=show_hot_offer&main="+main+"&country="+country;
    	    }
    }else{
    	if (hotterOffer == 1){
    		var url="ajax_search.php?mode=show_hot_offer&main="+main+"&region="+region+"&regionType="+regionType+"&currentRegion="+currentRegion+"&currentRegionType="+currentRegionType+"&hotterOfferRefresh=1";
    		hotterOffer = 0;
    	}else{
    		var url="ajax_search.php?mode=show_hot_offer&main="+main+"&region="+region+"&regionType="+regionType+"&currentRegion="+currentRegion+"&currentRegionType="+currentRegionType;
    	}
    }
//    alert(url);
    
   // don't show categorylist when mode is 
    //document.getElementById('currency_title').innerHTML +=  url +'<br>'+ hotterOffer +'<br>';
    if(document.getElementById('mode').value!=''){
    	
     multipleAjax='show_avail_product'; 
    
    }
    
	ajax_action_front(url,'hotOfferList');
	document.getElementById('selectedRegion').value=region;
	document.getElementById('currentRegionType').value=regionType;
	
	//var url="ajax_website.php?mode=show_product_list&main=hot_offer&country="+country+"&region="+region;
	
   //alert(document.getElementById('selectedRegion').value);
	//ajax_action_users(url,'hotOfferManage');
	
	
}

function searchFormSubmit(){
   
	if(document.getElementById('category')){
		if(document.getElementById('category').disabled){
		message=translate_language('Form_is_loading');	
		alert(message);
		return;
		}
	}
    
	if(	document.getElementById('country').disabled ||
    	document.getElementById('town').disabled ){
		message=translate_language('Form_is_loading');	
		alert(message);
		return;
    }
	
	minPrice=document.getElementById('minPrice').value;
	maxPrice=document.getElementById('maxPrice').value;
	
	if(document.getElementById('town').value==""){
		//alert(sessionLanguage);

		message=translate_language('You_have_to_select_a_region');	
		alert(message);
		return;
	}
	
    if(document.getElementById('currency').value==""){
		//alert(sessionLanguage);

		message=translate_language('You_have_to_select_a_currency');	
		alert(message);
		return;
	}
	
	if(minPrice!=''&&IsNumeric(minPrice)==false){
		document.getElementById('minPrice').focus();
		message=translate_language('Min_price_has_to_be_a_number');	
		alert(message);
		return;
	}
	
	if(maxPrice!=''&&IsNumeric(maxPrice)==false){
		document.getElementById('maxPrice').focus();
		message=translate_language('Max_price_has_to_be_a_number');	
		alert(message);
		return;
	}
	
	if(minPrice!=''&&maxPrice!=''&&parseInt(minPrice)>=parseInt(maxPrice)){
		
		
		message=translate_language('Max_price_has_to_be_a_number');	
		alert(message);
		return;
	}
	
	document.search_form.submit();
	
}

/*
onsubmit for AT and EV
*/

function searchFormSubmitATEV(){
	
	minPrice=document.getElementById('minPrice').value;
	maxPrice=document.getElementById('maxPrice').value;
	
	if(document.getElementById('town').value==""){
		alert(translate_language("You_have_to_select_a_region"));
		return false;
	}
	
	if(minPrice!=''&&IsNumeric(minPrice)==false){
		document.getElementById('minPrice').focus();
		alert(translate_language("Min_price_has_to_be_a_number"));
		return false;
	}
	
	if(maxPrice!=''&&IsNumeric(maxPrice)==false){
		document.getElementById('maxPrice').focus();
		alert(translate_language("Max_price_has_to_be_a_number"));
		return false;
	}
	
	if(minPrice!=''&&maxPrice!=''&&parseInt(minPrice)>=parseInt(maxPrice)){
		
		alert(translate_language("Min price can't be greater than max price"));
		return false;
	}
	document.search_form.submit();
}


function searchResultBookItHandler(pid,cid){

	//alert(pid+"^"+cid);
	window.location="detail.php?pid="+pid+"&cid="+cid+"&startDate="+document.getElementById('startDate').value;

}


function activitySearchResultBookItHandler(pid){

	//alert(pid+"^"+cid);
	window.location="detail.php?pid="+pid+"&mode=AT&startDate="+document.getElementById('startDate').value;

}

function tourSearchResultBookItHandler(pid){

	//alert(pid+"^"+cid);
	window.location="detail.php?pid="+pid+"&mode=EV&startDate="+document.getElementById('startDate').value;

}




function detailPageBookItHandler(pid){
    
	var mode=document.getElementById('mode').value;
	var startDate=document.getElementById('startDate').value;
	if(mode=='AM'){
	window.location="room_booking.php?pid="+pid+"&startDate="+startDate+"&ptype="+mode;
	}
	else{
		window.location="activity_booking.php?pid="+pid+"&startDate="+startDate+"&ptype="+mode;
	}

}



function searchResultGoTo(mode){

	 //alert(mode);
	 if(mode=='nextWeek'){

	 	document.getElementById('startDate').value=document.getElementById('nextWeek').value; 	
	 }
	  if(mode=='previousWeek'){

	  	document.getElementById('startDate').value=document.getElementById('previousWeek').value;

	 }
	 
	 document.navigateSearchResult.submit();
	//alert(startDate);
	//window.location="accomm.php?startDate="+startDate+"&region="+town;
	

}

function searchResultActivityGoTo(mode){
	
//	alert(123);
	 if(mode=='nextWeek'){

	 	document.getElementById('startDate').value=document.getElementById('nextWeek').value; 	
	 }
	  if(mode=='previousWeek'){

	  	document.getElementById('startDate').value=document.getElementById('previousWeek').value;

	 }
	 
	 document.navigateSearchResultActivity.submit();
	
/*
	minPrice=document.getElementById('minPrice').value;
	maxPrice=document.getElementById('maxPrice').value;
	window.location="activity.php?startDate="+startDate+"&region="+town+"&minPrice="+minPrice+"&maxPrice="+maxPrice;*/

}

function searchResultTourGoTo(mode){
	
	 if(mode=='nextWeek'){

	 	document.getElementById('startDate').value=document.getElementById('nextWeek').value; 	
	 }
	  if(mode=='previousWeek'){

	  	document.getElementById('startDate').value=document.getElementById('previousWeek').value;

	 }
	 
	 document.navigateSearchResultTour.submit();
}

/*function searchResultTourGoTo(startDate,town){

	//alert(startDate);
	minPrice=document.getElementById('minPrice').value;
	maxPrice=document.getElementById('maxPrice').value;
	window.location="tour.php?startDate="+startDate+"&region="+town+"&minPrice="+minPrice+"&maxPrice="+maxPrice;


}*/


//function void(){return null;}


function checkOutDetailsGoTo(startDate,pid,mode){

	//alert(startDate);
	window.location="detail.php?startDate="+startDate+"&pid="+pid+"&mode="+mode;

}



function productDetailHandler(id){



	TRID='TR'+id;
	ButtonID='button'+id;

	if(document.getElementById(TRID).style.display==''){

		document.getElementById(TRID).style.display='none';
		document.getElementById(ButtonID).className='static_button info';

	}
	else{

		document.getElementById(TRID).style.display='';
		document.getElementById(ButtonID).className='static_button info_open';
	}

}

function businessDetailHandler(){
	
	
	if(document.getElementById('businessDetail').style.display==''){

		document.getElementById('businessDetail').style.display='none';
		document.getElementById('col1').style.display='none';
		document.getElementById('BTbusinessDetails').className='static_button info_bDetail';

	}
	else{

		document.getElementById('businessDetail').style.display='';
		document.getElementById('col1').style.display='';
		document.getElementById('BTbusinessDetails').className='static_button info_bDetail_open';
	}
}

function iniCheckOutdetails(){

//	load('-33.831867','151.198173');
	
	/*
	alert(document.getElementById('pid').value);
	TRID='TR'+document.getElementById('pid').value;
	alert(TRID);
	document.getElementById(TRID).style.displau='inline';
	*/
}

  var originalCellClass;  // keep track of the orginal class of a cell highlighted
  var thID;   // keep track of the id of the frist left cell highlighted


/** Cell highlight functions Start **/
  var popupShow='N';
 
  function highlightpricingHandler(obj,id){
   
//  	alert(123);
	document.body.style.cursor='hand';
  	
  	//if(popupShow=='N'){
	originalCellClass=obj.className;
	
	splitString=id.split('^');
	
	rowID=splitString[2];
	//alert(rowID);
	
	thID='th'+rowID;
	
	document.getElementById(thID).style.background='#99FFFF';
	//originalTdClass=document.getElementById(thID).className
	
	obj.className = 'pricinghover';
	
	//alert(obj.id);
	if(document.getElementById('cellHighlighted'))
	document.getElementById('cellHighlighted').value=obj.id;
	
  	//}
	

}

  function highlightpricingHandlerTourPRE(obj,id){
   

  	//if(popupShow=='N'){
	originalCellClass=obj.className;
	
	splitString=id.split('^');
	
	rowID=splitString[1];
	//alert(rowID);
	
	thID='thPRE'+rowID;
	//alert(thID);
	
	document.getElementById(thID).style.background='#99FFFF';
	originalTdClass=document.getElementById(thID).className
	
	obj.className = 'pricinghover';
	
	//alert(obj.id);
	//document.getElementById('cellHighlighted').value=obj.id;
	
  	//}
	

}

  function unhighlightpricingHandlerTourPRE(obj){
   

	
	obj.className = originalCellClass;
	document.getElementById(thID).style.background='white';
	
  	//}
}  

  function highlightpricingHandlerTour(obj,id){
   

  	//if(popupShow=='N'){
	originalCellClass=obj.className;
	
	splitString=id.split('^');
	
	rowID=splitString[1];
	//alert(rowID);
	
	thID='th'+rowID;
	//alert(thID);
	
	document.getElementById(thID).style.background='#99FFFF';
	originalTdClass=document.getElementById(thID).className
	
	obj.className = 'pricinghover';
	
	//alert(obj.id);
	//document.getElementById('cellHighlighted').value=obj.id;
	
  	//}
	

}

/*
Onblur handler for min and max price field on search page
*/

/*function priceOnBlur(value,mode){
	
	maxPrice=document.getElementById('maxPrice').value;
	minPrice=document.getElementById('minPrice').value;
	
	if(mode=='min'){
			
		if(minPrice==''){
			return false;
		}
		else if(minPrice>=maxPrice){
			alert('Min price can\'t greater than max price');
			return false;
		}
		else{
			advanceSearchAjaxUpdator();
		}
	}
	}
*/




/*
  To update region list and category list (Activity and Tour only) When field in advanced search changes
*/

function advanceSearchAjaxUpdator(country,region, hotFlag){
	document.getElementById('currency_long_name').firstChild.data = document.getElementById('currency').options[document.getElementById('currency').selectedIndex].firstChild.data;

/* check whether currency is selected*/
	if(document.getElementById('currency').value==""&&country==''){
		//alert(sessionLanguage);
		message=translate_language('You_have_to_select_a_currency');	
		alert(message);
		return false;
	}
//	alert(country+region);
	var main=document.getElementById('mode').value;
	var allFields=new Array();
	var queryString='';
	var allFieldsValue=new Array();
		allFields[0]="country";
		allFields[1]="town";
		allFields[2]="category";
		allFields[3]="StartDate";
		allFields[4]="keyword";
		allFields[5]="minPrice";
		allFields[6]="maxPrice";
		allFields[7]="startRating";
		allFields[8]="roomType";
		allFields[9]="selectedFeatures";
		allFields[10]="selectedFeatureTypes";
		allFields[11]="currency";
	
/* Accommodation	*/
   if(main==''){
     	for(i=0;i<allFields.length;i++){
            
            /* skip product category */
     		 if(i!=2){
	     		/*refine search*/
	            if(country!='' && i==0){
	            		allFieldsValue[i]=country;
	            }else if(country!=''&&i==1){
	            		allFieldsValue[i]=region;
	            }else{ /*	normal search */
	            		//alert(allFields[i]);
		     					allFieldsValue[i]=document.getElementById(allFields[i]).value;
	            }
		            queryString=queryString+'&'+allFields[i]+'='+allFieldsValue[i];
     		}
     	}
            /* Validation */
	         if(allFieldsValue[5]!=''&&IsNumeric(allFieldsValue[5])==false){
			
			 message=translate_language('Min_price_has_to_be_a_number');	
		     alert(message);
			  return false;
			}
			
			if(allFieldsValue[6]!=''&&IsNumeric(allFieldsValue[6])==false){
				
		
				message=translate_language('Max_price_has_to_be_a_number');	
		        alert(message);
				return false;
			}
			
	     	 if(allFieldsValue[5]!=''&&allFieldsValue[6]!=''&&parseInt(allFieldsValue[5])>=parseInt(allFieldsValue[6])){
         //	   	        alert(allFieldsValue[5]+allFieldsValue[6]);
	 
	     		message=translate_language('Min_price_cannot_greater_than_max_price');	
		        alert(message);
				return false;
	         }
   	
   }
/* Activity and Tour */
   else{
//   	    alert(country);
   	   for(i=0;i<allFields.length;i++){
           /* skip the accommodation specific fields */
   	    	if(i!=7&&i!=8&&i!=9&&i!=10){
   	    	
                //get the formatted category from the gloable variable
   	    		if(i==2){
   	    			if(selectedCategories!=''&&refineSearch=='Y'){
   	    				allFieldsValue[i]=selectedCategories;
   	    				refineSearch='N';  //reset the flag. only need to preselect once (restore the selections).
   	    			}
   	    			else{
   	    				allFieldsValue[i]=getSelectedCategories();
   	    			}
   	    			
   	    			queryString=queryString+'&'+allFields[i]+'='+allFieldsValue[i];
   	    			continue;
   	    		}
   	    			/*refine search*/
	            if(country!=''&&i==0){
	            		allFieldsValue[i]=country;
	            }
	            else if(country!=''&&i==1){
	            	
	            		allFieldsValue[i]=region;
	            }
	            else{
   	    		        allFieldsValue[i]=document.getElementById(allFields[i]).value;
	            }
   	    		queryString=queryString+'&'+allFields[i]+'='+allFieldsValue[i];
   	    	}
   	    }
      
         /*	User entry point */
         
	   	    queryString=queryString+'&userEntryPoint='+userEntryPoint;
   	    
   	     /* Validation */
	         if(allFieldsValue[5]!=''&&IsNumeric(allFieldsValue[5])==false){
			
			 alert(translate_language("Min_price_has_to_be_a_number"));
			  return false;
			}
			
			if(allFieldsValue[6]!=''&&IsNumeric(allFieldsValue[6])==false){
				
				alert(translate_language("Max_price_has_to_be_a_number"));
				return false;
			}
			
	     	 if(allFieldsValue[5]!=''&&allFieldsValue[6]!=''&&parseInt(allFieldsValue[5])>=parseInt(allFieldsValue[6])){
	     		alert(translate_language('Min_price_cannot_greater_than_max_price'));
				return false;
	         }
   	
   }
  
   
//   alert(queryString);
	
var url="ajax_search.php?mode=advancedSearchUpdate&main="+main+queryString;
//alert(url);
if(country==''){
   showLoadingImageDo('');
}
if (hotFlag==1){hotterOffer=1;}
ajax_action_front(url,'searchPanelTop');

}
var hotterOffer = 0;

function hotoffer_onChange(){
	hotterOffer = 0;
	var country=document.getElementById('country').value;
	var main=document.getElementById('mode').value;
	var region=document.getElementById('town').value;
	var regionType = '';
	var myDropdownList = document.search_form.region;
	if(myDropdownList){
		// Loop through all the items
		for (iLoop = 0; iLoop< myDropdownList.options.length; iLoop++){
			if (myDropdownList.options[iLoop].selected == true){
				// Item is found. Set its selected property, and exit the loop
				regionType=myDropdownList.options[iLoop].id;
			}
		}
	}
	var currentRegion=document.getElementById('selectedRegion').value;
	var currentRegionType=document.getElementById('currentRegionType').value
	if(regionType=='all' || regionType==''){
		var url="ajax_search.php?mode=show_hot_offer&main="+main+"&country="+country+"&hotterOfferRefresh=1";
	}else{
		var url="ajax_search.php?mode=show_hot_offer&main="+main+"&region="+region+"&regionType="+regionType+"&currentRegion="+currentRegion+"&currentRegionType="+currentRegionType+"&hotterOfferRefresh=1";
	}
	document.getElementById('selectedRegion').value=region;
	document.getElementById('currentRegionType').value=regionType;
	ajax_action_front(url,'hotOfferList');
}


/*
return selected category names in a string dilimited by ','
*/

function getSelectedCategoryInString(){
	
	 category=document.getElementById('category');
						  	
			  	var numSelected=0;
			  	var categoryList='';
			
			  	for (iLoop = 0; iLoop< category.length; iLoop++)
				{
					if (category.options[iLoop].selected == true)
					{
						
					    categoryList+=","+category.options[iLoop].value+"";
						numSelected++;
					}
				}
				
			   categoryList=categoryList.substring(1);  
			   return categoryList;
	
}

/*
 change date in the search page
*/

 function calendarDateChange(startDate){
 	
//     alert(startDate);
	 var country=document.getElementById('country').value;
	 var region=document.getElementById('town').value;
	 var main=document.getElementById('mode').value;
 
	/* Accommodation	 */ 
	 if(main==''){
	 	
	 	advanceSearchAjaxUpdator('','');
	 	/*var url="ajax_search.php?mode=country&main="+main+"&startDate="+startDate+"&id="+country+"&region="+region;
		ajax_action_front(url,'searchPanelTop');*/
	 	
	 }
   /* Activity and Tour	 */
	 else{
			 advanceSearchAjaxUpdator('','');
	 	  
//	 	  category=document.getElementById('category');
//			 type=document.getElementById('currentRegionType').value;
//		//	 alert(type);
//						  	
//			  	var numSelected=0;
//			  	var categoryList='';
//			
//			  	for (iLoop = 0; iLoop< category.length; iLoop++)
//				{
//					if (category.options[iLoop].selected == true)
//					{
//						
//					    categoryList+=",'"+category.options[iLoop].value+"'";
//						numSelected++;
//					}
//				}
//				
//			   categoryList=categoryList.substring(1);  //format categoryList
//			   
////		 	   alert(country+'^'+region+'^'+categoryList+'^'+userEntryPoint);
//		 	   
//		/*  Only country is selected */
//		
//		 	   if(country!=''&&region==''&&categoryList==''){
//		 	   	
//		 	  	var url="ajax_search.php?mode=country&main="+main+"&startDate="+startDate+"&id="+country;
//		        ajax_action_front(url,'searchPanelTop');
//		 	   	
//		 	   }
//		/*   country and region are selected */ 	   
//		 	   if(country!=''&&region!=''&&categoryList==''){
//		 	   	
//		 	  	var url="ajax_search.php?mode=show_category_list&country="+country+"&region="+region+"&type="+type+"&main="+main+"&startDate="+startDate;
//		        ajax_action_front(url,'searchPanelTop');
//		 	   	
//		 	   }
//		 /*   country and category are selected */ 	   
//		 	    if(country!=''&&region==''&&categoryList!=''){
//		 	   	
//		 	  	var url="ajax_search.php?mode=update_region_list&country="+country+"&startDate="+startDate+"&main="+main+"&category="+categoryList;
//		        ajax_action_front(url,'searchPanelTop');
//		 	   	
//		 	   }
//		  /*   country , category and region are ALL selected */ 		   
//		 	   
//		 	    if(country!=''&&region!=''&&categoryList!=''){
//		 	   	
//		 	    	if(userEntryPoint=='region'){
//		 	    		 var url="ajax_search.php?mode=show_category_list&country="+country+"&region="+region+"&type="+type+"&main="+main+"&startDate="+startDate;
//		                 ajax_action_front(url,'searchPanelTop');
//		 	    	}
//		 	    	 
//		 	    	if(userEntryPoint=='category'){
//		 	    		var url="ajax_search.php?mode=update_region_list&country="+country+"&startDate="+startDate+"&main="+main+"&category="+categoryList;
//		                ajax_action_front(url,'searchPanelTop');
//		 	    	}
//		 	 
//		 	   	
//		 	   }
 	   
	 }
 	   
 }


var selectedCategories='';   //selected product categories
 
/*
For single category selection
*/
  function categoryUpdate(value,e){
  	
  	  //alert('eliot'+userEntryPoint);
      
  	displaySlideShow();
    if(userEntryPoint==''){
    	
    	userEntryPoint='category';
    }
  	
	  	if (!e) {   //IE
	  		var e = window.event;
	  	}
	  	
	  	 	
	/*
	Don't do anything if ctrl is pressed    
	*/
	  	if(e.ctrlKey||e.shiftKey){
	  		return;
	  	}
	
	  	///show loading image
	   if(showLoadingImage=='Y'){
	   	  showLoadingImageDo('searchPanelTop');
	   }

	  	startDate=document.getElementById('StartDate').value;
	  	country=document.getElementById('country').value;
	  	main=document.getElementById('mode').value;
	  	//category="'"+value+"'";   //in special format for select IN 
	  	category=value;   //in special format for select IN 
	  	selectedCategories=category;
//	  	alert(selectedCategories);
	  	
	  	advanceSearchAjaxUpdator('','');
	  	
	    /*var url="ajax_search.php?mode=update_region_list&country="+country+"&startDate="+startDate+"&main="+main+"&category="+category;
	    ajax_action_front(url,'searchPanelTop');*/
	  
  	
  }
  
/* 
  check the key pressed when selecting categories, set flag ctrlShiftPressed to Y if key pressed is ctrl or shift
*/
  
 var ctrlShiftPressed='N';  
  
 function keyDown(e){
  	
		  	ctrlShiftPressed='N';
		  	
		  	if (!e) {   //IE
		  		var e = window.event;
		  	}
		  	
		//  	/alert(e.keyCode);
		  	if(e.keyCode=='17'||e.keyCode=='16'){
		  		
		  		ctrlShiftPressed='Y';
		  	}
  	
  }
 
 
 /*
  For multiple category selection
*/
  function multiCategoriesUpdate(e){
  	
  	      // alert('eliot'+userEntryPoint);
    
		    if(userEntryPoint==''){
		    	
		    	userEntryPoint='category';
		    }
  	   
  	     startDate=document.getElementById('StartDate').value;
  	     country=document.getElementById('country').value;
	     main=document.getElementById('mode').value;
  
		  	//only do stuff if alt or ctrl was pressed
		  if (ctrlShiftPressed=='Y'){
//		  		alert('go');
		  	 
		  		    	///show loading image
					   if(showLoadingImage=='Y'){
					   	  showLoadingImageDo('searchPanelTop');
					   }
//				  	category=document.getElementById('category');
				  	
//				  	var numSelected=0;
				  	var categoryList='';
				
				  	     categoryList=getSelectedCategories();
						  	
						//make Ajax call
						selectedCategories=categoryList;
					    advanceSearchAjaxUpdator('','');
					    /*var url="ajax_search.php?mode=update_region_list&country="+country+"&startDate="+startDate+"&main="+main+"&category="+categoryList;
			
			            ajax_action_front(url,'searchPanelTop');*/
			}
  }

/*  
 get selectedCategories and put them in an string for IN Clause
*/
  function getSelectedCategories(){
  	
  	    var categoryList='';
  	  	category=document.getElementById('category');
  	  	var numSelected=0;
  	    for (iLoop = 0; iLoop< category.length; iLoop++)
						{
							if (category.options[iLoop].selected == true)
							{
								
								
								categoryList+=","+category.options[iLoop].value+"";
								numSelected++;
							}
						}
//						alert(numSelected);
						
							if(numSelected>0){
								
								categoryList=categoryList.substring(1);
//								alert(categoryList);
							}
						
	  return categoryList
  }
  
  
  function unhighlightpricingHandlerTour(obj){
   

	
	obj.className = originalCellClass;
	document.getElementById(thID).style.background='white';
	
  	//}
}  
  
  function unhighlightpricingHandler(obj){
   
	//if popup is showing, set the flag to stop highlighting other cells
	
  	//if(document.getElementById('activityDetails')||document.getElementById('accommDetails'))
  	//{
  		//popupShow='Y';  
  	//}
  	//else{
	document.body.style.cursor = 'default';
	obj.className = originalCellClass;
	document.getElementById(thID).style.background='white';
	
  	//}
}

/** Cell highlight functions End **/




var productID;
var childAjaxState=0;
var firstPictureID;   //the image user clicked on

function showAccomDetailsHandler(el,id) {

	//if no popup is showing
	//if(popupShow=='N'){
	
		splitstring = id.split("^");
		
		document.getElementById('startDate').value=splitstring[1];
		
	
		pid=splitstring[0];
		//date=splitstring[1];
	
	
		//changeto(tdID,'#FFCCCC');
	
		var url="ajax_search.php?mode=show_AM_detail&pid="+pid;
	
	
		//alert(startDate);
	
		//Close previously opened window
		xpFloatStopNew('accommDetails');
	
		ajax_action(el,url,300,45,'accommDetails','pic');
	
		//numberOfFeatures=document.getElementById('number_of_features');
	
		//alert(numberOfFeatures);
		productID=pid;
		startId=1;
	
		
}





function slideShowProduct(el,id,firstID) {

	
		var pid=id;
	
	
		var url="ajax_search.php?mode=product_slideshow&pid="+pid;
	
	
		//alert(startDate);
	
		//Close previously opened window
		xpFloatStopNew('businessSlideShow');
		xpFloatStopNew('productSlideShow');
	
		ajax_action(el,url,145,25,'productSlideShow','slideshow');
	

		productID=pid;
		startId=1;
		firstPictureID=firstID;
	
	
}


function slideShowBusiness(el,id,firstID) {

	    //alert(id+'*'+firstPictureID);
	
		var pid=id;
	
	      /////////////////////////////////////////pid is actually cid in this case
		var url="ajax_search.php?mode=business_slideshow&cid="+pid;
	
	
		//Close previously opened window
	
		xpFloatStopNew('productSlideShow');
		xpFloatStopNew('businessSlideShow');
	
		ajax_action(el,url,145,25,'businessSlideShow','slideshowBusiness');
	

		productID=pid;
		startId=1;
		firstPictureID=firstID;
	
	
}





function showActivityDetailsHandler(el,data) {

	//tdID='td'+date;
	


	splitstring = data.split("^");

	pid=splitstring[0];
	date=splitstring[1];
    document.getElementById('startDate').value=date;


	var url="ajax_search.php?mode=show_AT_detail&pid="+pid+"&date="+date;


	//alert(url);
	xpFloatStopNew('activityDetails');

	ajax_action(el,url,300,45,'activityDetails','pic');

	//numberOfFeatures=document.getElementById('number_of_features');

	//alert(numberOfFeatures);
	productID=pid;
	startId=1;

	//delay the execution to wait for responseTEXT
	//setTimeout("showIndexPic(productID);",400);
}

function reloadIframe(id){
	
//	alert(id);
	var f = document.getElementById(id);
    f.src = f.src;
}

function showTourDetailsHandler(el,data) {

	//alert(data);

	splitstring = data.split("^");

	pid=splitstring[3];
	date=splitstring[1];
	sid=splitstring[0];

	var url="ajax_search.php?mode=show_EV_detail&pid="+pid+"&date="+date+"&sessionid="+sid;
	//alert(url);


	//alert(url);
	xpFloatStopNew('tourDetails');

	ajax_action(el,url,300,45,'tourDetails','pic');

	
	productID=pid;
	startId=1;

}

////////////////////////////////////////////////////Ajax Start//////////////////////////////////////////////////////////////////////////////////
var xmlHttp;
//var globalDIV;
var CurrentPopUpDIvUser;




function ajax_action_front(url,div) {

	CurrentPopUpDIvUser=div;

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert (translate_language("Browser_does_not_support_HTTP_Request"));
		return;
	}

	url=url+"&sid="+Math.random();



	xmlHttp.onreadystatechange=stateChangedFront
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

var collapse2;  //global for expand and collapse the advance search panel
var reloadIframeBool='N'; //the flag indicates whether the reload is needed for image and video slideshow on the home page

function stateChangedFront()
{

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
        /* Put this on the top so that the slideshow reloads regardless the needs for the hot offer list */
		if(document.getElementById('flashSlideShow')&&reloadIframeBool=='Y'){
           
			reloadIframe('flashSlideShow');	
	        reloadIframe('youtubeSlideShow');	
	        reloadIframeBool='N';   //reset the flag
		}

		// When the refresh of hot offer list is not necessary
		if(xmlHttp.responseText.substr(0,8)=='noReload'){
		
			var country=document.getElementById('country').value;
			var type=document.getElementById('currentRegionType').value;
			var region=document.getElementById('selectedRegion').value;
			var main=document.getElementById('mode').value;
			
			// don't show categorylist when mode is accommodation
			  if(document.getElementById('mode').value!=''){
			
				   // var url="ajax_search.php?mode=show_category_list&country="+country+"&region="+region+"&type="+type+"&main="+main;
				   // alert(url);
				   // ajax_action_front(url,'searchPanelTop');
				    
			  }
			//return;
		}else{
			document.getElementById(CurrentPopUpDIvUser).innerHTML=xmlHttp.responseText;
		}
		
		if (hotterOffer==1 && document.getElementById('mode').value!="AT" && document.getElementById('mode').value!="EV"){
			region_onChange();
		}else if (hotterOffer==1 && (document.getElementById('mode').value=="AT" || document.getElementById('mode').value=="EV")){
			hotoffer_onChange();
		}
		if(multipleAjax=='index.php'){
	          //alert(currentURL);
				ajax_action_users(currentURL,'hotOfferList');
				multipleAjax='';
				
				main=document.getElementById('mode').value;
			//if mode is AM	
				if(main==''){
					
				//####  advanced search panel
				// status is defined in animatedcollapse.js  
			    //inistantiate the object for expand and collapse the advance search panel
			         /*if(status=='up'){
			          collapse2=new animatedcollapse("advanceSearchPanel", 400, false,'contract'); 
			          hideMoreOptions();
			         }
			         else if(status=='down'){
			         collapse2=new animatedcollapse("advanceSearchPanel", 400, false,'block');
			         showMoreOptions();
			         }
			         else
			         collapse2=new animatedcollapse("advanceSearchPanel", 400, false,'contract');*/
			          //collapse2=new animatedcollapse("advanceSearchPanel", 400, false,'contract');
			      
				}
				else{
				
					if(status=='up'){
			          collapse3=new animatedcollapse("advanceSearchPanel", 200, false,'contract'); 
			          hideMoreOptions();
			         }
			         else if(status=='down'){
			         collapse3=new animatedcollapse("advanceSearchPanel", 200, false,'block');
			         showMoreOptions();
			         }
			         else
			         collapse3=new animatedcollapse("advanceSearchPanel", 200, false,'contract');
				}
				
				 populateEndDate();  // populate the end date upon on the selection of startDate
				 relocateRegion();
		}
		
		if(multipleAjax=='show_avail_product'){
	      
			
			country=document.getElementById('country').value;
			type=document.getElementById('currentRegionType').value;
			region=document.getElementById('selectedRegion').value;	
			main=document.getElementById('mode').value;
			startDate=document.getElementById('StartDate').value;
			
			  
			advanceSearchAjaxUpdator('','');
			
//		    var url="ajax_search.php?mode=show_category_list&country="+country+"&region="+region+"&type="+type+"&main="+main+"&startDate="+startDate;
		    var url='';
           
		   selectedCategory=document.getElementById('category').value;
		   
		   //alert(selectedCategory);
		   
           /* Only reload the list if there is no category selected		   */
		   if(selectedCategory==''||(selectedCategory!=''&&userEntryPoint=='region')){
		 
		   	 ///show loading image
			   if(showLoadingImage=='Y'){
			   	  showLoadingImageDo('searchPanelTop');
			   }
			   if(url!=''){
		   	       ajax_action_front(url,'searchPanelTop');
			   }
		    
		   }
		   
		    multipleAjax='activeAdvanceSearchPanel';
			
		}
         if(multipleAjax=='activeAdvanceSearchPanel'){
		          ///for AT EV 
                     if(status=='up'){
			          collapse3=new animatedcollapse("advanceSearchPanel", 200, false,'contract'); 
			          hideMoreOptions();
			         }
			         else if(status=='down'){
			         collapse3=new animatedcollapse("advanceSearchPanel", 200, false,'block');
			         showMoreOptions();
			         }
			         else{
			         	 
			         collapse3=new animatedcollapse("advanceSearchPanel", 200, false,'contract');
			         } 
           
         }
 		 
		if (document.getElementById('flashSlideShow')){
			document.getElementById('flashSlideShow').src='slideshow/slideshow.html';
		}
		if (document.getElementById('youtubeSlideShow')){
			document.getElementById('youtubeSlideShow').src='video_slideshow.php';
		}
		
         if(ajax_command_array.length > 0) {eval(ajax_command_array.shift());}
         
	}
}
////////////////////////////////////////////////////ajax User End//////////////////////////////////////////////////////////////////////////////////
//###################################################### SlideShow start###################################################################################



//alert(numberOfFeatures);

var refreshSec = 5;   //time interval
var newsNum;   //num of images
var startId = 1;   //start from
var firstSlide;   //indicate whether this is the first slide

function changePic(id,pid) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert (translate_language("Browser_does_not_support_HTTP_Request"));
		return;
	}
	var tourl = "slideshow.php?action="+ajax_action_mode+"&pictureid="+id+"&pid="+pid+"&firstPictureID="+firstPictureID+"&firstSlide="+firstSlide;
	
	firstSlide='N';  //reset firstPictureID
 

	xmlHttp.onreadystatechange=handleRequest
	xmlHttp.open("GET",tourl,true);
	xmlHttp.send(null);

    newsNumOBJ=document.getElementById('number_of_features');
	if(newsNumOBJ)
	newsNum=newsNumOBJ.value;

	
	var numNavi = "";
	/*This is to show the number navigation bar
	
	for (i = 1; i <= newsNum; i++) {
		if (i == id) {
			numNavi += " <a href=\"javascript:void(0)\" onClick=\"changePic(" + i +"," + pid +")\"><span id=\"num" + i + "\" class=\"numnavi\">" + i + "</span></a>";
		} else {
			numNavi += " <a href=\"javascript:void(0)\" onClick=\"changePic(" + i +"," + pid +")\"><span id=\"num" + i + "\" class=\"numnavilink\">" + i + "</span></a>";
		}
	}*/
	//alert(newsNum);
	
	PRE=translate('PRE');	
	NEXT=translate('NEXT');
	
	if(id!=1){
		numNavi += " <a href=\"javascript:void(0)\" onClick=\"changePic(" + (id-1) +"," + pid +")\"><span id=\"num\" class=\"numnavi\">"+PRE+"</span></a>";
	}else{
		numNavi += " <span id=\"num\" class=\"numnavi disabled\">"+PRE+"</span> ";
	}
    if(id<newsNum){
    	numNavi += " <a href=\"javascript:void(0)\" onClick=\"changePic(" + (id+1) +"," + pid +")\"><span id=\"num\" class=\"numnavi\">"+NEXT+"</span></a>";
    }else{
    	numNavi += " <span id=\"num\" class=\"numnavi disabled\">"+NEXT+"</span>";
    }
	document.getElementById("newsnavi").innerHTML = numNavi;
   
 }


function showIndexPic(pid) {
	//alert(productID+startId+newsNum);

	firstSlide='Y';
	var refreshTime = refreshSec * 1000;
	changePic(startId,pid);
	startId ++;
	 

	startId = (startId > newsNum) ? 1 : startId;
	
	if (refreshTime == 1) {
		changePic(startId,pid);
	}
	//problem with enabling auto switch: sometime can't get number_of_features.  The solutions to this might be 
	//get the number_of_features when the page is loaded and pass it to ajax_search as a parameter
	/*else {
		//comment this out to stop auto switch
		window.setTimeout("showIndexPic(productID)", refreshTime);
	}
	*/
	
}

function handleRequest() {
	if (xmlHttp.readyState == 4) {
		childAjaxState=4;
		//alert(123);
		if (xmlHttp.status == 200) {
			//alert(nds[1].firstChild.nodeValue);
			var nds = xmlHttp.responseXML.documentElement.firstChild.childNodes;
			var picId = 0;
			var contents = '';
			if (nds[2].firstChild){picId = nds[2].firstChild.nodeValue;}
			if (nds[0].firstChild){contents = nds[0].firstChild.nodeValue;}
			//document.getElementById('indexpic').innerHTML = "<a href=\"" + nds[1].firstChild.nodeValue + "\"><img id=\"showpic\" src=\"resize.php?mode="+ajax_action_mode+"&pic="+ picId + "\" border=\"0\"></a>";
			document.getElementById('indexpic').innerHTML = "<img id=\"showpic\" src=\"resize.php?mode="+ajax_action_mode+"&pic="+ picId + "\" border=\"0\">";
			//document.getElementById('indexpic').innerHTML = "<a href=\"" + nds[1].firstChild.nodeValue + "\" target=\"_blank\"><img id=\"showpic\" src=\"" + nds[2].firstChild.nodeValue + "\" width=\"425\" height=\"100\" border=\"0\"></a>";
			//document.getElementById('indexpicnews').innerHTML = "<a href=\"" + nds[1].firstChild.nodeValue + "\" target=\"_blank\">" + nds[0].firstChild.nodeValue + "</a>";
			document.getElementById('indexpicnews').innerHTML = contents;
		}
	}
}
function slide_menu(DisplayId, HiddenId, LinkHidId, LinkDisId){
	document.getElementById(DisplayId).style.display = "";
	document.getElementById(HiddenId).style.display = "none";
	document.getElementById(LinkHidId).style.backgroundPosition = "0 -26px";
	document.getElementById(LinkDisId).style.backgroundPosition = "0 0";
}

// Cross-browser implementation of element.addEventListener()
function addListener(element, type, expression, bubbling){
	var bubbling = bubbling || false;
	if(window.addEventListener) { // Standard
		element.addEventListener(type, expression, bubbling);
		return true;
	}else if(window.attachEvent) { // IE
		element.attachEvent('on' + type, expression);
		return true;
	}else return false;
}

function fnSampleResult(form){
	var startMin = newParseInt(form.HH.value) * 60 + newParseInt(form.MM.value) + (form.AM_PM.value=='PM'?12*60:0);
	var lengthMin = newParseInt(form.L_DD.value) * 24 * 60 + newParseInt(form.L_HH.value) * 60 + newParseInt(form.L_MM.value);
	var endMin = startMin + lengthMin;
	var endDay = Math.floor(endMin/60/24)+1;
	var endHour = Math.floor(endMin%(60*24)/60);
	var endMin = endMin%60;
	var endHourStatus = endHour<13?'AM':'PM';
	endHour = endHour<13?endHour:(endHour-12);
	
	var dayArray = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
	var endDayName = dayArray[ endDay % 7 ];
	
	var txtStart = 'Day 1, Monday '+form.HH.value+':'+form.MM.value+' '+form.AM_PM.value;
	
	var txtEnd = 'Day '+endDay+', ' + endDayName + ' ' + (endHour.toString().length<2?'0'+endHour.toString():endHour)+':'+(endMin.toString().length<2?'0'+endMin.toString():endMin)+' '+endHourStatus;
	 document.getElementById('sample_result').innerHTML = txtStart + ' to ' + txtEnd;
}

function newParseInt(val) {
	if (val == '08') return 8;
	if (val == '09') return 9;
	return parseInt(val);
}


function relocateRegion(){
	for(var i = 0; i < document.search_form.town.options.length; i++){
		if(document.search_form.selectedRegion.value==document.search_form.town.options[i].value){
			document.search_form.town.selectedIndex = i;
			break;
		}
	}
}


//###################################################### SlideShow end###################################################################################

//###################################################### Front END end#################################################################################################################

	
function confirmDelete(url) {
	if (confirm("Are you sure you want to delete this?")) location.href = url;
}