

//****************************    VARIABLES    *****************************

var screenWidth = screen.availWidth<800 ? screen.availWidth : 800
var screenHeight = screen.availHeight<600 ? screen.availHeight : 600

//****************************    VersionNavigateur    *****************************
	
function VersionNavigateur(Netscape, Explorer) {
  if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||      
      (navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
    return true;
else return false;
}

//****************************    which_browser    *****************************

function which_browser ()
{
	if ( navigator.appName.indexOf("Microsoft") != -1 )
		return "ie";
	else
  		return "ns";
}

//****************************    openHomeWindow    *****************************

function openHomeWindow(lang)
{
	var x = 0;
	var y = 0;
	document.cookie = "lang="+lang;
	var PersianIranWindow = window.open("/home.asp","PersianIranWindow","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=0,width="+screenWidth+",height="+screenHeight);
	while ( !PersianIranWindow ) {}
//	PersianIranWindow.focus();
	x = (screen.availWidth-screenWidth)/2;
	if ( x < 0 )
		x = 0;
	y = (screen.availHeight-screenHeight)/2;
	if ( y < 0 )
		y = 0;
	if ( y > 100 )
		y = 100;
	PersianIranWindow.moveTo(x,y);
	if ( lang == "fr" )
	{
		var msg = "Ce site est en cours de traduction.";
		msg += "<br>Certaines pages sont encore en anglais :-)";
		msg += "<br>Bonne visite.";
		message (msg);
	}
}

//****************************    VerifWindow    *****************************

function VerifWindow(here)
{
	if ( window.name == "PersianIran" || window.name == "PersianIran_Contact" || window.name == "PersianIran_Message"  || window.name == "PersianIran_Help"  || window.name == "PersianIran_Search" || window.name == "PersianIran_Admin" )
		return;
	var x = 0;
	var y = 0;
	
	if (top.name != "PersianIran_SearchResult")
		top.location.href = "/"; //"/contact.asp";
	
	PersianIranWindow = window.open(here,"PersianIranWindow","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=0,width="+screenWidth+",height="+screenHeight);
	x = (screen.availWidth-screenWidth)/2;
	if ( x < 0 )
		x = 0;
	y = (screen.availHeight-screenHeight)/2;
	if ( y < 0 )
		y = 0;
	if ( y > 100 )
		y = 100;
	PersianIranWindow.moveTo(x,y);
	
	if (top.name == "PersianIran_SearchResult")
		top.close();

}

//****************************    Copyright    *****************************

function copyright()
{
	if (event.button!=1)
		//event.cancel;
		return false;
		//alert('Copyright © 2000-2002 PersianIran.com by M.Assadi');
	
}
document.onmousedown=copyright;

//****************************    resize    *****************************

function resize()
{
	if (window.name = "PersianIran")
		return;
		
	window.resizeTo(screenWidth,screenHeight);
}
window.onresize = resize;

//****************************    moveMouseImg    *****************************

var xspacer = -20;
var yspacer = 0;
var mouseFlag = 0;

function moveMouseImg(e)
{
	x = (document.layers) ? e.pageX : event.clientX
	y = (document.layers) ? e.pageY : event.clientY
	mouseFlag=1
}

function mouseImg() {

	if (mouseFlag==1 && document.all)
	{
    	document.all.mouseImg.style.posLeft = x + xspacer + document.body.scrollLeft
		document.all.mouseImg.style.posTop = y + yspacer + document.body.scrollTop	
	}

	if (mouseFlag==1 && document.layers)
	{
		document.mouseImg.left = x + xspacer
		document.mouseImg.top = y + yspacer
	}

	var timer = setTimeout("mouseImg()",10)
}

function makeMouseImg (img)
{
	document.write("<span id='mouseImg' class='pointerImg'><img src='"+img+"'></span>")
	if (document.layers)
	{
		document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = moveMouseImg;
}

//****************************    set_lang    *****************************

function set_lang(lang,here)
{
	document.cookie = "lang="+lang;
	window.location.href=here+"?lang="+lang;
	//window.replace(here)
	//document.location.href.refresh();
	//var PersianIranWindow = window.open("/home.asp","PersianIranWindow","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=0,width=800,height=600");
	if ( lang == "fr" )
		message ("Ce site est sous traduction.<br>Certaines pages sont encore en anglais :-)<br>Bonne visite.")
}

//****************************    openHomeUrl    *****************************

function openHomeUrl(url)
{
	document.write("<form name='PersianIranWindow_form'>");
	document.write("<input type='hidden' name='PersianIranWindow'>");
	document.write("</form>");
	document.PersianIranWindow_form.target = "PersianIranWindow";
	document.PersianIranWindow_form.action = url;
	document.PersianIranWindow_form.PersianIranWindow.value = "PersianIranWindow";
	document.PersianIranWindow_form.submit();
}

//****************************    help_win    *****************************

function help_win ()
{
	var HelpWindow = window.open("/commun/help.asp","HelpWindow","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=0,width=400,height=150");
}

//****************************    search_win    *****************************

function search_win ()
{	
	var x = 0;
	var y = 0;
	var SearchWindow = window.open("/commun/search.asp","SearchWindow","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=0,width=700,height=500");
	x = (screen.availWidth-700)/2;
	if ( x < 0 )
		x = 0;
	y = (screen.availHeight-500)/2;
	if ( y < 0 )
		y = 0;
	if ( y > 100 )
		y = 100;
	SearchWindow.moveTo(x,y);
}

//****************************    message    *****************************

function message(msg)
{
	var MessageWindow = window.open("/commun/message.asp?message="+msg,"MessageWindow","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=0,width=400,height=150");
}

//****************************    openWin    *****************************

function openWin(url)
{
	url=""+url;
	newWin = window.open(url, "", "height=600, width=800, scrollbars=1");
	newWin.moveTo(0,0);
}

//****************************    swapImage    *****************************
var imageName;
var imageSrc;

function restoreImgOver()
{
	if ( imageName == "" )
		return
	eval( "document."+imageName+".src = '"+imageSrc+"'");
}

function goImgOver(imgName,imgOver)
{
	imageName = imgName;
	if ( imageName == "" )
		return
	imageSrc = eval("document."+imgName+".src");
	
	eval("document."+imgName+".src = '"+ imgOver+"'");
}

//****************************    add_favorite    *****************************

function add_favorite ()
{
	if ( which_browser() == "ie" )
		window.external.AddFavorite("http://www.persianiran.com","PersianIran.com" );
	else
		message ("Internet explorer only :-)");
}
//***************************************************************************
//***************************************************************************
//***************************************************************************

