function write_in_id(id,note){
 	if(document.getElementById(id)){
 		document.getElementById(id).innerHTML=note;
	}
}

function doeval(js){
	if(js!=null){
	var sc = document.createElement('script');
	jsCode = js;
	sc.type = 'text/javascript';
	document.getElementsByTagName('head')[0].appendChild(sc);
	sc.text = 'try{eval(jsCode);}catch(e){}jsCode="";';
	sc.text = "\/\/ :-)";
	}
}

function getscript(str){
let_out=str;
	jstr=let_out.split('<script>');
	if( jstr[1] !=null){
		newstr=jstr[1].split('</script>');
		if( newstr[1] !=null){
			setTimeout("doeval( newstr[0] )", 500);
		}
	}
return let_out;
}

function ajax(url , thisid, post){
 	var xmlhttp=false;
      write_in_id(thisid, '<center><img src=\"../../../../themes/modern/images/loading.gif\"></center>') ;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         xmlhttp = new XMLHttpRequest();
         if (xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/html');
      } else if (window.ActiveXObject) { // IE
         try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!xmlhttp) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
        if (post) { xmlhttp.open('POST', url, true); } else { xmlhttp.open('GET', url, true); }
        
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); post+='&my_time='+escape(new Date().getTime());
        xmlhttp.send(post); 
        xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState == 4  && xmlhttp.status == 200){
				my_respons=xmlhttp.responseText;
				my_respons = my_respons.replace('\n', '');
				my_respons = my_respons.replace('\r', '');
				my_respons = getscript(my_respons);
				document.getElementById(thisid).innerHTML =my_respons;
             }
        }
}

function LoadFunctions(){
	window.document.frm_search.tag.style.color = "#8F8F8F"
	window.document.frm_search.tag.value = "جستجو در سايت"
}
 
function SetTextBoxColorInGotFocus(TextBox){
	if (TextBox=="2"){
		if (window.document.frm_search.tag.value == "جستجو در سايت"){
			window.document.frm_search.tag.value = ""
			window.document.frm_search.tag.style.color = "#000000"
		}else{
			window.document.frm_search.tag.style.color = "#000000"
		}
	}
}
 
function SetTextBoxColorInLostFocus(TextBox){
if (TextBox=="2"){
	if (window.document.frm_search.tag.value == ""){
		window.document.frm_search.tag.value = "جستجو در سايت"
		window.document.frm_search.tag.style.color = "#8F8F8F"
	}else{
		window.document.frm_search.tag.style.color = "#8F8F8F"}
	}
}

