////////////<SCRIPT>
function collex(id) 
{
	if(document.getElementById('ID'+id).style.display == "none")
	{
		document.getElementById('ID'+id).style.display = "Block";
		document.getElementById('img'+id).src="images/downboxed1.gif";
	}
	else
	{
		document.getElementById('ID'+id).style.display = "none";
		document.getElementById('img'+id).src="images/downboxed0.gif";
	}
}
///////////////////
function SHOW_FULL(id) 
{
	if(document.getElementById(id+'_FULL').style.display == "none")
	{
		document.getElementById(id+'_FULL').style.display = "Block";
		document.getElementById(id).style.display = "none";
	}
	else
	{
		document.getElementById(id+'_FULL').style.display = "none";
		document.getElementById(id).style.display = "Block";
	}
}
///////////////////
function TO_LTR(id)
{
		document.getElementById(id).style.direction = "ltr";
}
function TO_RTL(id)
{
		document.getElementById(id).style.direction = "rtl";
}

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function checksms(theForm, nset)
{
 	if( theForm.message.value == '' ) 
		{
	 	alert("لطفا متن پیام خود را وارد نمایید");
	 	theForm.message.focus();
	 	return false;
	 	}

	if( nset == 2 )
		if( !searchFormobile.test(theForm.mobile.value)) 
			{
			alert("لطفا شماره گیرنده پیامک را به درستی وارد کنید");
			theForm.mobile.focus();
			return false;
			}

	if( nset == 3 )
		{
		if( !searchFormobilesg.test(theForm.to.value)) 
			alert("یکی یا تعدادی از شماره گیرنده ها دارای فرمت صحیحی نیستند. امکان ارسال همه آنها وجود ندارد");
		}
		
	if( nset == 4 || nset == 5 )
		{
		if( !searchFormobile.test(theForm.to.value)) 
			{
			alert("لطفا شماره گیرنده های پیامک را به درستی وارد کنید");
			theForm.to.focus();
			return false;
			}
		if( theForm.to2.value == '' ) 
			{
		 	alert("لطفا تعداد شماره بعد ارسال از شماره خود را وارد کنید");
		 	theForm.to2.focus();
		 	return false;
		 	}
		if( !isInteger(theForm.to2.value) ) 
			{
		 	alert("تعداد شماره بعد ارسال از شماره باید عددی باشد");
		 	theForm.to2.focus();
		 	return false;
		 	}
		if( parseInt(theForm.to2.value) < 1 )
			{
		 	alert("تعداد شماره بعد ارسال از شماره نمی تواند کمتر از یک باشد");
		 	theForm.to2.focus();
		 	return false;
			}
		if( parseInt(theForm.to2.value) > 9900 )
			{
		 	alert("تعداد شماره بعد ارسال از شماره نمی تواند بیشتر از 9900 باشد");
		 	theForm.to2.focus();
		 	return false;
			}
		}
		
 	if( nset == 5 )
 		{
		if( theForm.tomin.value == '' ) 
			{
		  alert("لطفا حداقل فاصله بین شماره ها را وارد کنید");
		  theForm.tomin.focus();
		  return false;
		  }
		if( !isInteger(theForm.tomin.value) ) 
			{
		 	alert("حداقل فاصله بین شماره ها باید عددی باشد");
		 	theForm.tomin.focus();
		 	return false;
		 	}
		if( parseInt(theForm.tomin.value) < 1 )
			{
		 	alert("حداقل فاصله بین شماره ها نمی تواند کمتر از یک باشد");
		 	theForm.tomin.focus();
		 	return false;
			}
 		if( theForm.tomax.value == '' )
 			{
 			alert("لطفا حداکثر فاصله بین شماره ها را وارد کنید");
 			theForm.tomax.focus();
 			return false;
 			}
		if( !isInteger(theForm.tomax.value) ) 
			{
		 	alert("حداکثر فاصله بین شماره ها باید عددی باشد");
		 	theForm.tomax.focus();
		 	return false;
		 	}
		if( parseInt(theForm.tomax.value) > 1000 )
			{
		 	alert("حداکثر فاصله بین شماره ها نمی تواند بیشتر از هزار باشد");
		 	theForm.tomax.focus();
		 	return false;
			}
		if( parseInt(theForm.tomin.value) >= parseInt(theForm.tomax.value) )
			{
		 	alert("حداکثر فاصله بین شماره ها باید بزرگتر از حداقل فاصله بین شماره ها باشد");
		 	theForm.tomax.focus();
		 	return false;
			}
 		}

	if( nset == 6 )
		{
 		if( theForm.dbefore.value == '' )
 			{
 			alert("لطفا بازه زماني پيش از موعد را مشخص كنيد");
 			theForm.dbefore.focus();
 			return false;
 			}
		if( !isInteger(theForm.dbefore.value) ) 
			{
		 	alert("بازه زماني پيش از موعد باید عدد مثبت باشد");
		 	theForm.dbefore.focus();
		 	return false;
		 	}
 		if( theForm.datekind.value != 'D' && theForm.datekind.value != 'M' )
 			{
 			alert("لطفا روز يا ماه را انتخاب كنيد");
 			theForm.datekind.focus();
 			return false;
 			}

 		if(  theForm.wdate.value != '0' && theForm.wdate.value != '1' && theForm.wdate.value != '2' && theForm.wdate.value != '3' && theForm.wdate.value != '4' && theForm.wdate.value != '5' )
 			{
 			alert("لطفا يكي از تاريخهاي مورد نظر را مشخص كنيد");
 			theForm.wdate.focus();
 			return false;
 			}
 			
		if( theForm.datekind.value == 'D' )
			{
			if( theForm.dbefore.value < 0 || theForm.dbefore.value > 29 )
				{ 
	 			alert("بازه زماني بايد بين صفر و 29 روز باشد");
	 			theForm.dbefore.focus();
	 			return false;
	 			}
			}
		else
			{
			if( theForm.dbefore.value < 1 || theForm.dbefore.value > 11 )
				{ 
	 			alert("بازه زماني بايد بين 1 و 11 ماه باشد");
	 			theForm.dbefore.focus();
	 			return false;
	 			}
			}
		}

	document.getElementById("SubmitImage").style.cursor= 'not-allowed';
	document.getElementById("SubmitImage").disabled=true;
	return true;
// return disablesubmit(theForm);
}

