function evalscript(_source) {
		var source = _source;
		var scripts = new Array();
		
		// Strip out tags
		while(source.indexOf("<script") > -1 || source.indexOf("</script") > -1) {
	var s = source.indexOf("<script");
	var s_e = source.indexOf(">", s);
	var e = source.indexOf("</script", s);
	var e_e = source.indexOf(">", e);
	
	// Add to scripts array
	scripts.push(source.substring(s_e+1, e));
	// Strip from source
	source = source.substring(0, s) + source.substring(e_e+1);
		}
		
		// Loop through every script collected and eval it
		for(var i=0; i<scripts.length; i++) {
	try {
		eval(scripts[i]);
	}
	catch(ex) {
		// do what you want here when a script fails
	}
		}
		return source;
}

function GetXmlHttpObject()
{
        var xmlhttp;
        /** Special IE only code ... */
        /*@cc_on
          @if (@_jscript_version >= 5)
              try
              {
                  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
              }
              catch (e)
              {
                  try
                  {
                      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                  }
                  catch (E)
                  {
                      xmlhttp = false;
                  }
             }
          @else
             xmlhttp = false;
        @end @*/

        /** Every other browser on the planet */
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
        {
            try
            {
                xmlhttp = new XMLHttpRequest();
            }
            catch (e)
            {
                xmlhttp = false;
            }
        }

        return xmlhttp;
}

