// ' ######## Persian Rahile CMS Client Scripts ####### ' //
var imgs = document.all.tags("img");
for (i=0; i<imgs.length; i++)
	if (imgs[i].src.indexOf(".png") != -1) {
		imgs[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + imgs[i].src + "', sizingMethod='image');";
		imgs[i].src = "/mt/images/blank.gif";
}
function capLock(e){
	kc = e.keyCode ? e.keyCode : e.which;
	sk = e.shiftKey ? e.shiftKey : ((kc == 16) ? true : false);
	if(((kc >= 65 && kc <= 90) && !sk)||((kc >= 97 && kc <= 122) && sk))
		document.getElementById('divCapsLock').style.visibility = 'visible';
	else
		document.getElementById('divCapsLock').style.visibility = 'hidden';
} 
	
//#########################################################
function NoError()
 {
  return true;
 }
window.onerror=NoError;
//#########################################################
function changecolor()
{
	if (nl.style.color !='blue') nl.style.color='blue'; else nl.style.color='red';
}
//#########################################################
function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.opera6=this.agent.indexOf("Opera 6")>-1
	this.opera7=this.agent.indexOf("Opera 7")>-1
	this.opera = (this.opera5 || this.opera6 || this.opera7)
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 || this.opera6 || this.opera7)
	return this	
}
//#########################################################
var bw=new lib_bwcheck()
//window.status = bw.opera7

function loadMessage(htmlID){
if (!bw.mac){
document.getElementById(htmlID).innerHTML="<span class=loadMSG><i>Loading...</i></span>"
}
}
//#########################################################
<!-- hide from JavaScript-challenged browsers
function openWindow(url) {
	popupWin = window.open(url,'new_page','width=425,height=400,top=150,left=150,scrollbars=auto')
}

function OpenFillWin(win, w, h, lr, t){
	var sUrl, sFeature, w, h;
	sUrl = win;
	sFeature = "dialogHeight:"+h+"; dialogWidth:"+w+"; dialogLeft:"+lr+"; dialogTop:"+t+"; scrollbars:no; edge:sunken; resizable:no; help=no; status:no; toolbar:no;";
	window.showModalDialog(sUrl, window, sFeature);
	return;
}

var win = null;
function NewWindow(mypage,myname,w,h,skroll){
	l = (screen.availWidth - w) /2;
	t = (screen.availHeight -h) /2;
	settings = 'height='+h+',width='+w+',top='+t+',left='+l+',scrollbars='+skroll;
	//alert(mypage + myname + settings); 
	win = 	window.open(mypage,myname,settings)
	win.focus();
}

function openWin(win,w,h,sx,sy,skroll) {
if (sx ==''){
	var sx = (screen.availWidth - w) /2;
	var sy = (screen.availHeight -h) /2;
	}
	window.open(win,null,'height='+h+',width='+w+',status=no,toolbar=no,scrollbars='+skroll+',resizable=no,titlebar=no,menubar=no,location=no,left='+sx+',top='+sy,false);
	win.focus();
	//location.reload();
}

var win = null;
function openWin2(mypage,myname,w,h,l,t,skroll){
if (l ==''){
	l = (screen.availWidth - w) /2;
	t = (screen.availHeight -h) /2;
	}
	settings = 'height='+h+',width='+w+',top='+t+',left='+l+',scrollbars='+skroll;
	//alert(mypage + myname + settings); 
	win = 	window.open(mypage,myname,settings)
	win.focus();
}

var win = null;
function showWin(url){
	var skroll = 'yes';
	myname = 'mypage';
	settings = 'width=100,height=100,left=0,top=0,scrollbars='+skroll+',resizable=no,center=no, status=no, help=no';
	//alert(mypage + myname + settings); 
	win = window.open(url,myname,settings)
	win.focus();
}
//#########################################################
function openPollWindow(url,w,h) {
	popupWin = window.open(url,'new_page','width='+w+',height='+h+',scrollbars=yes')
}
function submitPoll(btnPressed) {
	btnPressed.disabled=true;
	if (btnPressed.name == "results") {
		document.Poll.Method_Type.value = "guest_vote";
	} else {
		document.Poll.Method_Type.value = "member_vote";
	}
	document.Poll.submit();
}
//#########################################################
function jumpto2(url){
   window.location=url
}
function OpenSpellCheck(){
	var curCookie = "strMessagePreview=" + escape(document.PostTopic.Message.value);
	document.cookie = curCookie;
	popupWin = window.open('pop_spellcheck.asp', 'preview_page', 'scrollbars=yes,width=650,height=400')
}
function upload() {
	popupWin = window.open('pop_forum_code.asp','new_page','width=500,height=450,scrollbars=yes')
}
// done hiding -->
<!-- hide from JavaScript-challenged browsers
	function mOvr(src,clrOver) {src.bgColor = clrOver;}
	function mOut(src,clrIn)   {src.style.cursor = 'default'; src.bgColor = clrIn;}
// --->
//#########################################################
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}
	//var oNetwork = new ActiveXObject("WScript.Network")
	//sCN = oNetwork.ComputerName;
	//document.cookie= "cn=" + sCN;
