
var Browsers = navigator.userAgent.toLowerCase();
NS  = ( (Browsers.indexOf('mozilla')!=-1) && ( (Browsers.indexOf('spoofer')==-1) && (Browsers.indexOf('compatible') == -1) ) );
NS6 = ( (document.getElementById) && (!document.all) && (Browsers.indexOf("opera") == -1) );
IE = ( (Browsers.indexOf("msie") != -1) && (Browsers.indexOf("opera") == -1) );
OP = (Browsers.indexOf("opera") != -1);
stdBrowser=(document.getElementById) ? true : false;
obj=(document.images);
var widBody = null;
var cntEvent = true , TestLoad = false;
var Locationx = Locationy=1,argWidth=0;
var Timehide = refvar = HideLater = setTimeout("null",1);
var catWindow = null;
var preWindow = new Array();
var	Counter = 0;

//************* Load Images *************\\


function LoadImages(){
	if(obj){
		imgsArray = new Array();
		var arg = 	LoadImages.arguments;
		for(var i=0 ; i<arg.length ; i++){
			imgsArray[i] = new Image();
			imgsArray[i].src = arg[i];
		}
	}
}
switch(classPage){
	case "pHome" :
		LoadImages('../images/hevercircle_on.gif','../images/hevercircle_on.gif'
		,'../images/phaboutusw_on.gif','../images/phproductsw_on.gif','../images/phformsw_on.gif','../images/phmarketingw_on.gif','../images/phcontactusw_on.gif');
		break;
	case "eHome" :
		LoadImages('../images/hpvercircle_on.gif','../images/havercircle_on.gif'
		,'../images/ehaboutusw_on.gif','../images/ehproductsw_on.gif','../images/ehformsw_on.gif','../images/ehmarketingw_on.gif','../images/ehcontactusw_on.gif');
		break;
	case "aHome" :
		LoadImages('../images/hpvercircle_on.gif','../images/hevercircle_on.gif'
		,'../images/ahaboutusw_on.gif','../images/ahproductsw_on.gif','../images/ahformsw_on.gif','../images/ahmarketingw_on.gif','../images/ahcontactusw_on.gif');
		break;
	case "Persian":
		LoadImages('../images/avercircle_on.gif','../images/evercircle_on.gif','../images/faqcircle_on.gif','../images/khorasancircle_on.gif'
		,'../images/paboutusw_on.gif','../images/pproductsw_on.gif','../images/pforumsw_on.gif','../images/pmarketingw_on.gif','../images/pcontactusw_on.gif');
		break;
	case "English":
		LoadImages('../images/avercircle_on.gif','../images/pvercircle_on.gif','../images/faqcircle_on.gif','../images/khorasancircle_on.gif');
		break;
	case "Arabic":
		LoadImages('../images/apvercircle_on.gif','../images/evercircle_on.gif','../images/faqcircle_on.gif','../images/khorasancircle_on.gif'
		,'../images/aaboutusw_on.gif','../images/aproductsw_on.gif','../images/aforumsw_on.gif','../images/amarketingw_on.gif','../images/acontactusw_on.gif');
		break;
}


//************* End Load Images *************\\



//************* Rollover *************\\



function Mouseover() {
	if(obj){
		if(Mouseover.arguments[2]){
			if(Mouseover.arguments[1]=="true") {document[Mouseover.arguments[0]].src=("images/" + Mouseover.arguments[0] + "_on.jpg");}
			else {document[Mouseover.arguments[0]].src=("../images/" + Mouseover.arguments[0] + "_on.jpg");}
		}
		else{
			if(Mouseover.arguments[1]=="true") {document[Mouseover.arguments[0]].src=("images/" + Mouseover.arguments[0] + "_on.gif");}
			else {document[Mouseover.arguments[0]].src=("../images/" + Mouseover.arguments[0] + "_on.gif");}
		}		
	}
}

function Mouseout() {
	if(obj){
		if(Mouseout.arguments[2]){
			if(Mouseout.arguments[1]=="true") {document[Mouseout.arguments[0]].src = ("images/" + Mouseout.arguments[0] + ".jpg");}
			else {document[Mouseout.arguments[0]].src = ("../images/" + Mouseout.arguments[0] + ".jpg");}
		}
		else{
			if(Mouseout.arguments[1]=="true") {document[Mouseout.arguments[0]].src = ("images/" + Mouseout.arguments[0] + ".gif");}
			else {document[Mouseout.arguments[0]].src = ("../images/" + Mouseout.arguments[0] + ".gif");}
		}		
	}
}



