// JavaScript Document
var xmlhttp

var http_request = false;
//tmp_url = 'http://localhost/ski';
//tmp_url = 'http://testsite.skibid.co.il';
tmp_url = '';


/**********POST FORM VIA AJAX***********/
function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }
function changePoss() {
	
}

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('msg_sent').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
	  else {
		  result = '<div id="over_wrapper"></div><div id="over_overwrapper"><img src="images/spinner.gif"/><a href="javascript:backHP()">popop</a></div>';
		  document.getElementById('msg_sent').innerHTML =result;
			scrOfY = parseInt(getScrollY());
			myHeight = parseInt(getSizeY());
			myWidth = parseInt(getSizeX());
			topLocation = (scrOfY - myHeight - 440)/2;
			rightLocation = (myWidth - 417)/2;
			document.getElementById('over_overwrapper').style.right = rightLocation +'px';
			document.getElementById('over_overwrapper').style.top = topLocation +'px';
	  }
		scrOfY = parseInt(getScrollY());
		myHeight = parseInt(getSizeY());
		myWidth = parseInt(getSizeX());
		topLocation = scrOfY + (myHeight - 440)/2;
		rightLocation = (myWidth - 417)/2;
		document.getElementById('over_overwrapper').style.right = rightLocation +'px';
		document.getElementById('over_overwrapper').style.top = topLocation +'px';
	  
   }

function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}
function getScrollX() {
  var scrOfX = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfX;
}


function getSizeY() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;

}
function getSizeX() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

	function isset(varname){
  		return(typeof(varname)!='undefined');
	}

   function get(obj) {
	   searf1 = '0';
	   if (isset(document.reservation.searf1)) {
		   if(document.reservation.searf1.checked)
		   		searf1 = '1';
	   }
	   searf2 = '0';
	   if (isset(document.reservation.searf2)) {
	  	 if (document.reservation.searf2.checked==true) 
		   searf2 = '1';
	   }
	   searf3 = '0';
	   if (isset(document.reservation.searf3)) {
	   	if (document.reservation.searf3.checked) 
		   searf3 = '1';
	   }
	   
	   rental1 = '0';
	   if (isset(document.reservation.rental1)) {
	   	if (document.reservation.rental1.checked) 
		   rental1 = '1';
	   }
	   rental2 = '0';
	   if (isset(document.reservation.rental2)) {
	   	if (document.reservation.rental2.checked) 
		   rental2 = '1';
	   }
	   transport1 = '0'; 
	   if (isset(document.reservation.transport1)) {
	   	if (document.reservation.transport1.checked) 
		   transport1 = '1';
	   }
	   transport2 = '0'; 
	   if (isset(document.reservation.transport2)) {
	   	if (document.reservation.transport2.checked) 
		   transport2 = '1';
	   }
	   lodge1 = '0';
	   if (isset(document.reservation.lodge1)) {
	   	if (document.reservation.lodge1.checked) 
		   lodge1 = '1';
	   }
	   lodge2 = '0';
	   if (isset(document.reservation.lodge2)) {
	   	if (document.reservation.lodge2.checked) 
		   lodge2 = '1';
	   }
	   lodge3 = '0';
	   if (isset(document.reservation.lodge3)) {
	   	if (document.reservation.lodge3.checked) 
		   lodge3 = '1';
	   }
	   lodge4 = '0';
	   if (isset(document.reservation.lodge4)) {
	   	if (document.reservation.lodge4.checked) 
		   lodge4 = '1';
	   }
	   prefer1 = '0';
	   if (isset(document.reservation.prefer1)) {
	   	if (document.reservation.prefer1.checked) 
		   prefer1 = '1';
	   }
	   prefer2 = '0';
	   if (isset(document.reservation.prefer2)) {
		 if (document.reservation.prefer2.checked) 
		   prefer2 = '1';
	   }
	   prefer3 = '0';
	   if (isset(document.reservation.prefer3)) {
		 if (document.reservation.prefer3.checked)
		   prefer3 = '1';
	   }
	   prefer4 = '0';
	   if (isset(document.reservation.prefer4)) {
		if (document.reservation.prefer4.checked) 
		   prefer4 = '1';
	   }
	   accommodation_level = '0';
	   if (isset(document.reservation.accommodation_level)) {
		   accommodation_level = document.reservation.accommodation_level.value;
	   }
	   accommodation_s = '0';
	   if (isset(document.reservation.accommodation_s)) {
		   accommodation_level = document.reservation.accommodation_s.value;
	   }
	   budjet = '0';
	   if (isset(document.reservation.budjet)) {
		   budjet = document.reservation.budjet.value;
	   }


var poststr = "country=" + escape(encodeURI(document.reservation.country.value))  +
				"&site=" + escape(encodeURI(document.reservation.site.value))+
				"&PUDate=" + escape(encodeURI(document.reservation.PUDate.value)) +
				"&day_count=" + escape(encodeURI(document.reservation.day_count.value)) +
				"&persons=" + escape(encodeURI(document.reservation.persons.value)) +
				"&contact_schedule=" + escape(encodeURI(document.reservation.contact_schedule.value)) +
				"&num_agents=" + escape(encodeURI(document.reservation.num_agents.value)) +
				"&searf1=" + escape(encodeURI(searf1)) +
				"&searf2=" + escape(encodeURI(searf2)) +
				"&searf3=" + escape(encodeURI(searf3)) +
				"&rental1=" + escape(encodeURI(rental1)) +
				"&rental2=" + escape(encodeURI(rental2)) +
				"&transport1=" + escape(encodeURI(transport1)) +
				"&transport2=" + escape(encodeURI(transport2)) +
				"&lodge1=" + escape(encodeURI(lodge1)) +
				"&lodge2=" + escape(encodeURI(lodge2)) +
				"&lodge3=" + escape(encodeURI(lodge3)) +
				"&lodge4=" + escape(encodeURI(lodge4)) +
				"&accommodation_level=" + escape(encodeURI(accommodation_level)) +
				"&accommodation_s=" + escape(encodeURI(accommodation_s)) +
				"&prefer1=" + escape(encodeURI(prefer1)) +
				"&prefer2=" + escape(encodeURI(prefer2)) +
				"&prefer3=" + escape(encodeURI(prefer3)) +
				"&prefer4=" + escape(encodeURI(prefer4)) +
				"&budjet=" + escape(encodeURI(budjet)) +
				"&name=" + escape(encodeURI(document.reservation.name.value)) +
				"&email=" + escape(encodeURI(document.reservation.email.value)) +
				"&phone=" + escape(encodeURI(document.reservation.phone.value)) +
				"&prefix=" + escape(encodeURI(document.reservation.prefix.value));	   
	   
	   
/*		var poststr = "mytextarea1=" + escape(encodeURI(
document.getElementById("mytextarea1").value )) +"&mytextarea2=" +
escape(encodeURI( document.getElementById("mytextarea2").value ));
*/
	makePOSTRequest(tmp_url+'/Scripts/insert_data.php', poststr);
   }
   
/***********DISPLAY RELATED SITES ONLY**************/
function changeSiteVal(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url=tmp_url+"/Scripts/getsite.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function changeSiteValReservationForm(str)
{
	if (str == '10000'){
		//document.getElementById('siteTitle').innerHTML = '<strong>שם מדינה אחרת:</strong>&nbsp;&nbsp;&nbsp;';
		//document.getElementById('sites').innerHTML = '<input type="text" name="OtherCountry" id="OtherCountry"  style="margin:10px 0px;"/>';
		document.getElementById('OtherCountry').style.display = 'inline';
	}
	else {
		//document.getElementById('siteTitle').innerHTML = '<strong>אתר:</strong>&nbsp;&nbsp;&nbsp;';
		document.getElementById('OtherCountry').style.display = 'none';
		
		xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  }
		var url=tmp_url+"/Scripts/getsiteResForm.php";
		url=url+"?q="+str;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=stateChangedRes;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
}



function stateChangedRes()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("sites").innerHTML=xmlhttp.responseText;
  }
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("siteID").innerHTML=xmlhttp.responseText;
  }
}

function changeSiteVal1(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url=tmp_url+"/Scripts/getsite1.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged1;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function changeSiteVal10(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url=tmp_url+"/Scripts/getsite10.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged1;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function changeSiteVal11(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url=tmp_url+"/Scripts/getsite11.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged1;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged1()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("sites1").innerHTML=xmlhttp.responseText;
  }
}

function changeSiteVal2(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url=tmp_url+"/Scripts/getsite2.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function changeSiteValADM(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url=tmp_url+"/Scripts/getsiteAdm.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}


function changeSiteVal3(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url=tmp_url+"/Scripts/getsite3.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function changeSiteVal4(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url=tmp_url+"/Scripts/getsite4.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function changeSiteVal5(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url=tmp_url+"/Scripts/getsite5.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}


function changeSiteValAdmin(id)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url=tmp_url+"/Scripts/getsiteAdmin.php";
	url=url+"?q="+id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChangedGetSiteAdmin;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged2()
{
if (xmlhttp.readyState==4)
  {
//	  alert(xmlhttp.responseText);
  document.getElementById("sites3").innerHTML=xmlhttp.responseText;
  }
}
function stateChangedGetSiteAdmin()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("sites3").innerHTML=xmlhttp.responseText;
  }
}


function searchPriority(p)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
	var url=tmp_url+"/Scripts/searchPriority.php";
		url=url+"?q="+p;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=stateChangedsearchPriority;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
}

function stateChangedsearchPriority()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("SearchResults").innerHTML=xmlhttp.responseText;
  }
}



/******* DISPLAY OTHER OPTIONS   *******/
function displayOtherOpt(dis)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
	var url=tmp_url+"/Scripts/other_options1.php";
		url=url+"?q="+dis;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=stateChangedOtherOpt;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	  	chance_display(dis);

}

function stateChangedOtherOpt()
{
	if (xmlhttp.readyState==4)
	  {
	  document.getElementById("other_options").innerHTML=xmlhttp.responseText;
	  }
}

/*function CountCheck(){
	var chkCnt = 0;
	var Frm = document.forms['reservation']; // or name where the first form is 0
	var dLen = Frm.length - 1;
	for (i=0;i<=dLen;i++){
		if (Frm.elements[i] == 'checkbox') {
			chkCnt++;
			if (Frm.elements[i].checked == true)
		}
	}
	return chkCnt;
} 

*/
function saveClick(){
 	
	chkboxArray = new Array();
	var str = '';
	//chkCnt = CountCheck();
	var Frm = document.forms['reservation']; // or name where the first form is 0
	if (Frm.searf1.checked == true) str = str + 'searf1;';
	if (Frm.searf2.checked == true) str = str + 'searf2;';
	if (Frm.searf3.checked == true) str = str + 'searf3;';
	if (Frm.rental1.checked == true) str = str + 'rental1;';
	if (Frm.rental2.checked == true) str = str + 'rental2;';
	if (Frm.transport1.checked == true) str = str + 'transport1;';
	if (Frm.transport2.checked == true) str = str + 'transport2;';
	if (Frm.lodge1.checked == true) str = str + 'lodge1;';
	if (Frm.lodge2.checked == true) str = str + 'lodge2;';
	if (Frm.lodge3.checked == true) str = str + 'lodge3;';
	if (Frm.lodge4.checked == true) str = str + 'lodge4;';
	if (Frm.prefer1.checked == true) str = str + 'prefer1;';
	if (Frm.prefer2.checked == true) str = str + 'prefer2;';
	if (Frm.prefer3.checked == true) str = str + 'prefer3;';
	if (Frm.prefer4.checked == true) str = str + 'prefer4;';
	selObj = Frm.accommodation_s;
	Index = selObj.selectedIndex;
	value = selObj.options[Index].value;
	str = str + '?accommodation_s='+ value +';';
	selObj = Frm.budjet;
	Index = selObj.selectedIndex;
	value = selObj.options[Index].value;
	str = str + '?budjet='+ value +';';
	//alert(str);	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
			var url=tmp_url+"/Scripts/save_MC.php";
			url=url+"?q=" + str;
			url=url+"&sid="+Math.random();
			xmlhttp.onreadystatechange=stateCloseOtherOpt;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
}

