﻿function getHTTPObject() {
    try{
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
	catch (e){
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e){
        xmlhttp = false;
      }
    }	
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

function search(s){
	if ( s == ''){
		alert("لطفا ابتدا يك عبارت براي جستجو وارد نماييد");
		return false;
	}
	return true;
}

function load_file(file,div,data,loading_img){
	document.getElementById(div).innerHTML = "<div align=center><img src=images/loading/"+loading_img+"></div>";
	data = "rand=" + parseInt(Math.random()*999999999999999) + data ;
	xmlhttp = getHTTPObject();
	xmlhttp.open("POST", file);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			document.getElementById(div).innerHTML = xmlhttp.responseText;
		}
	}	
	xmlhttp.send(data);
return false;
}

function getPos(theObj){
	x = y = 0;
	h = theObj.offsetHeight;
	w = theObj.offsetWidth;
	while(theObj){
		x += theObj.offsetLeft;
		y += theObj.offsetTop;
		theObj = theObj.offsetParent;
	}
	return {height:h,width:w,x:x,y:y}
}

function goTop(){
	scroll(0,0);
	return false;
}

function showlargepic(pic,location){
	rv = getPos(location);
	scroll(0,rv.height);
	opac = 70;
    document.getElementById('show-pic').style.opacity = opac / 100;
    document.getElementById('show-pic').style.MozOpacity = opac / 100;
    document.getElementById('show-pic').style.KhtmlOpacity = opac / 100;
    document.getElementById('show-pic').style.filter = 'alpha(opacity=' + opac + ')';

	document.getElementById('show-pic').style.top = rv.y;
	document.getElementById('show-pic').style.left = rv.x;
	document.getElementById('show-pic').style.width = rv.width;
	document.getElementById('show-pic').style.visibility = 'visible';
	document.getElementById('show-pic').innerHTML = "<table align=center height='"+ rv.height +"' width='"+ rv.width +"'><tr><td height=25 style='text-align:left;color:red;font-weight:bold'>بستن</td></tr><tr><td align=center class='loading_img'><img src='thumbnail.php?src=" + pic + "&w=600&zc=0'></td></tr></table>";
}

function check_email(fullname,email,tel,subject,pm,submit_mail){
  	if (fullname=="" || email=="" || pm=="" ){
       document.getElementById('contact_us').innerHTML = "لطفا فيلدهاي ستاره دار را حتما پر نماييد.";   
       return false;
   	}
   	
   	if (email.match("^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$") == null) {
	   document.getElementById('contact_us').innerHTML = "پست الكترونيك وارد شده معتبر نميباشد لطفا دقت فرماييد.";		   
       return false;
	}
	
	document.getElementById('contact_us').innerHTML = "در حال ارسال پيام ... لطفا منتظر بمانيد";		   
	rand = parseInt(Math.random()*999999999999999);
	data = "rand=" + rand + "&submit_mail=submit_mail" +  "&fullname="+ fullname + "&subject=" + subject + "&email=" + email + "&tel=" + tel + "&pm=" + pm;
	
	xmlhttp1 = getHTTPObject();
	xmlhttp1.open("POST", "contact.us.php");
	xmlhttp1.setRequestHeader(     'Content-Type',     
								  'application/x-www-form-urlencoded; charset=UTF-8' );
	xmlhttp1.onreadystatechange = function() {
	    if (xmlhttp1.readyState == 4 && xmlhttp1.status == 200) {
			document.getElementById('contact_us').innerHTML = xmlhttp1.responseText;
	    }
	}
	xmlhttp1.send(data);
    
return false;
}