//************* End  Rollover *************\\


//************* Position Layer *************\\

function styObject(nLayer , number){
	if(stdBrowser) {document.getElementById(nLayer).style.left = number + "px";}
	else if(IE) {document.all[nLayer].style.pixelLeft = number;}
}

function posLayer(){
	if ( (screen.width >= 1024) ) {newWidth = (screen.width - 780) / 2;}	
	else {newWidth = 0;}
	styObject("divBody",newWidth);
	if(classPage=="English" || classPage=="Persian" || classPage=="Arabic"){
		number = newWidth + LeftFloat;
		styObject("Floating",number);
		if( (stdBrowser && document.getElementById("divBody")) || (IE && document.all.divBody) ){
			for(var j=0 ; j<idLayer[0].length ; j++){
				relWidth = (stdBrowser) ? document.getElementById("divBody").style.left : document.all.divBody.style.pixelleft;
				number = parseInt(relWidth)+idLayer[2][j];
				styObject(idLayer[0][j],number);
			}
		}
	}
	else if(classPage=="eHome" || classPage=="pHome" || classPage=="aHome"){	
		if( (stdBrowser && document.getElementById("divBody")) || (IE && document.all.divBody) ){
			for(var j=0 ; j<Menus.length ; j++){
				relWidth = (stdBrowser) ? document.getElementById("divBody").style.left : document.all.divBody.style.pixelleft;
				number = Menus[j][1][1] + parseInt(relWidth);
				styObject(Menus[j][0][1],number);
			}
		}		
	}
}

window.onresize = posLayer;

//************* End Position Layer *************\\


//************* ToolTip *************\\


function ShowTooltip(){
	var posX=0;
	if(IE){
		Locationx = window.event.clientX;
		Locationy =window.event.clientY;
		if ( (widBody > 784) ) {divProperty.pixelLeft = Math.min(924,parseInt(Locationx)-2);}
		else{
			if(argWidth){
				posX=parseInt(Locationx);
				if( (argWidth+posX)>=780 ) {divProperty.pixelLeft=posX-argWidth;}
				else {divProperty.pixelLeft = Math.min( 780,parseInt(Locationx)-2);}
			}
			else {divProperty.pixelLeft = Math.min( 780,parseInt(Locationx)-2);}
		}
		divProperty.pixelTop = parseInt(Locationy) + 18;	
	}
	else if(NS6){
		Locationx = parseInt(event.pageX);
		Locationy = parseInt(event.pageY);
		if ( (widBody > 780) ) {Math.min(924,parseInt(Locationx)-2) + "px";}
		else{
			if(argWidth){
				posX=parseInt(Locationx);
				if( (argWidth+posX)>=780 ) {divProperty.left=(posX-argWidth)+"px";}
			}
			else {divProperty.left = Math.min(700,parseInt(Locationx)-2) + "px";}
		}
		divProperty.top = parseInt(Locationy) + 25 + "px";			
	}
	clearTimeout(Timehide);
	Timehide = setTimeout('divProperty.visibility = "visible"',500);
}

function ToolTip(position,namLayer){
	argWidth=ToolTip.arguments[2];	
	divProperty = (stdBrowser) ? document.getElementById(namLayer).style : document.all[namLayer].style;
	switch(position){
		case "Over" :
			ShowTooltip();
			break;
		case "Out" :
			clearTimeout(Timehide);
			Timehide = setTimeout("null",1);
			divProperty.visibility = "hidden";
			break;
	}
}


//************* End ToolTip *************\\


//************* Visibility *************\\


function VisibilityLayer() {
	clearTimeout(HideLater);
	HideLater = setTimeout("null",1);
	argFunction=VisibilityLayer.arguments.length;
	for(i=0 ; i<(argFunction-1) ; i+=2) {
		if(stdBrowser){ divPropertie=document.getElementById(VisibilityLayer.arguments[i]).style;}
		else {divPropertie = document.all[VisibilityLayer.arguments[i]].style;}
		divPropertie.visibility = (VisibilityLayer.arguments[i+1]=="show") ? "visible" : "hidden";
	}
}
function HideAll(nLayer){
	clearTimeout(HideLater);
	HideLater = setTimeout("null",1);
	for(var i=0 ; i<idLayer[0].length ; i++){
		divPropertie = (stdBrowser) ? document.getElementById(idLayer[0][i]).style : document.all[idLayer[0][i]].style;
		if( nLayer == "null" ) {divPropertie.visibility="hidden";}
		else if( idLayer[0][i] != nLayer ) {divPropertie.visibility="hidden";}
	}
}
function HideControl(NmLayer){
	divPropertie = (stdBrowser) ? document.getElementById(NmLayer).style : document.all[NmLayer].style;
	clearTimeout(HideLater);
	HideLater = setTimeout('divPropertie.visibility="hidden"',500);
}