function stateCloseOtherOpt() {
	if (xmlhttp.readyState==4)
	  {
	  document.getElementById("other_options").innerHTML=xmlhttp.responseText;
	  }
}

/******* DISPLAY MULTIPLE CHOICE   *******/
function displayMultipleChoice(dis)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
	var url=tmp_url+"/Scripts/multiple_choice.php";
		url=url+"?q="+dis;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=stateChangedMC;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	  	//chance_displayMC(dis);
}


function stateChangedMC()
{
	if (xmlhttp.readyState==4)
	  {
		scrOfY = parseInt(getScrollY());
		myHeight = parseInt(getSizeY());
		myWidth = parseInt(getSizeX());
		topLocation = scrOfY + (myHeight - 400)/2;
		rightLocation = (myWidth - 390)/2-110;
/*		if (scrOfY >0 ) {
			topLocation = 370;
		}
*/		//document.getElementById('over_overwrapper').style.right = rightLocation +'px';
		//document.getElementById('over_overwrapper').style.top = topLocation +'px';
		  
		  
		  
		document.getElementById('multiple_choice').style.display = 'block';
		document.getElementById("multiple_choice").style.position = 'absolute'; 
		document.getElementById("multiple_choice").style.top = topLocation +'px'
		document.getElementById("multiple_choice").style.right= rightLocation +'px'
		document.getElementById("multiple_choice").style.border = '5px solid #474747';
		document.getElementById("multiple_choice").style.color = '#1E4A7B'; 
		document.getElementById("multiple_choice").style.backgroundColor = '#9ed8fb';
		document.getElementById("multiple_choice").innerHTML=xmlhttp.responseText;
	  }
}


function DisableCheckBox(id,count) {
	if (document.getElementById(id).checked == true){
		for (i=1; i<=count;i++){
			elem=id+'-'+i;
			document.getElementById(elem).disabled=true;
		}
	}
	else {
		for (i=1; i<=count;i++){
			elem=id+'-'+i;
			document.getElementById(elem).disabled=false;
		}
	}
		
}

function SaveMultipleSites(c_count,s_count){
		var poststrC = '';
		var poststrS = '';
		var id = 1;
		for (i=1; i<=c_count;i++){
			while (!isset(document.getElementById(id))){
				id++;	
			}
			if (document.getElementById(id).checked)
				poststrC += id +';';
			id++;
		}

		for (i=1; i<=1000;i++){
			name = i + '_s';	
			if (isset(document.getElementsByName(name)[0])){
				boxobj = document.getElementsByName(name)[0];
				if (boxobj.checked == true)
					poststrS += boxobj.value +';';
			}
		}
/* 		if (poststrS != '' && poststrS != null) {
			changeSiteVal('multiple');	
			
		}
*/		xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  }
			var url=tmp_url+"/Scripts/save_MC.php";
				url=url+"?c="+poststrC;
				url=url+"&s="+poststrS;
				url=url+"&sid="+Math.random();
				xmlhttp.onreadystatechange=stateChangedMCExit;
				xmlhttp.open("GET",url,true);
				xmlhttp.send(null);

}

function exitMC(){
	document.getElementById('multiple_choice').style.display = 'none';
}

function stateChangedMCExit(){
	if (xmlhttp.readyState==4)
	  {
		document.getElementById('multiple_choice').style.display = 'none';
		str = xmlhttp.responseText;
		IndexOfS = str.indexOf('<select');
		//alert(str);
		//alert(chkResponse);
		if (IndexOfS != -1){
			IndexOfE = 	str.indexOf('</select><br>');
			if (IndexOfE != -1) {
				IndexOfE = IndexOfE +13;	
				Response1 = str.substring(IndexOfS,IndexOfE);
				//alert (Response1);
				str = str.substring(IndexOfE);
				//alert(str);
				IndexOfE = 	str.indexOf('</select>');
				if (IndexOfE != -1) {
					IndexOfE = IndexOfE +9;	
					Response2 = str.substring(0,IndexOfE);
					//alert (Response1);alert (Response2);
					document.getElementById("countries").innerHTML= Response1;
					document.getElementById("sites").innerHTML= Response2;
				}
				else
					document.getElementById("multiple_choice").innerHTML=xmlhttp.responseText;
			}
		
			else
				document.getElementById("multiple_choice").innerHTML=xmlhttp.responseText;
				
		}
		else
			document.getElementById("multiple_choice").innerHTML=xmlhttp.responseText;

	}
	
}


function chance_display(dis){
	if (dis == '1'){
		document.getElementById('other_options').style.display = 'block';
		document.getElementById('dis2').style.display = 'block';
		document.getElementById('dis1').style.display = 'none';
//		document.getElementById('footer').style.top = '1165px';
//		document.getElementById('buttom_bg').style.height = '600px';
	}
	else {
		document.getElementById('dis2').style.display = 'none';
		document.getElementById('dis1').style.display = 'block';
//		document.getElementById('footer').style.top = '860px';
//		document.getElementById('buttom_bg').style.height = '200px';
	saveClick();
	}
}	

function backHP(){
	
	document.getElementById('msg_sent').style.display = 'none';

}
/**************START ADMIN AJAX***************/
function changeAname(id,val){
	elem = 'aname' + id;
	var str = '<br /><br />';
	str += '<input type="submit" class="submitbtn" value="שמור" onclick="SubchangeAname('+id+',1)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	str += '<input type="submit" class="submitbtn" value="בטל" onclick="SubchangeAname('+id+',0)">';
	str += '<br /><br />';
	str += '<input type="text" id="newAname' + id +'" name="newAname" value="'+val+'"/>';
	//alert(elem);
	document.getElementById(elem).innerHTML = str;
	
	}


function SubchangeAname(id,type) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  elem = 'newAname'+id;
	  name = escape(encodeURI(document.getElementById(elem).value));
//	  alert(name);
//	  name = escape(encodeURI(document.getElementById('newAname').value));
//	  alert(name);
	  
		var url=tmp_url+"/login/changeAname.php";
			url=url+"?q="+name;
			url=url+"&id="+id;
			url=url+"&type="+type;
			url=url+"&sid="+Math.random();
			xmlhttp.onreadystatechange=stateChangeAname;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
	
}


function stateChangeAname()
{
	if (xmlhttp.readyState==4)
	  {
		str = xmlhttp.responseText;
//		alert(str);
		IndexOfS = str.indexOf('id=');
		if (IndexOfS != -1){
			IndexOfE = 	str.indexOf('=id;');
			if (IndexOfE != -1) {
				IndexOfS = IndexOfS +3;
				IndexOfE = IndexOfE;
//				alert(IndexOfS + '-'+ IndexOfE);
				//IndexOfE = IndexOfE +13;	
				id = str.substring(IndexOfS,IndexOfE);
//				alert (id);
				IndexOfS = IndexOfE +4;
				IndexOfE = str.indexOf('</span>');
				if (IndexOfE != -1){
					IndexOfE = IndexOfE +7;
					str = str.substring(IndexOfS,IndexOfE);
//					alert(str);
				}
			}
		}
		elem = 'aname' + id;
		document.getElementById(elem).innerHTML=str;
	  }
}


/****************START STATUS CHANGE*******************/

function changeStat(id, stat){

	var str = '';
	str += '<input type="submit" class="submitbtn" style="width:50px; height:22px;" value="בטל" onclick="confchangeStat(';
	str += id+',-1)" /><br><br>';
	selID = 'select'+id;
	str += '<select name="'+selID+'" id="'+selID+'" onchange="SubchangeStat('+id+')">';
	if (stat == 0)
		str += '<option value="0" selected="yes"/> חדש</option>';
	else
		str += '<option value="0"/> חדש</option>';
	if (stat == 1)
		str += '<option value="1" selected="yes"/> בטיפול</option>';
	else
		str += '<option value="1"/> בטיפול</option>';
	if (stat == 2)
		str += '<option value="2" selected="yes"/> נסגר</option>';
	else
		str += '<option value="2"/> נסגר</option>';
	str += '</select>';
	elem = 'stat' + id;
	//alert(elem);
	document.getElementById(elem).innerHTML = str;

	
}

function SubchangeStat(id) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  elem = 'select'+id;

		var statObj = document.getElementById(elem); 
		// Validate that the object exists  if(!pagesObj ) return;   
		// get the options array. This works for both  
		// single select and multi select boxes  
		if( typeof(statObj.options) != "undefined" || statObj.options != null ){  
			var o = statObj.options;  
			// get the selected options into an array  
			var s;  
			for( var i = 0; i < o.length; i++ )  {   
				if( o[i].selected )   {    
				s = o[i].value;   
				}  
			}  
		}
	  //alert(s);
	  
//	  name = document.getElementById(elem).value;
//	  name = escape(encodeURI(document.getElementById('newAname').value));
//	  alert(name);
	  
			var url=tmp_url+"/login/changeStat.php";
			url=url+"?q="+s;
			url=url+"&id="+id;
			url=url+"&sid="+Math.random();
			xmlhttp.onreadystatechange=stateChangeStat;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
	
}


function stateChangeStat()
{
	if (xmlhttp.readyState==4)
	  {
		str = xmlhttp.responseText;
		//alert(str);
		IndexOfS = str.indexOf('id=');
		if (IndexOfS != -1){
			IndexOfE = 	str.indexOf('=id;');
			if (IndexOfE != -1) {
				IndexOfS = IndexOfS +3;
				IndexOfE = IndexOfE;
//				alert(IndexOfS + '-'+ IndexOfE);
				//IndexOfE = IndexOfE +13;	
				id = str.substring(IndexOfS,IndexOfE);
				//alert (id);
				IndexOfS = IndexOfE +4;
				IndexOfE = str.indexOf('endString');
				//alert(IndexOfE);
				if (IndexOfE != -1){
					IndexOfE = IndexOfE;
					str = str.substring(IndexOfS,IndexOfE);
					//alert(str);
				}
			}
		}
		
			elem = 'stat' + id;
			document.getElementById(elem).innerHTML=str;
		
	  }
}

function confchangeStat(id,stat) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	 // elem = 'select'+id;

/*		var statObj = document.getElementById(elem); 
*/		// Validate that the object exists  if(!pagesObj ) return;   
		// get the options array. This works for both  
		// single select and multi select boxes  
/*		if( typeof(statObj.options) != "undefined" || statObj.options != null ){  
			var o = statObj.options;  
			// get the selected options into an array  
			var s;  
			for( var i = 0; i < o.length; i++ )  {   
				if( o[i].selected )   {    
				s = o[i].value;   
				}  
			}  
		}
*/	  //alert(s);
	  
//	  name = document.getElementById(elem).value;
//	  name = escape(encodeURI(document.getElementById('newAname').value));
//	  alert(name);
	  
			var url=tmp_url+"/login/changeStat1.php";
			url=url+"?q="+stat;
			url=url+"&id="+id;
			url=url+"&sid="+Math.random();
			xmlhttp.onreadystatechange=stateChangeStatConf;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
	
}