///////////////
function checklogin(theForm) { 
 if (theForm.username.value=='') {
 alert("لطفا نام کاربری خود را وارد کنید");
 theForm.username.focus();
 return false;
 }
 if (theForm.password.value=='') {
 alert("لطفا پسورد خود را وارد کنید");
 theForm.password.focus();
 return false;
 }
 
 return disablesubmit(theForm);
}
/////////////////
function copytoclipboard(elemnt) {
        document.getElementById(elemnt).select();
        document.getElementById(elemnt).focus();
        if (document.all) {
            textRange = document.getElementById(elemnt).createTextRange();
            textRange.execCommand("RemoveFormat");
            textRange.execCommand("Copy");
            alert("کد مورد نظر شما در حافظ موقت سیستم شما ذخیره شد.");
        }
    }
 
function isFarsi(msg)
{
 var searchForFarsi = /[ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی×÷ئ؛،ـآۀ؟ءأإؤیةكي]/;
 
 return searchForFarsi.test(msg);
}

    
//var SET_page= 1;
function count_text(message_Field,count_Field,count_Field_page,sbytes,allo,kc)
{
	var i;
	var maxBit = (sbytes * 8);
	var reallen = message_Field.value.length;
	var MaxChars;
	var pages;
	var param;
	var dec;
	var no_alert = 0;
	var cnt;

	if( kc == 16 || kc == 17 || kc == 18 )
		return;
		
	if( isFarsi(message_Field.value) )
		{
		param = 16;
		dec = 6;
		}
	else
		{
		param = 7;
		dec = 5;
		}
	
	reallen = reallen * param;
	if( reallen > maxBit )
		maxBit = (maxBit - (dec * 8));

	MaxChars = Math.floor((allo * (sbytes - dec) * 8) / param);

	if( reallen <= maxBit * (parseInt(count_Field_page.value) - 1) && parseInt(count_Field_page.value) > 1 )
		{
		count_Field_page.value = parseInt(count_Field_page.value) - 1;
		no_alert = 1;
		}
		
	cnt = parseInt(Math.floor((maxBit - (reallen - ((parseInt(count_Field_page.value) - 1) * (sbytes - dec) * 8))) / param));

	if ( cnt <= 0 ) 
		{
		if( cnt < 0 )
			{
			if( reallen % maxBit )
				{
				count_Field.value = parseInt(Math.floor((maxBit - (reallen % maxBit)) / param));
				}
			else
				{
				count_Field.value = parseInt(Math.floor(((maxBit - (reallen % maxBit)) - maxBit) / param));
				}
			}
		else
			count_Field.value = cnt;

		pages = parseInt(Math.ceil(reallen / maxBit));
		if( cnt == 0 )
			pages = pages + 1;
		if( message_Field.value.length >= MaxChars )
			{
			message_Field.value = message_Field.value.substring(0, MaxChars);
			count_Field.value = 0;
			pages = pages - 1;
			if (allo > 1)
				{ 
				alert("کاربر گرامی تعداد کاراکتر مجاز شما به پایان رسید\nتعداد صفحات ارسالی شما" + pages + " عدد می باشد" );
				}
			else
				{
				alert("کاربر گرامی تعداد کاراکتر مجاز شما به پایان رسید" );
				} 
			message_Field.blur();
			}
		else
		 	{
		 	if( !no_alert )
		 		{
		 		if( pages <= allo )
		 			{
					alert("کاربر گرامی تعداد کاراکتر این صفحه شما به پایان رسید\nشما در صفحه " + pages + " قرار گرفته اید");
					message_Field.blur();
					}
				}
			if (count_Field_page !== "")
				{
			  count_Field_page.value = pages;
			 	}
			}
		}
	else
		{
		count_Field.value = cnt;
		}
}