//#########################################################
function ChangePage(fnum){
	if (fnum == 1) {
		document.PageNum1.submit();
	}
	else {
		document.PageNum2.submit();
	}
}
//#########################################################
<!--
	function OpenPreview()
	{
	var curCookie = "strMessagePreview=" + escape(document.PostTopic.Message.value);
	document.cookie = curCookie;
	popupWin = window.open('pop_preview.asp', 'preview_page', 'scrollbars=no,width=750,height=450,top=150,left=150')
	}
	function openWindowHelp(url) {
	popupWin = window.open(url,'new_page','width=430,height=200,top=50,left=50')
	}
	//-->
//#########################################################
//	var message=""; 
//function clickIE() {
//	if (document.all) {(message);return false;}
//	} 
//function clickNS(e) {
//	if 
//	(document.layers||(document.getElementById&&!document.all)) { 
//	if (e.which==2||e.which==3) {(message);return false;}
//	}
//} 
//	if (document.layers) {
//	document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;
//	} 
//	else{
//	document.onmouseup=clickNS;document.oncontextmenu=clickIE;
//	} 
//	document.oncontextmenu=new Function("return false") 
//#########################################################
	function PopupPic(sPicURL) { 
     window.open( "pop_image.htm?"+sPicURL, "",  
     "resizable=no,HEIGHT=200,WIDTH=200,status=no,toolbar=no,titlebar=no,menubar=no,location=no"); 
   } 
//#########################################################

<!-- hide from JavaScript-challenged browsers
function openWindow(url) {
	popupWin = window.open(url,'new_page','width=425,height=400')
}
function openWindow1(url) {
	popupWin = window.open(url,'new_page','width=475,height=400')
}
function openWindow2(url) {
	popupWin = window.open(url,'new_page','width=400,height=450')
}
function openWindow3(url) {
	popupWin = window.open(url,'new_page','width=400,height=450,scrollbars=yes')
}
function openWindow4(url) {
	popupWin = window.open(url,'new_page','width=400,height=540')
}
function openWindow5(url) {
	popupWin = window.open(url,'new_page','width=450,height=525,scrollbars=yes,toolbars=yes,menubar=yes,resizable=yes')
}
function openWindow6(url) {
	popupWin = window.open(url,'new_page','width=500,height=450,scrollbars=yes')
}
function openWindow7(url) {
	popupWin = window.open(url,'new_page','width=600,height=510,scrollbars=no')
}
function openSOTW(url) {
	popupWin = window.open(url,'new_page','width=270,height=400,scrollbars=no')
}
function openWindowHelp(url) {
	popupWin = window.open(url,'new_page','width=470,height=200,scrollbars=yes')
}
function openWindowIgnore(url) {
	popupWin = window.open(url,'new_page','width=750,height=450,scrollbars=yes')
}
function openGameWindow(url) {
	popupWin = window.open(url,'new_page','width=full,height=full,scrollbars=no,menubar=no,resizable=yes')
}
function OpenValidate(url) {
  popupWin = window.open(url, 'preview_page', 'scrollbars=yes,width=600,height=400,resizable=yes')
}
function openWindowGal(url) {
	popupWin = window.open(url,'new_page','width=600,height=350,scrollbars=yes')
}
function openWindowProfile(url) {
  popupWin = window.open(url,'new_page','width=680,height=400,scrollbars=yes')
}
function openWindowNewSize(url) {
  popupWin = window.open(url,'new_page','width=400,height=400,scrollbars=yes')
}
function openWindowBuddys(url) {
	popupWin = window.open(url,'new_page','width=525,height=400,scrollbars=yes')
}

// ConquerChat
function openChat() {var MainWindow = window.open("./chat/default.asp?UserName=&login=login&mode=userLogin",'ChatWindow','scrollbars=yes,width=620,height=450,top=0,left=0,resizable=yes');
}
function openPollWindow(url,w,h) {
	popupWin = window.open(url,'new_page','width='+w+',height='+h+',scrollbars=yes')
}
function submitPoll(btnPressed) {
	btnPressed.disabled=true;
	if (btnPressed.name == "results") {
		document.Poll.Method_Type.value = "guest_vote";
	} else {
		document.Poll.Method_Type.value = "member_vote";
	}
	document.Poll.submit();
}

function upload() {
	popupWin = window.open('pop_forum_code.asp','new_page','width=500,height=450,scrollbars=yes')
}
function _Datepicker(i_strFieldName) {
   window.datefield = document.forms.PostTopic[i_strFieldName]; 
   window.open( 'cal_datepicker.asp?FieldName=' + i_strFieldName + '&date=' + window.datefield.value, 'cal', 'width=300,height=300' );
}

function clearMessageField() {
  PostTopic.Message.value='';
  PostTopic.Message.focus();
}

function pop_online() {
  var MainWindow = window.open ('pop_online.asp','new_page','toolbar=no,location=no,menubar=no,scrollbars=yes,width=260,height=500,resizeable=yes,status=no')
}
// done hiding -->