function stateChangeStatConf()
{
	if (xmlhttp.readyState==4)
	  {
		str = xmlhttp.responseText;
		//alert(str);
		IndexOfS = str.indexOf('id=');
		if (IndexOfS != -1){
			IndexOfE = 	str.indexOf('=id;');
			if (IndexOfE != -1) {
				IndexOfS = IndexOfS +3;
				IndexOfE = IndexOfE;
//				alert(IndexOfS + '-'+ IndexOfE);
				//IndexOfE = IndexOfE +13;	
				id = str.substring(IndexOfS,IndexOfE);
				//alert (id);
				IndexOfS = IndexOfE +4;
				IndexOfE = str.indexOf('endString');
				//alert(IndexOfE);
				if (IndexOfE != -1){
					IndexOfE = IndexOfE;
					str = str.substring(IndexOfS,IndexOfE);
					//alert(str);
				}
			}
		}
		
		elemTR = 'tr'+id;
		elem = 'stat' + id;
		pos = str.indexOf('נסגר');
		if (pos != -1){
			document.getElementById(elemTR).style.display ='none';
		}
		else {
			pos = str.indexOf('בטיפול');
			if (pos != -1){
				document.getElementById(elemTR).style.backgroundColor ='#ffffff';
				document.getElementById(elemTR).style.fontWeight = 'normal';
				document.getElementById(elem).innerHTML=str;
			}
			else {
				pos = str.indexOf('חדש');
				if (pos != -1){
					document.getElementById(elemTR).style.backgroundColor ='#ccc';
					document.getElementById(elemTR).style.fontWeight = 'bold';
					document.getElementById(elem).innerHTML=str;
				}
				
			}
	  }
	}
}

/************CHANGE MULTIPLE NAMES***************/

function changeNameMul(){
	changeName_Array = new Array();
	lead_Count = document.getElementsByName("chk").length;
	//alert(lead_Count);
    chkObj = document.getElementsByName("chk");
	//alert(chkObj);
	j = 0;
	i = 0;
	while (i< lead_Count){
		if (chkObj[i].checked) {
			changeName_Array[j] = chkObj[i].value;
			j++;
			//alert(changeName_Array[i]);
		}
		i++;
	}
	str='';
	if (isset(changeName_Array[0])	){

		str += '<input type="submit" class="submitbtn" value="שמור" onclick="SubchangeMAname('+changeName_Array+', -2)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
		str += '<input type="submit" class="submitbtn" value="בטל" onclick="SubchangeMAname('+changeName_Array+', -1)">';
		str += '<br /><br />';
		//str += '<input type="text" id="SubchangeMAname" name="newAname" />';
		//alert(str);
		//alert (changeName_Array);
		document.getElementById('changeNameOrStat').style.display = 'block';
		document.getElementById('changeNameOrStat').innerHTML = str +'<input type="text" id="SubchangeMAname" name="newAname" />';
		document.getElementById('changeNameOrStat2').style.display = 'block';
		document.getElementById('changeNameOrStat2').innerHTML = str + '<input type="text" id="SubchangeMAname2" name="newAname" />';
	}
	else {
		str = '<span style="font-size:14px; font-weight:bold;">אנא בחר לידים עבור שינוי השם</span>';
		document.getElementById('changeNameOrStat').innerHTML = str;
		document.getElementById('changeNameOrStat').style.display = 'block';
		document.getElementById('changeNameOrStat2').innerHTML = str;
		document.getElementById('changeNameOrStat2').style.display = 'block';
	}
}

function SubchangeMAname() {
  var argv = SubchangeMAname.arguments;
  var argc = argv.length;
  //alert(argc);
  var actionInx = argc-1;
  var array = new Array();
  for (var i = 0; i < argc; i++) {
    array += 'id=' +argv[i];
  }
  //alert(array);
  action = argv[actionInx];
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  elem = 'SubchangeMAname';
	  elem2 = 'SubchangeMAname2';
	  name = document.getElementById(elem).value.length;
  	  name2 = document.getElementById(elem2).value.length;
	  if (name > 0)
		  name = escape(encodeURI(document.getElementById(elem).value));
	  else {
		  name2 = escape(encodeURI(document.getElementById(elem2).value));
		  name = name2;  
	  }
//	  alert(name);
//	  name = escape(encodeURI(document.getElementById('newAname').value));
//	  alert(name);
	  
		var url=tmp_url+"/login/SubchangeMAname.php";
			url=url+"?q="+name;
			url=url+"&id="+array;
			url=url+"&type="+action
			url=url+"&sid="+Math.random();
			xmlhttp.onreadystatechange=stateSubchangeMAname;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
	
}


function stateSubchangeMAname()
{
	if (xmlhttp.readyState==4)
	  {
	  	array = new Array();
		str = xmlhttp.responseText;
		len = str.length;
		IndexOfS = 0
		IndexOfE = 1 ;
		i=0;
		while (IndexOfE<len) {
			IndexOfS = str.indexOf('id=');
			if (IndexOfS != -1){
				IndexOfE = 	str.indexOf('&');
				if (IndexOfE != -1) {
					IndexOfS = IndexOfS +3;
					//IndexOfE = IndexOfE-1;
					array[i] = str.substring(IndexOfS,IndexOfE);
					IndexOfE = IndexOfE+1;
					str = str.substring(IndexOfE,len)
					//IndexOfE++;
					i++;
				}
				else 
					IndexOfE = len;
			}
			else 
				IndexOfE = len;
		
		}
		
		//alert('array is:' +array);
		IndexOfS = str.indexOf('name=');
		if (IndexOfS != -1){
			IndexOfS = IndexOfS + 5;
			IndexOfE = 	str.indexOf('&');
			if (IndexOfE != -1) {
				//alert(IndexOfS); alert(IndexOfE);
				if (IndexOfS == IndexOfE) {
					name = '-';
					//alert('name empty');
				}
				else {
					name = str.substring(IndexOfS,IndexOfE);
					//alert (name);
				}
			}
		}
		
		
	if (name == '-') {
		str = '<input type="submit" class="submitbtn" value="הוסף שם" onclick="javascript:changeAname('+array[i] +')" />';	
	}
	else {
		str = '<input type="submit" class="submitbtn" value="שנה שם" onclick="javascript:changeAname('+array[i] +', ' + name +')" /><br /><br />';
		str += '<span style="font-size:14px; color:#006;">';
		str += name +'</span>';
	}
	len=array.length -1;
	for (i=0; i<len; i++){
		elem = 'aname' + array[i];
		document.getElementById(elem).innerHTML=str;
	}
	
  }
	  //alert(str);
		elem = 'changeNameOrStat';
		elem2 = 'changeNameOrStat2';
		document.getElementById(elem).style.display='none';
		document.getElementById(elem2).style.display='none';
	 // }
}

/************CHANGE MULTIPLE STATUS***************/

function changeStatMul(){
	changeStat_Array = new Array();
	lead_Count = document.getElementsByName("chk").length;
	//alert(lead_Count);
    chkObj = document.getElementsByName("chk");
	//alert(chkObj);
	j = 0;
	i = 0;
	while (i< lead_Count){
		if (chkObj[i].checked) {
			changeStat_Array[j] = chkObj[i].value;
			j++;
			//alert(changeName_Array[i]);
		}
		i++;
	}
	//str='';
	
	var str = '';


	
	
	
	if (isset(changeStat_Array[0])	){

	//str += '<select name="SubchangeMStat" id="SelectMS" onchange="SubchangeMStat('+changeStat_Array+', 1)">';
	str += '<option value="-1"/> </option>';
	str += '<option value="0"/> חדש</option>';
	str += '<option value="1"/> בטיפול</option>';
	str += '<option value="2"/> נסגר</option>';
	str += '</select>';
	str += '&nbsp;&nbsp;';
	str += '<input type="submit" class="submitbtn" style="width:50px; height:22px;" value="בטל" onclick="SubchangeMStat('+changeStat_Array+', -1)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';

		//str += '<input type="submit" class="submitbtn" value="בטל" onclick="SubchangeMStat('+changeStat_Array+', -1)">';

//str += '<input type="text" id="SubchangeMAname" name="newAname" />';
		//alert(str);
		//alert (changeName_Array);changeStat
		document.getElementById('changeNameOrStat').style.display = 'block';
		document.getElementById('changeNameOrStat').innerHTML = '<select name="SubchangeMStat" id="SubchangeMStat" onchange="SubchangeMStat('+changeStat_Array+', 1)">' + str;
//		document.getElementById('changeNameOrStat').innerHTML = '<select name="SubchangeMStat" id="SubchangeMStat" onchange="SubchangeMStat('+changeStat_Array+', 1)">' + str;
		document.getElementById('changeNameOrStat2').style.display = 'block';
		document.getElementById('changeNameOrStat2').innerHTML = '<select name="SubchangeMStat2" id="SubchangeMStat2" onchange="SubchangeMStat('+changeStat_Array+', 2)">' +str;
	}
	else {
		str = '<span style="font-size:14px; font-weight:bold;">אנא בחר לידים עבור שינוי הסטטוס</span>';
		document.getElementById('changeNameOrStat').innerHTML = str;
		document.getElementById('changeNameOrStat').style.display = 'block';
		document.getElementById('changeNameOrStat2').innerHTML = str;
		document.getElementById('changeNameOrStat2').style.display = 'block';
	}
}

function SubchangeMStat() {
  var argv = SubchangeMStat.arguments;
  var argc = argv.length;
  //alert(argc);
  var locationInx = argc-1;
  var actionInx = argc-1;
  var array = new Array();
  for (var i = 0; i < argc; i++) {
    array += 'id=' +argv[i];
  }
  //alert(array);
  action = argv[actionInx];
  //alert(action);
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  if (argv[locationInx] == 1)
	  	elem = 'SubchangeMStat';
	  else
	  	elem = 'SubchangeMStat2';

		var statObj = document.getElementById(elem); 
		
		//s = document.getElementById(elem).value;
		// Validate that the object exists  if(!pagesObj ) return;   
		// get the options array. This works for both  
		// single select and multi select boxes  
		if( typeof(statObj.options) != "undefined" || statObj.options != null ){  
			var o = statObj.options;  
			// get the selected options into an array  
			var s;  
			for( var i = 0; i < o.length; i++ )  {   
				if( o[i].selected )   {    
				s = o[i].value;   
				}  
			}  
		}

			
		//}
		
	  //alert('array is -------->'+array);
	  //alert('s is -------> '+s);
	  //alert('location is ' + argv[locationInx]);
	  //alert('action is '+action);
	  
//	  name = document.getElementById(elem).value;
//	  name = escape(encodeURI(document.getElementById('newAname').value));
//	  alert(name);
	  
			var url=tmp_url+"/login/SubchangeMStat.php";
			url=url+"?q="+array;
			url=url+"&type="+action;
			url=url+"&value="+s;
			url=url+"&sid="+Math.random();
			xmlhttp.onreadystatechange=stateChangeMStat;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
	
}