function pageload(page,usediv) {
	var xmlhttp = false;
	xmlhttp = GetXmlHttpObject();
	document.getElementById(usediv).innerHTML= '<center><img src="'+urltemp+'images/Md203203365.gif" /></center>' + document.getElementById(usediv).innerHTML ;
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState == 4 && (xmlhttp.status==200 || window.location.href.indexOf("http")==-1)){
			document.getElementById(usediv).innerHTML = evalscript(xmlhttp.responseText);
		}
	}
    xmlhttp.open("GET", page,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send(null);
   return false;
}
function pagesend(page,usediv,sendpost) {
	var xmlhttp = false;
	xmlhttp = GetXmlHttpObject();
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState == 4 && (xmlhttp.status==200 || window.location.href.indexOf("http")==-1)){
			document.getElementById(usediv).innerHTML = evalscript(xmlhttp.responseText);
		}
	}
    xmlhttp.open("POST", page,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send(sendpost);
   return false;  
}
function orderproduct(productid,linksend,sessionnamber){
	document.getElementById('ordersends').innerHTML= '<center><img src="'+urltemp+'images/Md203203365.gif" /></center>';
	var username = document.getElementById('username').value;
	var lastname = document.getElementById('lastname').value;
	var userphone = document.getElementById('phone').value;
	var codeposti = document.getElementById('codeposti').value;
	var adresekamel = document.getElementById('adresekamel').value;
	var tozih = document.getElementById('tozih').value;
	var usermail = document.getElementById('usermail').value;
	var mobile = document.getElementById('mobile').value;
	if(document.getElementById("typebuy")){
		var xxxss=document.getElementById("typebuy");
		var typebuy =  xxxss.options[xxxss.selectedIndex].text;
	}else{
		var typebuy = 'پرداخت در زمان تحويل';
	}
	if(document.getElementById("id_ostan").selectedIndex){
		var xxxssa=document.getElementById("id_ostan");
		var id_ostan =  xxxssa.options[xxxssa.selectedIndex].text;
		var id_ostan2 =  xxxssa.options[xxxssa.selectedIndex].value;
	}else{
		var id_ostan=document.getElementById("id_ostan").value;
		var id_ostan2 =  1;
	}
	if(document.getElementById("id_shahr").selectedIndex){
		var dsds=document.getElementById("id_shahr");
		var shahr =  dsds.options[dsds.selectedIndex].text;
		var shahr2 =  dsds.options[dsds.selectedIndex].value;
	}else{
		var shahr=document.getElementById("id_shahr").value;
		var shahr2 =  1;
	}
	if(document.getElementById('mablagh')){
		var mablagh = document.getElementById('mablagh').value;
	}else{
		var mablagh = '';
	}
	if(document.getElementById('shomarefish')){
		var shomarefish = document.getElementById('shomarefish').value;
	}else{
		var shomarefish = '';
	}
	if(document.getElementById('tarikh')){
		var tarikh = document.getElementById('tarikh').value;
	}else{
		var tarikh = '';
	}
	pagesend(linksend,'ordersends','shahr='+shahr+'&shahr2='+shahr2+'&id_ostan='+id_ostan+'&id_ostan2='+id_ostan2+'&productid='+productid+'&email='+usermail+'&mobile='+mobile+'&name='+username+'&lastname='+lastname+'&phone='+userphone+'&codeposti='+codeposti+'&typebuy='+typebuy+'&mablagh='+mablagh+'&shomarefish='+shomarefish+'&tarikh='+tarikh+'&adresekamel='+adresekamel+'&tozih='+tozih+'&sessionnamber='+sessionnamber+'&sefareshdarim=ok');
}
function imageopen(limk){
	window.open(limk,'image','status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no ,width=625px,height=467px');
}
function search(link){
	var KeyWord = document.getElementById('search').value;
	document.location.href = link+'search/'+KeyWord+'/';
}
function changesrc(Name,Img) {
	document.images[Name].src=Img;
}
function commentproduct(linksend,sessionnamber){
	var username = document.getElementById('username').value;
	var email = document.getElementById('email').value;
	var web = document.getElementById('web').value;
	var message = document.getElementById('message').value;
	pagesend(linksend,'commentsends','email='+email+'&name='+username+'&message='+message+'&web='+web+'&sessionnamber='+sessionnamber+'&commentdarim=ok');
}
function connectus(linksend,sessionnamber){
	var username = document.getElementById('username').value;
	var email = document.getElementById('email').value;
	var title = document.getElementById('title').value;
	var web = document.getElementById('web').value;
	var message = document.getElementById('message').value;
	pagesend(linksend,'connectus','email='+email+'&name='+username+'&title='+title+'&message='+message+'&web='+web+'&sessionnamber='+sessionnamber+'&payamdarim=ok');
}
function sendmail(linksend,sessionnamber){
	var namefirend = document.getElementById('namefirend').value;
	var emailfirend = document.getElementById('emailfirend').value;
	var productidfirend = document.getElementById('productidfirend').value;
	pagesend(linksend,'sendmails','name='+namefirend+'&type='+productidfirend+'&email='+emailfirend+'&sessionnamber='+sessionnamber+'&maildarim=ok');
}
function searchproduct(value){
value = value.replace(/\&/g, "mdammd").replace(/\?/g, "mdsoalmd").replace(/\+/g, "mdjammd").replace(/\=/g, "mdmosavimd");
pageload(folder+'?search='+value+'&ajax','mainshow');
}
function pigirisefaresh(value){
value = value.replace(/\&/g, "mdammd").replace(/\?/g, "mdsoalmd").replace(/\+/g, "mdjammd").replace(/\=/g, "mdmosavimd");
pageload(folder+'?result='+value+'&ajax','mainshow');
}

//Set the id names of your tablinks (without a number at the end)
var tablink_idname = new Array("tablink","anotherlink")
//Set the id names of your tabcontentareas (without a number at the end)
var tabcontent_idname = new Array("tabcontent","anothercontent") 
//Set the number of your tabs in each menu
var tabcount = new Array("10","10")
//Set the Tabs wich should load at start (In this Example:Menu 1 -> Tab 2 visible on load, Menu 2 -> Tab 5 visible on load)
var loadtabs = new Array("1","10")  


/*Swich EasyTabs Functions - no need to edit something here*/
function easytabs(menunr, active) {
	 menunr = menunr-1;
	for (i=1; i <= tabcount[menunr]; i++){
		if(document.getElementById(tabcontent_idname[menunr]+i)){
			document.getElementById(tabcontent_idname[menunr]+i).style.display = 'none';
		}
		if(document.getElementById(tablink_idname[menunr]+i)){
			document.getElementById(tablink_idname[menunr]+i).className='tab'+i;
		}
	}
	document.getElementById(tablink_idname[menunr]+active).className='tab'+active+' tabactive';
	document.getElementById(tabcontent_idname[menunr]+active).style.display = 'block';
}