//************* End Visibility *************\\




//************* New Windows *************\\


function newWindow(){
	if(catWindow){
		if(!catWindow.closed) {catWindow.close();}
	}
	var LeftWin=TopWin=WidthWin=HeightWin=0;
	var varScroll=adPage="null";
	if(newWindow.arguments[0]>=800){
		WidthWin = 760;
		varScroll="yes";
	}
	else if(newWindow.arguments[0]<800){
		WidthWin = newWindow.arguments[0];
		varScroll="no";
	}
	if(newWindow.arguments[1]>=600){
		HeightWin = 460;
		varScroll="yes";
	}
	else if(newWindow.arguments[1]<600){
		HeightWin = newWindow.arguments[1];
		varScroll="no";
	}
	adPage = newWindow.arguments[2];	
	namPage = "CatWin" + Counter;	
	if(screen){
		LeftWin=((screen.width - WidthWin) / 2 ) + "px";
		TopWin=((screen.height - HeightWin) / 2) + "px";
	}
	if(opener&&opener.catWindow){
		if(opener.catWindow.name==namPage){
			Counter+=1;
			namPage = "CatWin" + Counter;	
		}
	}
	catWindow=window.open(adPage,namPage,"left="+LeftWin+",top="+TopWin+",height="+HeightWin+",width="+WidthWin+",directories=no,status=no,resizable=no,toolbar=no,menubar=no,location=no,scrollbars="+varScroll+"");
	preWindow[Counter]=catWindow;
	if(newWindow.arguments[3]){
		catWindow.document.open();
		catWindow.document.writeln("<html>");
		catWindow.document.writeln("<head>");
		catWindow.document.writeln("<meta http-equiv=\"content-type\" content=\"text/html;charset=windows-1252\" \/>");
		catWindow.document.writeln("<meta name=\"generator\" content=\"Adobe GoLive 6\" \/>");
		catWindow.document.writeln("<title>Welcome to ShadabKhorasan : : : " + newWindow.arguments[3] + " : : :<\/title>");
		catWindow.document.writeln("<link href=\"../css/shadabkhorasan.css\" rel=\"stylesheet\" media=\"screen\">");
		catWindow.document.writeln("<\/head>");
		catWindow.document.writeln("<body>");
		if(newWindow.arguments[4]=="media"){
			catWindow.document.writeln("<p><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.#version=5,0,30,0\" width=\""+newWindow.arguments[0]+"\" height=\""+newWindow.arguments[1]+"\">"+
			"<param name=\"movie\" value=\"../media/"+newWindow.arguments[2]+"\"><param name=\"quality\" value=\"best\">"+
			"<param name=\"play\" value=\"true\">"+
			"<embed pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" src=\"../media/"+newWindow.arguments[2]+"\" type=\"application/x-shockwave-flash\" quality=\"best\" play=\"true\" width=\""+newWindow.arguments[0]+"\" height=\""+newWindow.arguments[1]+"\"><\/object></p>");
		}
		else{
			catWindow.document.writeln("<p><img border=\"0\" src=\"../images/"+newWindow.arguments[2]+"\"></p>");
		}
		catWindow.document.writeln("<\/body>");
		catWindow.document.writeln("<\/html>");
		catWindow.document.close();
	}
	Counter+=1;
	catWindow.focus();
}


//************* End New Windows *************\\
switch(classPage){
	case "aHome" :
		BuildHommenu();
		break;
	case "pHome" :
		BuildTooltips();
		BuildHommenu();
		break;		
	case "eHome" :
		BuildHommenu();
		break;
	default :
		if( (classPage=="Persian") || (classPage=="Arabic") ) {BuildTooltips();}
		BuildMenu();
		Buildfloat();
		Mover();
}