function stateChangeMStat(){
	if (xmlhttp.readyState==4) {
		str = xmlhttp.responseText;

		//alert(str);
		len = str.length;
		IndexOfS = 0;
		IndexOfE = 0;
	
		IndexOfS = str.indexOf('status=');
		if (IndexOfS != -1){
			//alert(IndexOfS);
			IndexOfE = 	str.indexOf('array=');
			if (IndexOfE != -1) {
				IndexOfS = IndexOfS +7;
							//alert(IndexOfE);
				stat = str.substring(IndexOfS,IndexOfE)
				//IndexOfE++;
			}
			else stat = '';
		}
		else stat = '';
		//alert('status is:' +stat);
		IndexOfS = str.indexOf('array=');
		if (IndexOfS != -1){
			//alert(IndexOfS);
			IndexOfE = 	str.indexOf('endString');
			if (IndexOfE != -1) {
				IndexOfS = IndexOfS +6;
							//alert(IndexOfE);
				array = str.substring(IndexOfS,IndexOfE)
				//IndexOfE++;
			}
			else array = '';
		}
		else array = '';
		if (stat ==0 ) statusName ='חדש';
		if (stat ==1 ) statusName ='בטיפול';		
		if (stat ==2 ) statusName ='נסגר';
		//alert('array is : '+array);
		if (stat != '') {
			if (stat != 2) {
				str = '<span>הסטטוס שבחרת הוא: <span style="font-weight:bold; font-size:14px;">'+statusName+'</span></span><br /><br />';
				str += '<input type="submit" class="submitbtn" style="width:40px; height:22px;" value="שמור" onclick="SubchangeMStat1(';
				str += stat+',1)" /> ';
				str += '<input type="submit" class="submitbtn" style="width:50px; height:22px;" value="בטל" onclick="SubchangeMStat1(';
				str += '-1,1)" />';
				str1 = '<span>הסטטוס שבחרת הוא: <span style="font-weight:bold; font-size:14px;">'+statusName+'</span></span><br /><br />';
				str1 += '<input type="submit" class="submitbtn" style="width:40px; height:22px;" value="שמור" onclick="SubchangeMStat1(';
				str1 += stat+',2)" /> ';
				str1 += '<input type="submit" class="submitbtn" style="width:50px; height:22px;" value="בטל" onclick="SubchangeMStat1(';
				str1 += '-1,2)" />';
				
			}
			else {
				str = '<span>הסטטוס שבחרת הוא: <span style="font-weight:bold; font-size:14px;">'+statusName+'</span></span><br />שורה זו תיעלם מהתצוגה. לראות את כל הלידים הסגורים, לחץ על כפתור -לידים סגורים- בשורת הכפתורים העליונה או התחתונה</span><br /><br />';
				str += '<input type="submit" class="submitbtn" style="width:40px; height:22px;" value="שמור" onclick="SubchangeMStat1(';
				str += stat+',1)" /> ';
				str += '<input type="submit" class="submitbtn" style="width:50px; height:22px;" value="בטל" onclick="SubchangeMStat1(';
				str +='-1,1)" />';
				str1 = '<span>הסטטוס שבחרת הוא: <span style="font-weight:bold; font-size:14px;">'+statusName+'</span></span><br />שורה זו תיעלם מהתצוגה. לראות את כל הלידים הסגורים, לחץ על כפתור -לידים סגורים- בשורת הכפתורים העליונה או התחתונה</span><br /><br />';
				str1 += '<input type="submit" class="submitbtn" style="width:40px; height:22px;" value="שמור" onclick="SubchangeMStat1(';
				str1 += stat+',2)" /> ';
				str1 += '<input type="submit" class="submitbtn" style="width:50px; height:22px;" value="בטל" onclick="SubchangeMStat1(';
				str1 +='-1,2)" />';
				
			}

			document.getElementById('changeNameOrStat').innerHTML = str;
			//document.getElementById('changeNameOrStat').style.display = 'block';
			document.getElementById('changeNameOrStat2').innerHTML = str;
			//document.getElementById('changeNameOrStat2').style.display = 'block';
			
		}
		else {
			document.getElementById('changeNameOrStat').innerHTML = str;
			document.getElementById('changeNameOrStat').style.display = 'none';
			document.getElementById('changeNameOrStat2').innerHTML = str;
			document.getElementById('changeNameOrStat2').style.display = 'none';
			
		}
		
	}
	
}

function SubchangeMStat1(stat,location) {
  
	changeStat_Array = new Array();
	lead_Count = document.getElementsByName("chk").length;
	//alert(lead_Count);
    chkObj = document.getElementsByName("chk");
	//alert(chkObj);
	j = 0;
	i = 0;
	//alert('lead count is: '+lead_Count);
	while (i< lead_Count){
		if (chkObj[i].checked) {
			changeStat_Array[j] = chkObj[i].value;
			j++;
			//alert(changeName_Array[i]);
		}
		i++;
	}
		//alert(changeStat_Array.length);

	//alert(changeStat_Array);
	array = '';
	for (i=0; i<changeStat_Array.length; i++){
		array += 'id=' +changeStat_Array[i];
	}
	//alert('status is: '+stat);
	//alert('status is: '+stat);
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
/*	  elem = 'SubchangeMStat';
	  elem2 = 'SubchangeMStat2';
	  stat = document.getElementById(elem).value.length;
  	  stat2 = document.getElementById(elem2).value.length;
	  if (stat > 0)
		  stat = document.getElementById(elem).value;
	  else 
		  stat = document.getElementById(elem2).value;
*/	  
//	  alert(name);
//	  name = escape(encodeURI(document.getElementById('newAname').value));
//	  alert(name);
	  
		var url=tmp_url+"/login/SubchangeMStat1.php";
			url=url+"?q="+stat;
			url=url+"&id="+array;
//			url=url+"&location="+location;
//			url=url+"&type="+action
			url=url+"&sid="+Math.random();
			xmlhttp.onreadystatechange=stateSubchangeMStat1;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
	
}


function stateSubchangeMStat1()
{
	if (xmlhttp.readyState==4)
	  {
	  	array = new Array();
		str = xmlhttp.responseText;
		
		//alert(str);
		len = str.length;
		IndexOfS = 0
		IndexOfE = 1 ;
		i=0;
		while (IndexOfE<len) {
			IndexOfS = str.indexOf('id=');
			if (IndexOfS != -1){
				IndexOfE = 	str.indexOf('&');
				if (IndexOfE != -1) {
					IndexOfS = IndexOfS +3;
					//IndexOfE = IndexOfE-1;
					array[i] = str.substring(IndexOfS,IndexOfE);
					IndexOfE = IndexOfE+1;
					str = str.substring(IndexOfE,len)
					//IndexOfE++;
					i++;
				}
				else 
					IndexOfE = len;
			}
			else 
				IndexOfE = len;
		
		}
		
		//alert('array is:' +array);
		IndexOfS = str.indexOf('stat=');
		if (IndexOfS != -1){
			IndexOfS = IndexOfS + 5;
			IndexOfE = 	str.indexOf('&');
			if (IndexOfE != -1) {
				//alert(IndexOfS); alert(IndexOfE);
				stat = str.substring(IndexOfS,IndexOfE);
					//alert (name);
			}
		}
		if (stat == 0) statName ='חדש';
		if (stat == 1) statName ='בטיפול';		
		if (stat == 2) statName ='נסגר';
		if (stat != -1) {
		
			str = '<input type="submit" class="submitbtn" value="שנה סטטוס" onclick="javascript:changeStat('+array[i] +', ' + stat +')" /><br /><br />';
			str += '<span style="font-size:14px; color:#006;">';
			str += statName +'</span>';
			len=array.length -1;
			for (i=0; i<=len; i++){
				elem = 'stat' + array[i];
				elemTR = 'tr'+array[i];
				document.getElementById(elem).innerHTML=str;
				if (stat==0) {
					document.getElementById(elemTR).style.backgroundColor = '#ccc';
					document.getElementById(elemTR).style.fontWeight = 'bold';
				}
				if (stat==1) {
					document.getElementById(elemTR).style.backgroundColor = '#ffffff';
					document.getElementById(elemTR).style.fontWeight = 'normal';
				}
				if (stat==2) {
					document.getElementById(elemTR).style.display = 'none';
				}
			}
		}
	
  }
	  //alert(str);
		elem = 'changeNameOrStat';
		elem2 = 'changeNameOrStat2';
		document.getElementById(elem).style.display='none';
		document.getElementById(elem2).style.display='none';
	 // }
}


function checkall() {
	checkAll_Array = new Array();
	lead_Count = document.getElementsByName("chk").length;
	//alert(lead_Count);
    chkObj = document.getElementsByName("chk");
	//alert(chkObj);
	j = 0;
	i = 0;
	while (i< lead_Count){
		if (chkObj[i].checked) {
			i = lead_Count;
			j = 1;
		}
		else
			i++;
	}
	i=0;
	if (j ==0) {
		while (i< lead_Count){
			chkObj[i].checked = "checked";
			i++;
		}
	}
	else {
		while (i< lead_Count){
			chkObj[i].checked = "";
			i++;
		}
		
	}
	
}

/******* DISPLAY BIG MAP TRAIL   *******/
function showBigTrailMap(location)
{
 href=location;
window.open(href,'dtm', 'resizable=1,width=700,height=700,scrollbars=yes');
}



function exitBTM() {
	document.getElementById('bigTrailMap').style.display = 'none';
	
}


function displayPlus(dis,id) {
	//document.getElementById('displayPlus').innerHTML = dis; 	
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  
		var url=tmp_url+"/Scripts/displayPlus.php";
			url=url+"?q="+dis;
			url=url+"&id="+id;
			url=url+"&sid="+Math.random();
			xmlhttp.onreadystatechange=stateSubchangedisPlus;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);	
	
}

function stateSubchangedisPlus()
{
if (xmlhttp.readyState==4)
  {
	 str = xmlhttp.responseText;
	IndexOfS = str.indexOf('startsting');
	if (IndexOfS != -1){
		IndexOfS = IndexOfS + 10;
		len = str.length;
		str = str.substring(IndexOfS, len);	
	}
	IndexOfS = str.indexOf('C=');
	Ind = IndexOfS ;
	//alert(str);
	//alert(chkResponse);
	if (IndexOfS != -1){
		IndexOfE = 	str.indexOf('id=');
		if (IndexOfE != -1) {
			IndexOfS = IndexOfS +2;
			sun_C = str.substring(IndexOfS,IndexOfE);
			IndexOfS = 	str.indexOf('id=');
			if (IndexOfS != -1){
				IndexOfE = 	str.indexOf('endstring');
				if (IndexOfE != -1) {
					IndexOfS = IndexOfS +3;
					id = str.substring(IndexOfS,IndexOfE);
					//alert (Response1);
					
					str = str.substring(0,Ind);

		//alert(str);
				}
			}
		}
	}
	  
  if (sun_C == '1') {
	  if (document.getElementById("generalInfo")){
	  document.getElementById("generalInfo").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("location")){
	  document.getElementById("location").style.backgroundColor = '#5b90bd';
	  }
	  if (document.getElementById("searfCond")){
	  document.getElementById("searfCond").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("nightLife")) {
	  document.getElementById("nightLife").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("familyVacation")){
	  document.getElementById("familyVacation").style.backgroundColor = '#1e4a7b';
	  }
  }
  if (sun_C == '2') {
	  if (document.getElementById("generalInfo")){
	  document.getElementById("generalInfo").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("location")){
	  document.getElementById("location").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("searfCond")){
	  document.getElementById("searfCond").style.backgroundColor = '#5b90bd';
	  }
	  if (document.getElementById("nightLife")) {
	  document.getElementById("nightLife").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("familyVacation")){
	  document.getElementById("familyVacation").style.backgroundColor = '#1e4a7b';
	  }
  }
  if (sun_C == '3') {
	  if (document.getElementById("generalInfo")){
	  document.getElementById("generalInfo").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("location")){
	  document.getElementById("location").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("searfCond")){
	  document.getElementById("searfCond").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("nightLife")) {
	  document.getElementById("nightLife").style.backgroundColor = '#5b90bd';
	  }
	  if (document.getElementById("familyVacation")){
	  document.getElementById("familyVacation").style.backgroundColor = '#1e4a7b';
	  }

	 }
  if (sun_C == '4') {
	  if (document.getElementById("generalInfo")){
	  document.getElementById("generalInfo").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("location")){
	  document.getElementById("location").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("searfCond")){
	  document.getElementById("searfCond").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("nightLife")) {
	  document.getElementById("nightLife").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("familyVacation")){
	  document.getElementById("familyVacation").style.backgroundColor = '#5b90bd';
	  }
  }
  if (sun_C == '5') {
	  if (document.getElementById("generalInfo")){
	  document.getElementById("generalInfo").style.backgroundColor = '#5b90bd';
	  }
	  if (document.getElementById("location")){
	  document.getElementById("location").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("searfCond")){
	  document.getElementById("searfCond").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("nightLife")) {
	  document.getElementById("nightLife").style.backgroundColor = '#1e4a7b';
	  }
	  if (document.getElementById("familyVacation")){
	  document.getElementById("familyVacation").style.backgroundColor = '#1e4a7b';
	  }

  }	  
  document.getElementById("displayPlus").innerHTML=str;
//  document.getElementById("displayPlus").innerHTML='<div style="width:500px; display:block;">'+str+'</div>';
  }
}
function displayMinus(dis, id) {
	switch (dis) {
		case 1:
			document.getElementById("displayPlus").style.display = 'none';
	  		document.getElementById("locationImg").innerHTML = '&nbsp;&nbsp;&nbsp;<a id="loc" href="javascript:displayPlus(1,'+id+')"> <img src="images/plussign.jpg" />&nbsp;<h4>מיקום והגעה</h4></a>';
			document.getElementById("loc").style.color = '#1C4A9B';
			
		break;
		case 2:
			document.getElementById("displayPlus").style.display = 'none';
	  		document.getElementById("searf_condImg").innerHTML = '&nbsp;&nbsp;&nbsp;<a id="cond" href="javascript:displayPlus(2,'+id+')"> <img src="images/plussign.jpg" />&nbsp;<h4>תנאי גלישה</h4></a>';
			document.getElementById("cond").style.color = '#1C4A9B';
			
		break;
		case 3:
			document.getElementById("displayPlus").style.display = 'none';
	  		document.getElementById("night_lifeImg").innerHTML = '&nbsp;&nbsp;&nbsp;<a id="night" href="javascript:displayPlus(3,'+id+')"> <img src="images/plussign.jpg" />&nbsp;<h4>חיי לילה</h4></a>';
			document.getElementById("night").style.color = '#1C4A9B';
			
		break;
		case 4:
			document.getElementById("displayPlus").style.display = 'none';
	  		document.getElementById("family_vacationImg").innerHTML = '&nbsp;&nbsp;&nbsp;<a id="fam" href="javascript:displayPlus(4,'+id+')"> <img src="images/plussign.jpg" />&nbsp;<h4>חופשה עם המשפחה</h4></a>';
			document.getElementById("fam").style.color = '#1C4A9B';
			
		break;
		
	}
	
}
function showPoll(poll_id){
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}

	var url=tmp_url+"/Scripts/showPollData.php";
	url=url+"?poll_id="+poll_id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateSubchangeshowPoll;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);		
}