function disablesubmit(theForm) 
{
	ua = new String(navigator.userAgent);
	if (ua.match(/IE/g)) 
	{
		for (i=1; i<theForm.elements.length; i++) 
			{
			if (theForm.elements[i].type == 'submit') 
				{
				theForm.elements[i].disabled = true;
				}
			}
		theForm.submit();
	}
	
	return true;
}

function disablesend()
{
	document.getElementById('sendsmsbtn').innerHTML = "<img src=\"/images/send_bd.gif\" alt=\"ارسال پیام کوتاه\" title=\"ارسال پیام کوتاه\"  width=\"73\" height=\"32\" />";
}

/////////////////عدد وارد شود
 var searchForNumbers2 = /^(d{1})?(\d{1})?(\d{2})?(\d{3})?(\d{4})?(\d{5})?(\d{6})?(\d{7})?(\d{8})?$/
function check_number(name) {

 if(!searchForNumbers2.test(name.value)){
 name.value = 0
 alert("کاربر گرامی در این کادر عدد صحیح وارد کنید");
 return false;
 }
 if(name.value == ''){
 name.value = 0
 alert("کاربر گرامی در این کادر عدد صحیح وارد کنید ");
 return false;
 }

}
//////////////////عدد وارد شود
/////////////////شماره مبایل وارد شود
var searchFormobile = /^09(\d{9})$/
var searchFormobiles = /^(09(\d{9})[\n\r]+)+(09(\d{9})[\n\r]*)$/
var searchFormobilesg = /^(09(\d{9})[\n\r]+|[\[\(](\d{1,6})(:(\d+);(\d+))?[\]\)][\n\r]+)+(09(\d{9})[\n\r]*|[\[\(](\d{1,6})(:(\d+);(\d{1,6}))?[\]\)][\n\r]*)*$/
function check_mobile(mobile,nn) {

 if((mobile).value.length > 10 || nn > 0 ){
	if(!searchFormobile.test(mobile.value)){
	 alert("لطفا شماره همراه مورد نظر خود را به درستی وارد کنید");
	  mobile.value = ''
	 return false;
	 }
 }
}
/////////////////شماره مبایل وارد شود

/////////دستورات بازکردن صفحه متحرک
function box_move(SET_TEXT){
 document.getElementById('windows_m').style.display ='';
 my_div_mover(3 , 0 , 0 , 0 ,'windows_m');
 document.getElementById('windows_mm').innerHTML=SET_TEXT;
}
/////////////
var DivY= 500;
var DivY0 = DivY/6;
var PoseActive=0;
var DoDown=0;
var DownTime;

function my_div_mover( my_y , go_down , down_time , move_down , go_up_id_old ){
go_up_id=go_up_id_old;
newleft=document.body.clientWidth/2 - parseInt(document.getElementById(go_up_id).style.width)/2;
document.getElementById(go_up_id).style.top = "0px";//Py;
document.getElementById(go_up_id).style.left = newleft+"px";
 DivY = document.body.clientHeight; //Start position of Div
 DivY0 = DivY/my_y; //end position
 PoseActive = move_down; //move width scroll
 DoDown = go_down; //Down after
 DownTime = down_time; //Down time 
 Pos();
 DivUp();
 document.getElementById(go_up_id).style.display="";
}
function Pos()
{
 if (window.innerHeight)
 {
 pos = window.pageYOffset
 }
 else if (document.documentElement && document.documentElement.scrollTop)
 {
 pos = document.documentElement.scrollTop
 }
 else if (document.body)
 {
 pos = document.body.scrollTop
 }
 if (PoseActive)
 {
 document.getElementById(go_up_id).style.top = DivY + pos+"px";
 temp = setTimeout('Pos()',300);
 }
}

