//Image Over Functions----------------------------------------------------------------------------
	function MM_swapImgRestore() { //v3.0
	
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

	function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
//Cookie Functions ------------------------------------------------------------------------	
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	
	var ck = name+"="+value+expires+"; path=/";
	document.cookie = ck;
	
}

function readCookie(name)
{
		
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++)
	{
	var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}
//Hide Layer Function -------------------------------------------------------------------------
function getElementLeft(Elem) {

	var elem = MM_findObj(Elem);
	var xPos = elem.offsetLeft;
	tempEl = elem.offsetParent;
  	while (tempEl != null) {
  		xPos += tempEl.offsetLeft;
	  	tempEl = tempEl.offsetParent;
  	}
	return xPos;
}
function getElementTop(Elem) {
var elem = MM_findObj(Elem);
	var yPos = elem.offsetTop;
	tempEl = elem.offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
	  	tempEl = tempEl.offsetParent;
  	}
	return yPos;
}
function getElementHeight(Elem) {

	var xPos = 0;
	if (MM_findObj(Elem)!=null)
		xPos = MM_findObj(Elem).offsetHeight;
	return xPos;
}
function getElementWidth(Elem) {

	var xPos = 0;
	if (MM_findObj(Elem)!=null)
		xPos = MM_findObj(Elem).offsetWidth;
	return xPos;
}
function getMousePosition()
{

var pos = new Array();
	pos.X = 0;
	pos.Y = 0;
	var e = window.event;
	if (e.pageX || e.pageY)
	{
		pos.X = e.pageX;
		pos.Y = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		pos.X = e.clientX + document.body.scrollLeft;
		pos.Y = e.clientY + document.body.scrollTop;
	}
	// pos.X and pos.Y contain the mouse position relative to the document
	// Do something with this information
	return pos;
}
function showLayer(boxid, parentid)
{
	
	var elemX = getElementLeft(parentid);
	var elemY = getElementTop(parentid);
	var elemW = getElementWidth(parentid);
	var elemH = getElementHeight(parentid);

	if (window.location.href.indexOf('-fa.html')>0)
	{	
		// Opera have no algorithm for right to left 
		// and return wrong X pos (return the position in LefttoRight)
		var OPB=false;uagent = window.navigator.userAgent.toLowerCase();OPB=(uagent.indexOf('opera') != -1)?true:false;		
		if (OPB)
		{
			if (document.body.clientWidth > elemX)
				elemX = document.body.clientWidth- elemX +18;
			else
				elemX = 0;
		}  	
	}
		
	if (MM_findObj(boxid)!=null)
	{
		var box = MM_findObj(boxid);
		box.style.position = "absolute";
		box.style.left = elemX;
		box.style.top  = elemY + elemH;
		box.style.visibility = "visible";		
	}
}
function forceHide(boxid)
{
	if (MM_findObj(boxid)!=null)
		MM_findObj(boxid).style.visibility = "hidden";
}
function hideLayer(boxid) {
	var p = getMousePosition();
	var startX = getElementLeft(boxid); 
	var endX   = startX + getElementWidth(boxid);
	var startY = getElementTop(boxid);
	var endY   = startY + getElementHeight(boxid); 
	if (!((p.X >= startX) && (p.X <= endX) && (p.Y >= startY) && (p.Y <= endY)) )
		MM_findObj(boxid).style.visibility = "hidden";
}
//Change Theme --------------------------------------------------------------------------------
	function setActiveStyleSheet(id) 
	{
	
		var i, a, main;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++) 
		{
			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("id")) 
			{
				if(a.getAttribute("id") != "StyleSheet") a.disabled = true;
				if(a.getAttribute("id") == "Style"+id) 
				{
					a.disabled = false;
				}
			}
		}
		
		createCookie("style", id, 365);
	}
	  
	function getActiveStyleSheet() 
	{
		var cookie = readCookie('style');
		var id = cookie ? cookie : '1';
		return id;
	}

	function ChangeBackgroundColor(td_name,td_color)
	{
		if (MM_findObj(td_name)!=null)
			MM_findObj(td_name).style.backgroundColor = td_color;
	}
	// Change this two function because of some javascript error 
	// that force image object must be in page before the code run  
	function InitStyle()
	{
		
		var cookie = readCookie('style');
		var id ;
		if (cookie)
			id = cookie;
		else
		{
			createCookie("style", 1, 365);
			id = "1";
		}
		setActiveStyleSheet(id);
			
	}
	function InitPreviewImage()
	{
		var x = readCookie('style');
		if (x) 
		{
			MM_findObj('theme'+x+'table').style.borderColor = '#000000';
		}
		else
			MM_findObj('theme1table').style.borderColor = '#000000';
		
	}
	function ThemeTdMouseOut(id)
	{
		var x = readCookie('style');
		if (x==id) 
		{
			MM_findObj('theme'+id+'table').style.borderColor = '#000000';
		} else {
			for (i=1;i<=5;i++)
			{
				if (x != i)
					MM_findObj('theme'+i+'table').style.borderColor = '#ffffff';
			}			
		}		
	}
	function ThemeSelect(id)
	{
	
		for (i=1;i<=5;i++)
		{
			if (id != i)
				MM_findObj('theme'+i+'table').style.borderColor = '#ffffff';
		}
		setActiveStyleSheet(id);
	}
	function TDOver(obj,id)
	{
		MM_findObj('theme'+id+'table').style.borderColor = '#000000';
		obj.style.cursor = 'hand';
	}
	
function OpenCenterWindow(sUrl,sName,iHeight,iWidth)
{

	var top		= (screen.height-iHeight)/2;
	var left	= (screen.width-iWidth)/2;
	window.open(sUrl,sName,"'status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,"+"width="+iWidth+",height="+iHeight+",top="+top+",left="+left+"'");
}
	
function OpenIDCCenterWindow()
{
	OpenCenterWindow('http://www.dpi.ir/idc/idc.htm','IDC',450,770);
}

function TellAFriend(lang)
{
	var leftPos = screen.availWidth/2-(380/2);
	var topPos  = screen.availHeight/2-(360/2);
	var tellWin;
	if((lang==null)||lang=="")
		tellWin = window.open ("tellafriend-fa.html", "TellAFriend", 'left=' + leftPos + ', top=' + topPos + ', width=380, height=360, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no');
	else 
		tellWin = window.open ("tellafriend-"+lang+".html", "TellAFriend", 'left=' + leftPos + ', top=' + topPos + ', width=380, height=360, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no');
}
function loadflash(holderid, theurl, width, height) 
{
	var holder = MM_findObj(holderid);
	if (holder)
	{
		holder.innerHTML ='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width='+ width +'" height="'+ height +'"><param name="movie" value="'+ theurl +'" \/><param name="quality" value="high" \/><embed src="'+ theurl + '" width="'+ width + '" height="'+ height + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" \/><\/embed><\/object>';
	}
}
function loadimage(holderid,theurl) 
{
	var holder = MM_findObj(holderid);
	if (holder)
	{
		MM_findObj(holderid).innerHTML ='<img  src="'+ theurl + '" >';
	}
}