function stateSubchangeshowPoll()
{
	if (xmlhttp.readyState==4)
	  {
/*		  document.getElementById('poll').innerHTML = xmlhttp.responseText;
*/	  
		result = xmlhttp.responseText;
		document.getElementById('msg_sent').innerHTML = result;            
		scrOfY = parseInt(getScrollY());
		myHeight = parseInt(getSizeY());
		myWidth = parseInt(getSizeX());
		topLocation = scrOfY + (myHeight - 443)/2;
		rightLocation = (myWidth - 422)/2;
		document.getElementById('over_overwrapper1').style.right = rightLocation +'px';
		document.getElementById('over_overwrapper1').style.top = topLocation +'px';
	
	}
}

function insertPollData() {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	obj = document.poll;
	subPoll = obj.subPoll.value;
	if (subPoll == 'שלח') {
		subPoll = 's';
		/*for (var i=0; i < obj.pollQ.length; i++)
		{
		   if (obj.pollQ[i].checked)
			  {
			  var rad_val = obj.pollQ[i].value;
			  i = obj.pollQ.length;
			  }
		}*/
		
		rad_val = obj.pollQ.value;
	}
	else {
		rad_val = 'poll_a0';
		subPoll = 'v';
	}
		
	poll_id = obj.pollId.value;
	//poll_id = obj.pollQ.value;
	var url=tmp_url+"/Scripts/insertPollData.php";
	url=url+"?val="+rad_val;
	url=url+"&action="+subPoll;
	url=url+"&poll_id="+poll_id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateSubchangePoll;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	

}
function insertPollData1(poll_id,page) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	formname='poll'+poll_id;
	obj=document.forms[formname];
//	obj = document.poll;
//	subPoll = obj.subPoll.value;
//	if (subPoll == 'שלח') {
//		subPoll = 's';
//alert('obj is: '+obj+' object length is: '+obj.length);
		for (var i=0; i < obj.length; i++)
		{
			if(obj.elements[i].type=="radio"){
				
	//			alert(obj[i].value);
			   if (obj.elements[i].checked)
				  {
				  var rad_val = obj.elements[i].value;
				  i = obj.length;
				  }
			}
		}
//	}
//	else {
//		rad_val = 'poll_a0';
//		subPoll = 'v';
//	}
		
//	poll_id = obj.pollId.value;
	var url=tmp_url+"/Scripts/insertPollData.php";
	url=url+"?val="+rad_val;
	url=url+"&action=s";
	url=url+"&page="+page;
	url=url+"&poll_id="+poll_id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateSubchangePoll;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	

}
function stateSubchangePoll()
{
	if (xmlhttp.readyState==4)
	  {
/*		  document.getElementById('poll').innerHTML = xmlhttp.responseText;
*/	  
		result = xmlhttp.responseText;
		document.getElementById('msg_sent').innerHTML = result;            
		scrOfY = parseInt(getScrollY());
		myHeight = parseInt(getSizeY());
		myWidth = parseInt(getSizeX());
		topLocation = scrOfY + (myHeight - 443)/2;
		rightLocation = (myWidth - 422)/2;
		document.getElementById('over_overwrapper1').style.right = rightLocation +'px';
		document.getElementById('over_overwrapper1').style.top = topLocation +'px';
	
	}
}

function backHP2(poll_id){
//	pollView = 'pollView'+poll_id;
//	alert(pollView);
	document.getElementById('msg_sent').style.display = 'none';
	document.location = '/polls';
//	document.getElementById(pollView).style.display = 'none';

}
function backHP1(id){
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
//	id = parseInt(id);
	var url=tmp_url+"/Scripts/afterVote.php";
	url=url+"?poll_id="+id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateSubchangeafterVote;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function backHP3(poll_id,page){
//	pollView = 'pollView'+poll_id;
//	alert(pollView);
	document.getElementById('msg_sent').style.display = 'none';
	document.location = '/polls/page'+page;
//	document.getElementById(pollView).style.display = 'none';

}

function stateSubchangeafterVote()
{
	if (xmlhttp.readyState==4)
	  {
		document.getElementById('poll').innerHTML = xmlhttp.responseText;	
		document.getElementById('msg_sent').style.display = 'none';
	}
}
function displayForm() {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=tmp_url+"/Scripts/displayContactForm.php";
	url=url+"?sid="+Math.random();
	xmlhttp.onreadystatechange=stateSubchangeDCF;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
	
}
function stateSubchangeDCF()
{
	if (xmlhttp.readyState==4)
	  {
		result = xmlhttp.responseText;
		document.getElementById('msg_sent').innerHTML = result;            
		scrOfY = parseInt(getScrollY());
		myHeight = parseInt(getSizeY());
		myWidth = parseInt(getSizeX());
		topLocation = scrOfY + (myHeight - 443)/2;
		rightLocation = (myWidth - 422)/2;
		document.getElementById('over_overwrapper1').style.right = rightLocation +'px';
		document.getElementById('over_overwrapper1').style.top = topLocation +'px';
/*		document.getElementById('msg_sent').style.display = 'block';
		document.getElementById('msg_sent').innerHTML = xmlhttp.responseText;	
*/	}
}

function displayDesctiption(c_id) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=tmp_url+"/Scripts/displayCountryDesc.php";
	url=url+"?c_id="+c_id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateSubchangeDCD;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function stateSubchangeDCD()
{
	if (xmlhttp.readyState==4)
	  {
		str = xmlhttp.responseText;
//		alert(str);
		IndexOfS = str.indexOf('startstring:');
		if (IndexOfS != -1){
			IndexOfS = IndexOfS + 12;
			len = str.length;
			str = str.substring(IndexOfS, len);	
		}
		IndexOfE = 	str.indexOf(';endstring');
		if (IndexOfE != -1) {
			str = str.substring(0,IndexOfE);

		}

		//result = xmlhttp.responseText;
//		alert(str);
//		document.getElementById('description').innerHTML = str;
//dht=str; 
		document.getElementById('descLink').style.display = 'none';
		document.getElementById('descCont').style.display='block'	
	}
}

function makePOSTRequestComment(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = stateSubchangeComment;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

function sendComment(obj) {
//	alert(document.commentForm.surfer_name.value);
	surfer_name=escape(encodeURI(document.commentForm.surfer_name.value));
	surfer_town=escape(encodeURI(document.commentForm.surfer_town.value));
	surfer_mail= escape(encodeURI(document.commentForm.surfer_mail.value));
	comment_title= escape(encodeURI(document.commentForm.comment_title.value));
	comment_content=escape(encodeURI(document.commentForm.comment_content.value));
	type_id = escape(encodeURI(document.commentForm.type_id.value));
	section_type = escape(encodeURI(document.commentForm.section_type.value));
	site_name = escape(encodeURI(document.commentForm.site_name.value));
	var poststr = "sn=" + surfer_name  +
				"&st=" + surfer_town +
				"&sm=" + surfer_mail +
				"&ct=" + comment_title +
				"&cc=" + comment_content +
				"&t_id=" + type_id +
				"&s_id=" + section_type +
				"&s_name=" + site_name;	   	
	//alert(poststr);
	makePOSTRequestComment(tmp_url+'/Scripts/subComment.php', poststr);
   }


   function stateSubchangeComment() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
			str =  http_request.responseText;
			IndexOfS = str.indexOf('messagesent');
			if (IndexOfS != -1){
				document.getElementById('addComment').style.color = '#ffffff';
				document.getElementById('commentForm').style.display = 'none';
	
				document.getElementById('afterSend').style.display = 'inline';
	}
		}
		else {
            alert('There was a problem with the request.');
         }
    
	  }

	  
   }