function DivUp()
{
 if (Math.abs(DivY- DivY0)>.1){
 DivY = (DivY0 - DivY) * .2 + DivY;
 document.getElementById(go_up_id).style.top = DivY + pos+"px";
 setTimeout("DivUp()", 50);
 }
 else
 {
 if(DoDown) setTimeout("DivDown()", DownTime); 
 else PoseActive = 0;
 }
}
function DivDown()
{
 if ((document.body.clientHeight - DivY)>0){
 DivY = (DivY - DivY0) * .2 + DivY;
 document.getElementById(go_up_id).style.top = DivY + pos+"px";
 setTimeout("DivDown()", 30);
 }
 else
 {
 document.getElementById(go_up_id).style.display="none";
 PoseActive = 0;
 }

}
function close_windows(){
 //hide_id('windows_1');
 Pos()
 DivDown()

}

/////////دستورات بازکردن صفحه متحرک
///////////////////////////////////
//-->
var keyboard="Farsi";
function FKeyPress(){
	key = window.event.keyCode;
	if((key==39)&&(keyboard!="Farsi")){window.event.keyCode=34;return true;}
	if ((key>127)||(key<32)){return true;}
	if ( keyboard == "Farsi"){
		basestring=' !"#$%،گ)(×+و-./0123456789:ک,=.؟@ِذ}ىُىلآ÷ـ،/’د×؛َءٍف‘{ًْإ~جژچ^_پشذزیثبلاهتنمئدخحضقسفعرصطغظ<|>ّ';
		window.event.keyCode=basestring.charCodeAt(key-32);
	}
	return true;
}
function Language_english(){

			keyboard = "English" ;

	return true;
}

function FKeyDown(){
	key=window.event.keyCode;
	if (key==145){  
		if (keyboard == "Farsi"){
			keyboard = "English" ;
		}else{
			keyboard = "Farsi"; 
		}
	}
	return true;
}

function ChangeLanguage(obj){
	if (keyboard == "Farsi"){
		keyboard = "English" ;
		//obj.src='../images/FAEN.gif'
	}else{
		keyboard = "Farsi"; 
		//obj.src='../images/FAEN.gif'	
	}
	return true;
}

///////////////////////////////
function hide_id(id){
    if( document.getElementById(id) ){
	document.getElementById(id).style.display ='none';
	}
}
//////////////////////////////////
function show_id(id){
    if( document.getElementById(id) ){
    document.getElementById(id).style.display ='';
	}
}
//////////////////////////////////
function getscript(str){
let_out=str;
str=str.split('#endofmyscript');
if( str[1] !=null){
doeval(str[0]);
let_out =let_out.replace(str[0]+'#endofmyscript', '');
}

return let_out;
}
////////////////////////////////////////
function doeval(js){
	if(js!=null){
	var sc = document.createElement('script');
	jsCode = js;
	sc.type = 'text/javascript';
	document.getElementsByTagName('head')[0].appendChild(sc);
	sc.text = 'try{eval(jsCode);}catch(e){}jsCode="";';
	//sc.text = 'try{eval(jsCode);}catch(e){try{alert(e.fileName+" : "+e.lineNumber+"\\n"+e.name+" : "+e.message); alert(e.stack);}catch(e){}}jsCode="";';
	sc.text = "\/\/ :-)";
	}
}
//////////////////////////////////////////
var theSiteLinks = new Array();

	// Control parameters
	var theCharacterTimeout = 60;
	var theStoryTimeout     = 2100;
	var theWidgetOne        = "_";
	var theWidgetTwo        = "-";
	var theWidgetNone       = "";

	var NS6=(document.getElementById && !document.all) ? true : false;
	// Define run time values
	theCurrentStory     = -1;
	theCurrentLength    = 0;
	


// Ticker startup
function startTicker()
{
	// Locate base objects
	if (document.getElementById) {	
			runTheTicker();   	
		 }
	else {
            document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>");
            return true;
	}
}