function FCKeditor_OnComplete( editorInstance )
{
	editorInstance.Events.AttachEvent( 'OnBlur', FCKeditor_OnBlur ) ;
	editorInstance.Events.AttachEvent( 'OnFocus', FCKeditor_OnFocus ) ;
}	
function FCKeditor_OnBlur( editorInstance )
{
	editorInstance.ToolbarSet.Collapse() ;
}
function FCKeditor_OnFocus( editorInstance )
{
	editorInstance.ToolbarSet.Expand() ;
}
//#########################################################

//##########Ajax Request###############
var xmlHttp
function getDataAjax(page, query, area){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert("Browser does not support HTTP Request")
	return
	}
	var url = page
	url = url+".asp?"+query
	//alert(url);
	//url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange = function(){
		stateChanged1(area);
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null);
	}

function stateChanged1(areapalce){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
			objID = 'contentinfo'+areapalce;
			//alert(objID);
			document.getElementById(objID).innerHTML=xmlHttp.responseText
		}
	}

function GetXmlHttpObject(){
	//first check for IE:
	if (window.ActiveXObject) {
		var objXMLHttp = 0;
		try {
			objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(ex) {
			try {
				objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(ex) {
				alert("AJAX: your browser does not support proper XMLHTTP");
			}
		}
		return objXMLHttp;
	}
	//maybe Mozilla?
	if (window.XMLHttpRequest)
		return new XMLHttpRequest();
	//unknown browser..
	alert("AJAX: Unknown browser.");
	return 0;
} //end function GetXmlHttpObject
//##########Ajax Request###############	

function hideData(el){
	//alert("Showing Element: "+el);
	objID = 'UI_'+el;
	//alert(objID);
	obj = document.getElementById(objID).style;
		(obj.display == 'none')? obj.display = 'block' : obj.display = 'none';
	}

function handlePageKeyPress() {
	var alreadyConfirmed = false;
	if (event.keyCode==27 && true) {
		if (confirmCloseIfChanged) {
			var thereIsChange = false;
			var inputsArray = document.getElementsByTagName("input");
			var textareasArray = document.getElementsByTagName("textarea");
			var selectsArray = document.getElementsByTagName("select");
 
			for (var i=0; i<inputsArray.length; i++) {
				if (inputsArray[i].loaderCachedLoadedValue != getInputValue(inputsArray[i])) {
					thereIsChange = true;
					break;
				}
			}
	    
			if (!thereIsChange) {
				for (var i=0; i<textareasArray.length; i++) {
					if (textareasArray[i].loaderCachedLoadedValue != textareasArray[i].value) {
						thereIsChange = true;
						break;
					}
				}
			}
 
			if (!thereIsChange) {
				for (var i=0; i<selectsArray.length; i++) {
					if (selectsArray[i].loaderCachedLoadedValue != selectsArray[i].value) {
						thereIsChange = true;
						break;
					}
				}
			}
	    
			if (thereIsChange) {
				if (!DidgahConfirm("ChangedFormEscCloseConfirm", eMessageBoxStyle.exclamation))
					return false;
				else
					alreadyConfirmed = true;
			}
 
			if (escCloseHandler!=null) {
				eval("var ret = " + escCloseHandler + ";");
				if (ret!=true)
					return false;
			}
 
			if (forceEscCloseConfirm==true && !alreadyConfirmed)
				if (!DidgahConfirm())
					return false;
		}
		
	  window.parent.close();
	}
}


function cacheLoadedValues() {
	try {
		if (document.readyState!="complete") {
			setTimeout(cacheLoadedValues, 100);
			return;
		}
  } catch(e) {
		return false;
  }
 
	var inputsArray = document.getElementsByTagName("input");
	var textareasArray = document.getElementsByTagName("textarea");
	var selectsArray = document.getElementsByTagName("select");
 
	for (var i=0; i<inputsArray.length; i++)
	  inputsArray[i].loaderCachedLoadedValue = getInputValue(inputsArray[i]);
 
	for (var i=0; i<textareasArray.length; i++)
	  textareasArray[i].loaderCachedLoadedValue = (textareasArray[i].value==null || textareasArray[i].value==undefined) ? "" : textareasArray[i].value;
 
	for (var i=0; i<selectsArray.length; i++)
	  selectsArray[i].loaderCachedLoadedValue = (selectsArray[i].value==null || selectsArray[i].value==undefined) ? "" : selectsArray[i].value;
}
 
function getInputValue(input) {
  if (input.id=="txtDate" || input.id=="txtTemp" || input.id.toString().substring(0, 12)=="ccDatePicker")
    return null;
  
  try {
    if (input.nextSibling.tagName=="datePicker")
      return null;
  } catch(e) {}
 
  var ret = input.value;
  switch (input.type) {
    case "checkbox":
    case "radio":
      ret = input.checked ? true : false;
      break;
  }
  
  if (ret==undefined)
    ret = "";
 
  return ret;
}
 


//msg = "eMovaghat.net";
//msg = "..." + msg;pos = 0;
//function scrollTitleMSG() {
//document.title = msg.substring(pos, msg.length) + msg.substring(0, pos);
//pos++;
//if (pos >  msg.length) pos = 0
//window.setTimeout("scrollTitleMSG()",200);
//}
//scrollTitleMSG();	