function makePOSTRequestCommentSub(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = stateSubchangeCommentSub;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

function sendCommentSub(cm_id) {
	//	alert(document.commentForm.surfer_name.value);
	surfer_nameElem = 'surfer_name'+cm_id;
	surfer_townElem = 'surfer_town'+cm_id;
	surfer_mailElem = 'surfer_mail'+cm_id;
	comment_titleElem = 'comment_title'+cm_id;
	comment_contentElem = 'comment_content'+cm_id;
	type_idElem = 'type_id'+cm_id;
	section_typeElem = 'section_type'+cm_id;
	site_nameElem = 'site_name'+cm_id;
	org_commentIDElem = 'org_commentID'+cm_id;
	
	surfer_name=escape(encodeURI(document.getElementById(surfer_nameElem).value));
	surfer_town=escape(encodeURI(document.getElementById(surfer_townElem).value));
	surfer_mail= escape(encodeURI(document.getElementById(surfer_mailElem).value));
	comment_title= escape(encodeURI(document.getElementById(comment_titleElem).value));
	comment_content=escape(encodeURI(document.getElementById(comment_contentElem).value));
	type_id = escape(encodeURI(document.getElementById(type_idElem).value));
	section_type = escape(encodeURI(document.getElementById(section_typeElem).value));
	site_name = escape(encodeURI(document.getElementById(site_nameElem).value));
	org_comment_id = escape(encodeURI(document.getElementById(org_commentIDElem).value));
	var poststr = "sn=" + surfer_name  +
				"&st=" + surfer_town +
				"&sm=" + surfer_mail +
				"&ct=" + comment_title +
				"&cc=" + comment_content +
				"&t_id=" + type_id +
				"&s_id=" + section_type +
				"&s_id=" + section_type +
				"&o_c_id=" + org_comment_id +
				"&s_name=" + site_name;	   	
	//alert(poststr);
	makePOSTRequestCommentSub(tmp_url+'/Scripts/subComment.php', poststr);
}

function sendPartnerSub(cm_id) {
	//	alert(document.commentForm.surfer_name.value);
	surfer_nameElem = 'surfer_name'+cm_id;
	surfer_townElem = 'surfer_town'+cm_id;
	surfer_mailElem = 'surfer_mail'+cm_id;
	comment_titleElem = 'comment_title'+cm_id;
	comment_contentElem = 'comment_content'+cm_id;
	//type_idElem = 'type_id'+cm_id;
	//section_typeElem = 'section_type'+cm_id;
	site_nameElem = 'site_name'+cm_id;
	org_commentIDElem = 'org_commentID'+cm_id;
	
	surfer_name=escape(encodeURI(document.getElementById(surfer_nameElem).value));
	surfer_town=escape(encodeURI(document.getElementById(surfer_townElem).value));
	surfer_mail= escape(encodeURI(document.getElementById(surfer_mailElem).value));
	comment_title= escape(encodeURI(document.getElementById(comment_titleElem).value));
	comment_content=escape(encodeURI(document.getElementById(comment_contentElem).value));
	//type_id = escape(encodeURI(document.getElementById(type_idElem).value));
	//section_type = escape(encodeURI(document.getElementById(section_typeElem).value));
	site_name = escape(encodeURI(document.getElementById(site_nameElem).value));
	org_comment_id = escape(encodeURI(document.getElementById(org_commentIDElem).value));
	var poststr = "sn=" + surfer_name  +
				"&st=" + surfer_town +
				"&sm=" + surfer_mail +
				"&ct=" + comment_title +
				"&cc=" + comment_content +
				"&t_id=-1"+
				"&s_id=3"+
				"&o_c_id=" + org_comment_id +
				"&s_name=" + site_name;	   	
	//alert(poststr);
	makePOSTRequestCommentSub(tmp_url+'/Scripts/subComment.php', poststr);
}
function stateSubchangeCommentSub() {
  if (http_request.readyState == 4) {
	 if (http_request.status == 200) {
		//alert(http_request.responseText);
		str =  http_request.responseText;
		cm_id = 0;
		IndexOfS = str.indexOf('messagesent;');
		if (IndexOfS != -1){
			IndexOfS = IndexOfS + 12;
			len = str.length;
			str = str.substring(IndexOfS, len);	
			IndexOfS = 	str.indexOf('id=');
			if (IndexOfS != -1) {
				IndexOfS = IndexOfS + 3;
				len = str.length;
				str = str.substring(IndexOfS, len);	
				IndexOfE = 	str.indexOf(';');
				if (IndexOfE != -1) {
					cm_id = str.substring(0,IndexOfE);
				}
			}
		}
		//alert(cm_id);
		if (cm_id == 0){
		document.getElementById('addComment').style.color = '#ffffff';
		document.getElementById('commentForm').style.display = 'none';
		document.getElementById('afterSend').style.display = 'inline';
		}
		else {
			addCommentElem = 'addCommentSub' + cm_id;
			commentFormElem = 'commentForm' + cm_id;
			afterSendElem = 'afterSend' + cm_id;
			document.getElementById(addCommentElem).style.color = '#ffffff';
			document.getElementById(commentFormElem).style.display = 'none';
			document.getElementById(afterSendElem).style.display = 'inline';
			
		}
	}
	else {
		alert('There was a problem with the request.');
	 }

  }

  
}


function makePOSTRequestCommentAdmin(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = stateSubchangeCommentAdmin;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

function sendCommentAdmin(publish) {

	comment_title= escape(encodeURI(document.commentForm.comment_title.value));
	comment_content=escape(encodeURI(document.commentForm.comment_content.value));
	com_id=escape(encodeURI(document.commentForm.com_id.value));
	section_type=escape(encodeURI(document.commentForm.section_type.value));
	type_id=escape(encodeURI(document.commentForm.type_id.value));
	surfer_mail=escape(encodeURI(document.commentForm.sm.value));
	var poststr = "ct=" + comment_title +
				  "&cc=" + comment_content +
				  "&com_id=" + com_id +
				  "&st=" + section_type +
				  "&tid=" + type_id +
				  "&sm=" + surfer_mail +
				  "&publish=" + publish;
	//alert(poststr);
	makePOSTRequestCommentAdmin(tmp_url+'/Scripts/subCommentAdmin.php', poststr);
   }


function stateSubchangeCommentAdmin() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			str =  http_request.responseText;
			//alert(str);
			IndexOfS = str.indexOf('publish:');
			if (IndexOfS != -1){
				IndexOfS = IndexOfS + 8;
				len = str.length;
				str = str.substring(IndexOfS, len);	
			}
			IndexOfE = 	str.indexOf('com_id:');
			if (IndexOfE != -1) {
				publish = str.substring(0,IndexOfE);
	
			}
			IndexOfS = IndexOfE +7;
			IndexOfE = 	str.indexOf('mail:');
			if (IndexOfE != -1) {
				com_id = str.substring(IndexOfS,IndexOfE);
	
			}
			IndexOfS = IndexOfE +5;
			IndexOfE = 	str.indexOf('stype');
			if (IndexOfE != -1) {
				mail = str.substring(IndexOfS,IndexOfE);
	
			}//				alert(com_id);
			IndexOfS = IndexOfE +6;
			IndexOfE = 	str.indexOf(';endstring');
			if (IndexOfE != -1) {
				stype = str.substring(IndexOfS,IndexOfE);
	
			}//				alert(com_id);
				document.getElementById('ViewForm').style.display = 'none';
				document.getElementById('messageMail').style.display = 'block';
				edit = "edit";
				del = "del";
				if (stype == 3 ) {
					if (publish == 1) {
						if (mail == 'true') {
							document.getElementById('messageMail').innerHTML = 'פרסום אושר, האם לשלוח מייל ליוזם הפרסום?<br><a href="javascript:void(0);" onclick="displayTemplate('+com_id+','+'edit'+','+stype+')" style="color:#006; text-decoration:underline; font-weight:bold;">כן</a>&nbsp;&nbsp;<a href="?type=partner" style="color:#006; text-decoration:underline; font-weight:bold;">לא</a>';
						}
						else {
							document.getElementById('messageMail').innerHTML = 'פרסום אושר.&nbsp;&nbsp;<a href="?type=partner" style="color:#006; text-decoration:underline; font-weight:bold;">חזרה</a>';
						}
					}
					else {
						if (mail == 'true') {
							document.getElementById('messageMail').innerHTML = 'פרסום נמחק, האם לשלוח מייל ליוזם הפרסום?<br><a href="javascript:void(0);" onclick="displayTemplate('+com_id+','+'del'+','+stype+')" style="color:#006; text-decoration:underline; font-weight:bold;">כן</a>&nbsp;&nbsp;<a href="?type=partner" style="color:#006; text-decoration:underline; font-weight:bold;">לא</a>';
						}
						else {
							document.getElementById('messageMail').innerHTML = 'פרסום נמחק.&nbsp;&nbsp;<a href="?type=partner" style="color:#006; text-decoration:underline; font-weight:bold;">חזרה</a>';
						}
					}
				}
				else {
					if (publish == 1) {
						if (mail == 'true') {
							document.getElementById('messageMail').innerHTML = 'התגובה אושרה, האם לשלוח מייל ליוזם התגובה?<br><a href="javascript:void(0);" onclick="displayTemplate('+com_id+','+'edit'+','+stype+')" style="color:#006; text-decoration:underline; font-weight:bold;">כן</a>&nbsp;&nbsp;<a href="?type=comment&p=sites" style="color:#006; text-decoration:underline; font-weight:bold;">לא</a>';
						}
						else {
							document.getElementById('messageMail').innerHTML = 'התגובה אושרה.&nbsp;&nbsp;<a href="?type=comment&p=sites" style="color:#006; text-decoration:underline; font-weight:bold;">חזרה</a>';
						}
					}
					else {
						if (mail == 'true') {
							document.getElementById('messageMail').innerHTML = 'התגובה נמחקה, האם לשלוח מייל ליוזם התגובה?<br><a href="javascript:void(0);" onclick="displayTemplate('+com_id+','+'del'+','+stype+')" style="color:#006; text-decoration:underline; font-weight:bold;">כן</a>&nbsp;&nbsp;<a href="?type=comment&p=sites" style="color:#006; text-decoration:underline; font-weight:bold;">לא</a>';
						}
						else {
							document.getElementById('messageMail').innerHTML = 'התגובה נמחקה.&nbsp;&nbsp;<a href="?type=comment&p=sites" style="color:#006; text-decoration:underline; font-weight:bold;">חזרה</a>';
						}
					}
				}
			}
		
		else {
			alert('There was a problem with the request.');
		}
	}
	

}
function displayTemplate(com_id, action, type){
document.getElementById('messageMail').style.display = 'none';	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=tmp_url+"/Scripts/displayTemplate.php";
	url=url+"?com_id="+com_id;
	url=url+"&action="+action;
	url=url+"&type="+type;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateSubchangeTMP;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function stateSubchangeTMP()
{
	if (xmlhttp.readyState==4)
	  {
		str = xmlhttp.responseText;

		document.getElementById('templateMail').style.display= 'block'	
		document.getElementById('templateMail').innerHTML = str;
	}	
}

function insertDataToDB(campaign_id){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=tmp_url+"/Scripts/insertDataToDB.php";
	url=url+"?campaign_id="+campaign_id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateinsertDataToDB;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function stateinsertDataToDB()
{
	if (xmlhttp.readyState==4)
	  {
/*		  alert(xmlhttp.responseText);*/
	}	
}

function reorderLinks(dir, id){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=tmp_url+"/Scripts/reorderLinks.php";
	url=url+"?id="+id;
	url=url+"&q="+dir;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=statereorderLinks;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function statereorderLinks()
{
	if (xmlhttp.readyState==4)
	  {
		  /*alert(xmlhttp.responseText);*/
document.location = 'content_management.php?type=dlinks';
/*document.getElementById('links').innerHTML = xmlhttp.responseText;*/
	}	
}

function reorderTips(dir, id){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=tmp_url+"/Scripts/reorderTips.php";
	url=url+"?id="+id;
	url=url+"&q="+dir;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=statereorderTips;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function statereorderTips()
{
	if (xmlhttp.readyState==4)
	  {
		  /*alert(xmlhttp.responseText);*/
document.location = 'content_management.php?type=tiplinks';
/*document.getElementById('links').innerHTML = xmlhttp.responseText;*/
	}	
}

function reorderTipsHP(dir, id){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=tmp_url+"/Scripts/reorderTipsHP.php";
	url=url+"?id="+id;
	url=url+"&q="+dir;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=statereorderTipsHP;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function statereorderTipsHP()
{
	if (xmlhttp.readyState==4)
	  {
		  /*alert(xmlhttp.responseText);*/
document.location = 'content_management.php?type=tipHP';
/*document.getElementById('links').innerHTML = xmlhttp.responseText;*/
	}	
}

function makePOSTRequestFlake(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = stateSubchangeFlake;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
}


function insertFlakeOfWisdom(obj) {
	if (document.FlakeOfWisdomForm.flake_title.value == '' || document.FlakeOfWisdomForm.flake_title.value == 'אנא הכנס פתית'){
		document.FlakeOfWisdomForm.flake_title.value = 'אנא הכנס פתית';
		return;
	}
//	alert(document.commentForm.surfer_name.value);
	flake_title=escape(encodeURI(document.FlakeOfWisdomForm.flake_title.value));
	flake_q_id=escape(encodeURI(document.FlakeOfWisdomForm.flake_q_id.value));
	var poststr = "ft=" + flake_title +
				  "&fqi=" + flake_q_id;

	//alert(poststr);
	makePOSTRequestFlake(tmp_url+'/Scripts/subFlake.php', poststr);
}


function stateSubchangeFlake() {
  if (http_request.readyState == 4) {
	 if (http_request.status == 200) {
		str =  http_request.responseText;
		document.FlakeOfWisdomForm.flake_title.value = '';
		document.getElementById('flakes').innerHTML = str;
		//alert(str);
	}
	else {
		//alert('There was a problem with the request.');
		//alert('http_request.status- '+http_request.status);
	 }
	 

  }
  else {
		document.FlakeOfWisdomForm.flake_title.value = '';
		document.location="/flakes";
	  
  }

  
}

function updateYeh(id,count){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=tmp_url+"/Scripts/subFlake.php";
	url=url+"?id="+id;
	url=url+"&count="+count;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateupdateYeh;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}

function stateupdateYeh()
{
if (xmlhttp.readyState==4)
  {
	str = xmlhttp.responseText;
//	alert(str);
	IndexOfS = str.indexOf('startsting');
	if (IndexOfS != -1){
		IndexOfS = IndexOfS + 10;
		len = str.length;
		str = str.substring(IndexOfS, len);	
	}
	IndexOfS = str.indexOf('id=');
	Ind = IndexOfS ;
	//alert(str);
	//alert(chkResponse);
	if (IndexOfS != -1){
		IndexOfE = 	str.indexOf('count=');
		if (IndexOfE != -1) {
			IndexOfS = IndexOfS +3;
			id = str.substring(IndexOfS,IndexOfE);
			//alert(id);
			//IndexOfS = 	str.indexOf('yeh=');
			IndexOfS = IndexOfE +6;
			IndexOfE = 	str.indexOf('<a');
			if (IndexOfE != -1) {
				count = str.substring(IndexOfS,IndexOfE);
				//alert(id);
				//IndexOfS = 	str.indexOf('yeh=');
				IndexOfS = IndexOfE;
				len=str.length;
				str = str.substring(IndexOfE,len);
				//alert(count);
			}
			else {
			IndexOfE = 	str.indexOf('<img');
			if (IndexOfE != -1) {
				count = str.substring(IndexOfS,IndexOfE);
				//alert(id);
				//IndexOfS = 	str.indexOf('yeh=');
				IndexOfS = IndexOfE;
				len=str.length;
				str = str.substring(IndexOfE,len);
				//alert(count);
			}
			}
		}

	}
		elem1 = 'yeh'+id;
		elem = 'yehImg'+id;
		document.getElementById(elem).innerHTML = str;
		document.getElementById(elem1).innerHTML = '&nbsp;&nbsp;'+count+'&nbsp;Yeh!';
		

  }
}

function ShowAllFlakes(id){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=tmp_url+"/Scripts/ShowAllFlakes.php";
	url=url+"?id="+id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateShowAllFlakes;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function stateShowAllFlakes()
{
	if (xmlhttp.readyState==4)
	  {
		//alert(xmlhttp.responseText);
		str = xmlhttp.responseText;

		IndexOfS = str.indexOf('startsting');
		if (IndexOfS != -1){
			IndexOfS = IndexOfS + 10;
			len = str.length;
			str = str.substring(IndexOfS, len);	
		}
		IndexOfS = str.indexOf('id=');
		Ind = IndexOfS ;
		if (IndexOfS != -1){
			IndexOfE = 	str.indexOf(';-;');
			if (IndexOfE != -1) {
				IndexOfS = IndexOfS +3;
				id = str.substring(IndexOfS,IndexOfE);
				//alert(id);
				IndexOfS = IndexOfE +3;
				len=str.length;
				str = str.substring(IndexOfS,len);
			}
	
		}
		elem = 'flake_q_id'+id;
		document.getElementById(elem).innerHTML = str;
	}	
}
function displayImg(imgid) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=tmp_url+"/Scripts/displayImgGallery.php";
	url=url+"?sid="+Math.random();
	xmlhttp.onreadystatechange=stateSubchangeGal;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
	
}
function stateSubchangeGal()
{
	if (xmlhttp.readyState==4)
	  {
		result = xmlhttp.responseText;
		document.getElementById('msg_sent').innerHTML = result;            
		scrOfY = parseInt(getScrollY());
		myHeight = parseInt(getSizeY());
		myWidth = parseInt(getSizeX());
		topLocation = scrOfY + (myHeight - 443)/2;
		rightLocation = (myWidth - 422)/2;
		document.getElementById('over_overwrapper1').style.right = rightLocation +'px';
		document.getElementById('over_overwrapper1').style.top = topLocation +'px';
/*		document.getElementById('msg_sent').style.display = 'block';
		document.getElementById('msg_sent').innerHTML = xmlhttp.responseText;	
*/	}
}
function reorderPhotos(dir, id, gal_id){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=tmp_url+"/Scripts/reorderPhotos.php";
	url=url+"?id="+id;
	url=url+"&gal_id="+gal_id;
	url=url+"&q="+dir;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=statereorderPhotos;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function statereorderPhotos()
{
	if (xmlhttp.readyState==4)
	  {
		str = xmlhttp.responseText;
		//alert(str);
		IndexOfS = str.indexOf('gal_id=');
		if (IndexOfS != -1){
			IndexOfS = IndexOfS + 7;
			len = str.length;
			str = str.substring(IndexOfS, len);	
			IndexOfE = 	str.indexOf(';');
			if (IndexOfE != -1) {
				gal_id = str.substring(0,IndexOfE);
		
			}
		}

/*alert(xmlhttp.responseText);*/
document.location = 'content_management.php?type=new_gal&act=step2&gal_id='+gal_id;
/*document.getElementById('links').innerHTML = xmlhttp.responseText;*/
	}	
}


/******* DISPLAY MULTIPLE CHOICE ADMIN  *******/
function displayMultipleChoiceAdm(dis, gal_id)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
	var url=tmp_url+"/Scripts/multiple_choice_Adm.php";
		url=url+"?q="+dis;
		url=url+"&gal_id="+gal_id;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=stateChangedMCAdm;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	  	//chance_displayMC(dis);
}


function stateChangedMCAdm()
{
	if (xmlhttp.readyState==4)
	  {
		scrOfY = parseInt(getScrollY());
		myHeight = parseInt(getSizeY());
		myWidth = parseInt(getSizeX());
		topLocation = scrOfY + (myHeight - 400)/2;
		rightLocation = (myWidth - 390)/2-110;
/*		if (scrOfY >0 ) {
			topLocation = 370;
		}
*/		//document.getElementById('over_overwrapper').style.right = rightLocation +'px';
		//document.getElementById('over_overwrapper').style.top = topLocation +'px';
		  
		  
		  
		document.getElementById('multiple_choice').style.display = 'block';
		document.getElementById("multiple_choice").style.position = 'absolute'; 
		document.getElementById("multiple_choice").style.top = topLocation +'px'
		document.getElementById("multiple_choice").style.right= rightLocation +'px'
		document.getElementById("multiple_choice").style.border = '5px solid #474747';
		document.getElementById("multiple_choice").style.color = '#1E4A7B'; 
		document.getElementById("multiple_choice").style.backgroundColor = '#9ed8fb';
		document.getElementById("multiple_choice").innerHTML=xmlhttp.responseText;
	  }
}


function DisableCheckBoxAdm(id,count) {
	if (document.getElementById(id).checked == true){
		for (i=1; i<=count;i++){
			elem=id+'-'+i;
			document.getElementById(elem).disabled=true;
		}
	}
	else {
		for (i=1; i<=count;i++){
			elem=id+'-'+i;
			document.getElementById(elem).disabled=false;
		}
	}
		
}


function SaveMultipleSitesAdm(c_count,s_count, gal_id){
		var poststrC = '';
		var poststrS = '';
		var id = 1;
		for (i=1; i<=c_count;i++){
			while (!isset(document.getElementById(id))){
				id++;	
			}
			if (document.getElementById(id).checked)
				poststrC += id +';';
			id++;
			/*name = i;	
			if (isset(document.getElementsByName(name)[0])){
				boxobj = document.getElementsByName(name)[0];
				if (boxobj.checked == true)
					poststrC += boxobj.value +';';
			}*/			
		}

		for (i=1; i<=1000;i++){
			name = i + '_s';	
			if (isset(document.getElementsByName(name)[0])){
				boxobj = document.getElementsByName(name)[0];
				if (boxobj.checked == true)
					poststrS += boxobj.value +';';
			}
		}
		hp = 0;
		if (isset(document.getElementById('homePage'))) {
			if (document.getElementById('homePage').checked)
				hp = 1;
		}
		/*homePage = 0;
		name = 'homePage';*/
		/*boxobj = document.getElementsByName(name)[0];
		if (boxobj.checked == true)
			homePage = 1;*/
		//alert('countries: '+poststrC +',sites: '+poststrS);
		xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  }
			var url=tmp_url+"/Scripts/save_MCAdm.php";
				url=url+"?c="+poststrC;
				url=url+"&s="+poststrS;
				url=url+"&hp="+hp;
				url=url+"&gal_id="+gal_id;
				url=url+"&sid="+Math.random();
				xmlhttp.onreadystatechange=stateChangedMCExitAdm;
				xmlhttp.open("GET",url,true);
				xmlhttp.send(null);

}

function exitMCAdm(){
	document.getElementById('multiple_choice').style.display = 'none';
}

function stateChangedMCExitAdm(){
	if (xmlhttp.readyState==4)
	  {
		//alert(xmlhttp.responseText);
		document.getElementById('multiple_choice').style.display = 'none';
		document.getElementById('listGalleryLocation').innerHTML = xmlhttp.responseText;
	}
	
}

function OpenPhotoList(gal_id, page) {
	
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
	var url=tmp_url+"/Scripts/photos.php";
		url=url+"?page="+page;
		url=url+"&gal_id="+gal_id;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=stateChangedPhotos;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	  	//chance_displayMC(dis);
}


function stateChangedPhotos()
{
	if (xmlhttp.readyState==4)
	  {
		scrOfY = parseInt(getScrollY());
		myHeight = parseInt(getSizeY());
		myWidth = parseInt(getSizeX());
		topLocation = scrOfY + (myHeight - 600)/2;
		rightLocation = (myWidth - 600)/2;
		  
		document.getElementById('PhotoList').style.display = 'block';
		document.getElementById("PhotoList").style.position = 'absolute'; 
		document.getElementById("PhotoList").style.top = topLocation +'px'
		document.getElementById("PhotoList").style.right= rightLocation +'px'
		document.getElementById("PhotoList").style.border = '2px solid #453b7e';
		document.getElementById("PhotoList").style.color = '#1E4A7B'; 
		document.getElementById("PhotoList").style.backgroundColor = '#ffffff';
		document.getElementById("PhotoList").innerHTML=xmlhttp.responseText;
	  }
}
function exitPL(){
	document.getElementById('PhotoList').style.display = 'none';
}

function SaveMarkedPhotos(maxID, gal_id) {
	var checkedPhotos = '';
	
	for (i=1; i<=maxID;i++){
		name = 'p'+i;	
		if (isset(document.getElementsByName(name)[0])){
			boxobj = document.getElementsByName(name)[0];
			if (boxobj.checked == true)
				checkedPhotos += boxobj.value +';';
		}
	}
	//alert(checkedPhotos);
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=tmp_url+"/Scripts/saveToGal.php";
	url=url+"?p="+checkedPhotos;
	url=url+"&gal_id="+gal_id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChangedSaveToGal;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
			//chance_displayMC(dis);
	
}
function stateChangedSaveToGal()
{
	if (xmlhttp.readyState==4) {
		str = xmlhttp.responseText;
		//alert(str);
		IndexOfS = str.indexOf('gal_id=');
		if (IndexOfS != -1){
			IndexOfS = IndexOfS + 7;
			len = str.length;
			str = str.substring(IndexOfS, len);	
			IndexOfE = 	str.indexOf(';');
			if (IndexOfE != -1) {
				gal_id = str.substring(0,IndexOfE);
		
			}
		}
		
		//alert(xmlhttp.responseText);
		document.location.href ='http://'+document.domain+'/admin/content_management.php?type=new_gal&act=step2&gal_id='+gal_id;
	}
}


function makePOSTRequestQuestion(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = stateSubchangeQuestion;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

function sendQuestion(obj) {
//	alert(document.commentForm.surfer_name.value);
	surfer_name=escape(encodeURI(document.QuestionForm.surfer_name.value));
	surfer_mail= escape(encodeURI(document.QuestionForm.surfer_mail.value));
	Question_content=escape(encodeURI(document.QuestionForm.Question_content.value));
	var poststr = "sn=" + surfer_name  +
				"&sm=" + surfer_mail +
				"&cc=" + Question_content;
	//alert(poststr);
	makePOSTRequestQuestion(tmp_url+'/Scripts/subQuestion.php', poststr);
   }


   function stateSubchangeQuestion() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
			str =  http_request.responseText;

			document.getElementById('flakes').innerHTML = str;
			document.getElementById('changeQuestionButton').src = '/images/plus_sign_comment.jpg';
			document.getElementById('addQuestion').style.color = '#ffffff';
			document.getElementById('QuestionForm').style.display = 'none';
			document.getElementById('Question_content').value = '';

		 
/*			str =  http_request.responseText;
			IndexOfS = str.indexOf('messagesent');
			if (IndexOfS != -1){
				document.getElementById('addQuestion').style.color = '#ffffff';
				document.getElementById('QuestionForm').style.display = 'none';
	
				document.getElementById('afterSend').style.display = 'inline';
			}
*/		}
		else {
 	   alert('http_request.responseText '+http_request.responseText);
           alert('There was a problem with the request.');
         }
    
	  }

	  
   }

function SendMailToAgent() {
	obj = document.leadsFrom;

	FormName = '';
	if (isset(obj.FormName)) {
		if(obj.FormName.checked)
		FormName = obj.FormName.value
	}
	FormPhone = '';
	if (isset(obj.FormPhone)) {
		if(obj.FormPhone.checked)
		FormPhone = obj.FormPhone.value
	}
	
	FormEmail = '';
	if (isset(obj.FormEmail)) {
		if(obj.FormEmail.checked)
		FormEmail = obj.FormEmail.value
	}
	
	FormCountry = '';
	if (isset(obj.FormCountry)) {
		if(obj.FormCountry.checked)
		FormCountry = obj.FormCountry.value
	}

	FormSite = '';
	if (isset(obj.FormSite)) {
		if(obj.FormSite.checked)
		FormSite = obj.FormSite.value
	}

/*	clubmed = '';
	if (isset(obj.clubmed)) {
		if(obj.clubmed.checked)
		FormClubmed = obj.clubmed.value
	}
*/	
	multiClub = '';
	if (isset(obj.multiClub)) {
		if(obj.multiClub.checked)
		multiClub = obj.multiClub.value
	}

	FormLodge = '';
	if (isset(obj.FormLodge)) {
		if(obj.FormLodge.checked)
		FormLodge = obj.FormLodge.value
	}

	FormBudjet = '';
	if (isset(obj.FormBudjet)) {
		if(obj.FormBudjet.checked)
		FormBudjet = obj.FormBudjet.value
	}
	
	FormPersons = '';
	if (isset(obj.FormPersons)) {
		if(obj.FormPersons.checked)
		FormPersons = obj.FormPersons.value
	}	
	
	FormDays = '';
	if (isset(obj.FormDays)) {
		if(obj.FormDays.checked)
		FormDays = obj.FormDays.value
	}	

	FormDate = '';
	if (isset(obj.FormDate)) {
		if(obj.FormDate.checked)
		FormDate = obj.FormDate.value
	}	

	FormMessage = '';
	if (isset(obj.FormMessage)) {
		if(obj.FormMessage.checked)
		FormMessage = obj.FormMessage.value
	}	
	systemMsg = obj.systemMsg.value;
	
	poststrS = '';
	for (i=1; i<=100;i++){
		name = 'agentID' + i;	
		if (isset(document.getElementsByName(name)[0])){
			boxobj = document.getElementsByName(name)[0];
			if (boxobj.checked == true)
				poststrS += i +';';
		}
	}
	
	//alert(poststrS);
	
var poststr = "name=" + escape(encodeURI(FormName))  +
				"&phone=" + escape(encodeURI(FormPhone))+
				"&email=" + escape(encodeURI(FormEmail)) +
				"&country=" + escape(encodeURI(FormCountry)) +
				"&site=" + escape(encodeURI(FormSite)) +
				/*"&clubmed=" + escape(encodeURI(FormClubmed)) +*/
				"&multiClub=" + escape(encodeURI(multiClub)) +
				"&lodge=" + escape(encodeURI(FormLodge)) +
				"&budjet=" + escape(encodeURI(FormBudjet)) +
				"&persons=" + escape(encodeURI(FormPersons)) +
				"&days=" + escape(encodeURI(FormDays)) +
				"&date=" + escape(encodeURI(FormDate)) +
				"&userMessage=" + escape(encodeURI(FormMessage)) +
				"&systemMsg=" + escape(encodeURI(systemMsg)) +
				"&rID=" + escape(encodeURI(obj.id.value)) +
				"&aID=" + poststrS;	   
	   
	   
/*		var poststr = "mytextarea1=" + escape(encodeURI(
document.getElementById("mytextarea1").value )) +"&mytextarea2=" +
escape(encodeURI( document.getElementById("mytextarea2").value ));
*/
	makePOSTandMail(tmp_url+'/Scripts/SendMailToAgent.php', poststr);
	//alert(poststr);
   	

}

function makePOSTandMail(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = stateMail;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

function stateMail() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
			 //alert(http_request.responseText);
			 document.location='content_management.php?type=lead';
         } else {
            alert('There was a problem with the request.');
         }
      }

	  
   }   