// Ticker main run loop
function runTheTicker()
{
var theItemCount = SET_TEXT.length;

	var myTimeout;  
	// Go for the next story data block
	if(theCurrentLength == 0)
	{
		theCurrentStory++;
		theCurrentStory      = theCurrentStory % theItemCount;
		theStorySummary      = SET_TEXT[theCurrentStory];
		theTargetLink        = theSiteLinks[theCurrentStory];
	}
	
	var textTitle = theStorySummary.substring(0,theCurrentLength) + whatWidget();
	
	if (theTargetLink ) {
	
		if (NS6) {
	document.getElementById("SET_TEXT_ID").innerHTML  = '<font color="#000000"><a href="'+ theTargetLink +'" target="_blank"  style="text-decoration: none"><font color="#000000">'+textTitle+'</font></a></font>';
				 }
		else {
	document.all.SET_TEXT_ID.innerHTML  = '<font color="#000000"><a href="'+ theTargetLink +'" target="_blank"  style="text-decoration: none"><font color="#000000">'+textTitle+'</font></a></font>';
				}
						} 	
	else {
		if (NS6) {
	document.getElementById("SET_TEXT_ID").innerHTML = '<font color="#000000">'+textTitle+'</font>';
				}
		else {
	document.all.SET_TEXT_ID.innerHTML  = '<font color="#000000">'+textTitle+'</font>';
				}
	}
	
	// Modify the length for the substring and define the timer
	if(theCurrentLength != theStorySummary.length)
	{
		theCurrentLength++;
		myTimeout = theCharacterTimeout;
	}
	else
	{
		theCurrentLength = 0;
		myTimeout = theStoryTimeout;
	}
	// Call up the next cycle of the ticker
	setTimeout("runTheTicker()", myTimeout);
}


// Widget generator
function whatWidget()
{
	if(theCurrentLength == theStorySummary.length)
	{
		return theWidgetNone;
	}

	if((theCurrentLength % 2) == 1)
	{
		return theWidgetOne;
	}
	else
	{
	    return theWidgetTwo;
	}
}

//startTicker();