/*May 2011*/

function changeSiteVal2011(str, lineNum)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url=tmp_url+"/Scripts/getsite2011.php";
	url=url+"?q="+str;
	url=url+"&ln="+lineNum;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged2011;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged2011()
{
	
	if (xmlhttp.readyState==4)
	  {
		str = xmlhttp.responseText;
		//alert(str);
		IndexOfS = str.indexOf('**LNIS**');
		if (IndexOfS != -1){
			IndexOfS = IndexOfS + 8;
			len = str.length;
			str = str.substring(IndexOfS, len);	
			IndexOfE = 	str.indexOf(';');
			if (IndexOfE != -1) {
				lineNum = str.substring(0,IndexOfE);
		
			}
		}
		//alert(lineNum)
	  el = "sites"+lineNum;	
	  strlen = IndexOfS - 8;
	  str = xmlhttp.responseText
	  str = str.substring(0,strlen);	

	  document.getElementById(el).innerHTML=str;
	  }
}

function subTop5Rating(lineNum) {
	s_id = document.getElementById('s_id'+lineNum).value
	alert(s_id);
}

function stateChangedGetSiteAdmin()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("sites3").innerHTML=xmlhttp.responseText;
  }
}



/*END MAY 2011*/


/*START JULY 2011*/
function checkUncheckAll(task) {
	var inputs = document.getElementsByTagName("input"); //or document.forms[0].elements;  
	for (var i = 1; i < inputs.length; i++) {  
	  if (inputs[i].type == "checkbox") { 
	  	if (document.getElementById('random').checked)  {
			inputs[i].disabled = true;
		}
		else {
			inputs[i].disabled = false;
		}
	  }  
	}
	if (document.getElementById('random').checked)
		document.getElementById('dailySingle').disabled = true;
	else
		document.getElementById('dailySingle').disabled = false;
	
	document.getElementById('random').disabled = false;
	//alert(document.getElementById('random').checked);
}