function moveGroup(dir)
{
	var i;
	var theForm;
	var fromS, toS;
	
	theForm = document.form;
	if( dir == 1 )
		{
		fromS = theForm.allgr;
		toS = theForm.phonegr;
		}
	else
		{
		fromS = theForm.phonegr;
		toS = theForm.allgr;
		}

	if( toS.options.length == 1 && toS.options[0].value === "" )
		toS.remove(0);

	for(i = 0 ; i < fromS.options.length ; i++ )
		{
		if (fromS.options[i].selected)
			{
			var elOptNew = document.createElement('option');
	    elOptNew.text = fromS.options[i].text;
  	  elOptNew.value = fromS.options[i].value;
  	  
			try {
					toS.add(elOptNew, toS.options[toS.length]); // standards compliant; does not work in IE
			    }
	    catch(ex) {
		      toS.add(elOptNew, toS.options.length); // IE only
			    }
			fromS.remove(i);
			} 
		}
		
	if( fromS.options.length == 1 && fromS.options[0].value === "" )
		fromS.remove(0);
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function checkgroup(theForm, addit)
{
	var i;
	var searchForInvalid = /[~'"^]/;
	var rep;
	
	if( theForm.gr_grp.value.trim() === "" )
		{
		alert('لطفا نام گروه را وارد نمایید');
		return false;
		}

	if( searchForInvalid.test(theForm.gr_grp.value) )
		{
		alert('نام گروه نمی تواند شامل کاراکترهای \'، "، ^ و ~ باشد');
		return false;
		}

	if( !addit && theForm.allgr.selectedIndex == -1 )
		{
		alert('گروهی را که می خواهید تغییر نام دهید انتخاب کنید');
		return false;
		}

	rep = 0;
	for(i = 0 ; i < theForm.allgr.options.length ; i++ )
		{
		if( theForm.allgr.options[i].text === theForm.gr_grp.value )
			rep = 1;
		}
		
	if( rep == 0 )
		{
		if( addit )
			{
			var elOptNew = document.createElement('option');
		  elOptNew.text = theForm.gr_grp.value;
		  elOptNew.value = '0';
		  
			try {
					theForm.allgr.add(elOptNew, theForm.allgr.options[theForm.allgr.length]); // standards compliant; does not work in IE
			    }
		  catch(ex) {
		      theForm.allgr.add(elOptNew, theForm.allgr.options.length); // IE only
			    }
			}
		else
			{
			theForm.allgr.options[theForm.allgr.selectedIndex].text = theForm.gr_grp.value;
			}
		theForm.gr_grp.value = "";
		}

	if( addit == 1 )
		theForm.gr_grp.focus();

	return true;
}

function delgroup(theForm)
{
	if( theForm.allgr.selectedIndex != -1 )
		{
		theForm.allgr.remove(theForm.allgr.selectedIndex);
		theForm.gr_grp.value = "";
		}

	return true;
}

function groupscheck(theForm)
{
	var i;
	
	if( theForm.allgr.options.length == 0 )
		{
		alert("امکان حذف همه گروه ها وجود ندارد");
		return false;
		}

	theForm.allgroups.value="";
	for(i = 0 ; i < theForm.allgr.options.length ; i++ )
		{
		theForm.allgroups.value = theForm.allgroups.value + theForm.allgr.options[i].value + '^' + theForm.allgr.options[i].text + '~';
		}

	return true;
}

function checknum(theForm)
{
	var i;
	var searchForInvalid = /\d{8}(\d{6})?/;
	var rep;
	
	if( !searchForInvalid.test(theForm.nu_num.value) )
		{
		alert('لطفا شماره را به صورت 8 یا 14 رقمی وارد کنید');
		return false;
		}

	rep = 0;
	for(i = 0 ; i < theForm.allnum.options.length ; i++ )
		{
		if( theForm.allnum.options[i].text === theForm.nu_num.value )
			rep = 1;
		}
		
	if( rep == 0 )
		{
		var elOptNew = document.createElement('option');
	  elOptNew.text = theForm.nu_num.value;
	  elOptNew.value = '0';
	  
		try {
				theForm.allnum.add(elOptNew, theForm.allnum.options[theForm.allnum.length]); // standards compliant; does not work in IE
		    }
	  catch(ex) {
	      theForm.allnum.add(elOptNew, theForm.allnum.options.length); // IE only
		    }
		theForm.nu_num.value = "";
		}

	return true;
}

function numscheck(theForm)
{
	var i;
	
	if( theForm.allnum.options.length == 0 )
		{
		alert("امکان حذف همه شماره ها وجود ندارد");
		return false;
		}

	theForm.allnums.value="";
	for(i = 0 ; i < theForm.allnum.options.length ; i++ )
		{
		theForm.allnums.value = theForm.allnums.value + theForm.allnum.options[i].value + '^' + theForm.allnum.options[i].text + '~';
		}

	return true;
}


function checkext() 
{
	if( document.form0.file0.value == '' )
		return true;
		
  var ext = document.form0.file0.value;
  if( ext.length < 5 )
  	{
	  	document.form0.file0.value = '';
	    alert('نام فايل نا معتبر است');
	    return false;
  	}
  	
  ext = ext.substring(ext.length-4,ext.length);
  ext = ext.toLowerCase();
  if(ext != '.xls') 
  	{
  	ext = document.form0.file0.value;
	  if( ext.length < 6 )
	  	{
	  	document.form0.file0.value = '';
	    alert('نام فايل نا معتبر است');
	    return false;
	  	}
	  ext = ext.substring(ext.length-5,ext.length);
	  ext = ext.toLowerCase();
	  if(ext != '.xlsx') 
	  	{
	  	document.form0.file0.value = '';
	    alert('فقط پسوندهاي زير قابل قبول هستند:\n\nXLS, XLSX');
  	  return false; 
    	}
    else
    	return true;
    }
  else
    return true; 
}

function setVisible(obj)
{
	var obj0 = document.getElementById(obj);
	if( obj == 'layer1' )
		placeIt(obj0, 400, 300);
	else
		placeIt(obj0, 700, 500);
	obj0.style.visibility = (obj0.style.visibility == 'visible') ? 'hidden' : 'visible';
}

function placeIt(obj1, w, h)
{
	var hasInner = typeof(window.innerWidth) == 'number';
	var hasElement = typeof(document.documentElement) == 'object' && typeof(document.documentElement.clientWidth) == 'number';
	var de = document.documentElement;
	var wh = de.clientHeight > window.innerHeight ? window.innerHeight : de.clientHeight;
	var ww = hasElement ? de.clientWidth : document.body.clientWidth;
	var theLeft, theTop;

	theLeft = parseInt((ww - w) / 2);
	theTop = parseInt((wh - h) / 2);

	obj1.style.left = theLeft + 'px' ;
	obj1.style.top = theTop + 'px' ;
}