function SaveMultipleDailyAdm(){
		var poststrC = '';
		var poststrS = '';
		var poststrA = '';
		var dd=0;
		var id = 1;
		if (isset(document.getElementById('random')) && document.getElementById('random') != null && document.getElementById('random').checked) {
				dd=0;
		}
		else {		
			for (i=1; i<200;i++){
				elemC='C-'+i;
				//alert('elem is: '+elem+' id checked = '+document.getElementById(elem).checked);
				if (isset(document.getElementById(elemC)) && document.getElementById(elemC) != null) {
					if (document.getElementById(elemC).checked)
						poststrC += i +';';
				}
				id++;
			}
			id = 1;
			for (is=1; is<500;is++){
				elemS='S-'+is;
				if (isset(document.getElementById(elemS)) && document.getElementById(elemS) != null) {
					if (document.getElementById(elemS).checked)
						poststrS += is +';';
				}
				id++;
			}
			id = 1;
			for (ia=1; ia<100;ia++){
				elemA='A-'+ia;
				if (isset(document.getElementById(elemA)) && document.getElementById(elemA) != null) {
					if (document.getElementById(elemA).checked)
						poststrA += ia +';';
				}
				id++;
			}
			
			if (isset(document.getElementById('dailySingle')) && document.getElementById('dailySingle') != null && document.getElementById('dailySingle').value > 0) {
				dd=document.getElementById('dailySingle').value;
				//alert(dd);
			}
		}
		xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  }
			var url=tmp_url+"/Scripts/save_MCAdmDaily.php";
				url=url+"?c="+poststrC;
				url=url+"&s="+poststrS;
				url=url+"&a="+poststrA;
				url=url+"&dd="+dd;
				url=url+"&sid="+Math.random();
				xmlhttp.onreadystatechange=stateChangedMCExitAdmDaily;
				xmlhttp.open("GET",url,true);
				xmlhttp.send(null);

}

function exitMCAdm(){
	document.getElementById('multiple_choice').style.display = 'none';
}

function stateChangedMCExitAdmDaily(){
	if (xmlhttp.readyState==4)
	  {
		//alert(xmlhttp.responseText);
		//document.getElementById('multiple_choice').style.display = 'none';
		//document.getElementById('listGalleryLocation').innerHTML = xmlhttp.responseText;
		document.location = 'content_management.php';
	}
	
}

function changeMainVideo(activeid, id2, id3) {
	document.getElementById("mainVideoObj"+id2).style.display = 'none';
	document.getElementById("mainVideoObj"+id3).style.display = 'none';
	document.getElementById("videothumbBG"+id2).style.background="";
	document.getElementById("videothumbBG"+id3).style.background="";
	document.getElementById("videothumbBG"+id2).className="THnotactive";
	document.getElementById("videothumbBG"+id3).className="THnotactive";
	document.getElementById("videothumbBG"+activeid).className="THactive"; 
	document.getElementById("videothumbBG"+activeid).style.backgroundImage = "url(images/video_active_BG.jpg)"; 
	document.getElementById("mainVideoObj"+activeid).style.display = 'inline';
	stop();
	stopVideo();
}

/*END JULY 2011*/

function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	  {
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  return new XMLHttpRequest();
	  }
	if (window.ActiveXObject)
	  {
	  // code for IE6, IE5
	  return new ActiveXObject("Microsoft.XMLHTTP");
	  }
	return null;
}
