﻿// JScript File

function MiddleOver(e,sImgName,i)
{
  e.className="TD_Middle1"
  e.style.cursor='hand';

  if (i == 1)
  {
      sImgFile = document.getElementById("hid_Img1").value
      document.getElementById("TD_Middle2").className = "TD_Middle"
  }
  else if (i == 2)
  {
       sImgFile = document.getElementById("hid_Img2").value
       document.getElementById("TD_Middle1").className = "TD_Middle"
  }
  else if (i == 3)
  {
     sImgFile = document.getElementById("hid_Img3").value
     document.getElementById("TD_Middle4").className = "TD_Middle"
  }  
  else if (i == 4)
  {
     sImgFile = document.getElementById("hid_Img4").value
     document.getElementById("TD_Middle3").className = "TD_Middle"

  }
 if (sImgFile != "" ) 
    document.images[sImgName].src = sImgFile ; 
 else
   document.images[sImgName].src = "../Images/noimage1.jpg"
   
}

function MiddleLeave(e)
{
  e.className="TD_Middle"
 
}

// ****************************************


function Check_Special2(form)
{
var msg = ""
var value = form.value;
var len=value.length;
var i;

if (len > 0)
{
 for (i=0; i<len; i++)
  {
        n=value.charAt(i)
		if (n == "-")
		{
		  if (value.charAt(i + 1) == "-")
		  {
		    msg = 'شما مجاز به استفاده از کاراکترهای زیر نمی باشید' + ' \n' + '(; : -- =)'
		    alert(msg)
		    form.focus();
	        form.select();
		    
		  }
		}
		if (n == ";"  || n== ":" || n == "=" )
		{
		 msg = 'شما مجاز به استفاده از کاراکترهای زیر نمی باشید' + ' \n' + '(; : -- =)'
		 alert(msg)
		 form.focus();
	     form.select();
		
	     }
		
  }	
 					

}



}


// ****************************************

function Check_Special(form)
{
var msg = ""
var value = form;
var len=value.length;
var i;

if (len > 0)
{
 for (i=0; i<len; i++)
  {
        n=value.charAt(i)
		if (n == "-")
		{
		  if (value.charAt(i + 1) == "-")
		  {
		    msg = 'شما مجاز به استفاده از کاراکترهای زیر نمی باشید' + ' \n' + '(; : -- =)'
		    return msg
		    
		  }
		}
		if (n == ";"  || n== ":" || n == "=" )
		{
		 msg = 'شما مجاز به استفاده از کاراکترهای زیر نمی باشید' + ' \n' + '(; : -- =)'
		 return msg
		
	     
		}
		
  }	
  
				
return '' ;						

}



}


// ****************************************
var UserName 

function Check_UN(form)
{

//var value=form.value;
var value=form;
UserName = form ;

var len=value.length;
var i;
var digit=false
var Big_Char=false
var Small_Char=false
var Special=false
var ans = "" ;

if (len > 0 )
{
if (len < 6 )
  {
   alert("نام کاربری حداقل باید 6 کاراکتر باشد")
   return "";
  }
 else
 {
    ans = Check_Special(value)
    if (ans != '')
    {
      alert(ans)
      return "";
  
    }
 
    return form ;
 } 
 
}
else
  return "";
}
// ***********************
function Check_UN1(form)
{

//var value=form.value;
var value=form;
UserName = form ;

var len=value.length;
var i;
var digit=false
var Big_Char=false
var Small_Char=false
var Special=false
var ans = "" ;

if (len > 0 )
{
if (len < 6 )
  {
   alert("نام کاربری حداقل باید 6 کاراکتر باشد")
   return "";
  }
 else
 

  CheckUN()
  
 
 ans = Check_Special(value)
 if (ans != '')
 {
  alert(ans)
  return "";
  
 }

  return form ; 
}
else
 {
  CheckUN()
   ans = Check_Special(value)
  if (ans != '')
  {
  alert(ans)
  return "";
  }
  
  return "";
 }
 
}

// ***************************
function CheckUN()
{
if (checkBlank(document.getElementById('txt_Username')))
 document.getElementById("S_Active").style.display = "none"
else if (!checkBlank(document.getElementById('txt_Username')) && document.getElementById("hid_ShowActive").value == "1")
 document.getElementById("S_Active").style.display = ""

}
// ***************************

function Check_Pass(form,UN)
{

if ( UN != "")
   { UserName = UN; }

//var value=form.value;
var value = form;
var len=value.length;
var i;
var digit = false;
var Big_Char = false;
var Small_Char = false;
var Special = false;

if (len > 0 )
{

 if (len < 6 )
  {
   alert("کلمه عبور باید حداقل 6 کاراکتر باشد")
   return "";
  }
 else if (UserName != "")
  {
    if (UserName == form)
    {
       alert("نام کاربری و کلمه عبور نباید مانند یکدیگر باشند");
       return "" ;
    }
    
  }
 
 // //Start of For //////////////
if (len > 6 )
{
 var ans 
 ans = Check_Special(value)
 if (ans != '')
 {
  alert(ans)
  return "";
  
 }
}
 for (i=0; i<len; i++)
	{
	    n=value.charAt(i)
		
		if (n == "1" || n == "2" || n == "3" || n == "4" || n == "5" || n == "6" || n == "7" || n == "8" || n == "9" || n == "0" )
		{
		 digit=true;
		 
		}
		
		if (n == "a" || n == "b" || n == "c" || n == "d" || n == "e" || n == "f" || n == "g" || n == "h" || n == "i" || n == "j" || n == "k" || n == "l" || n == "m" || n == "n" || n == "o" || n == "p" || n == "q" || n == "r" || n == "s" || n == "t" || n == "u" || n == "v" || n == "w" || n == "x" || n == "y" || n == "z" )
		{
		 Small_Char=true;
		}
		
		if (n == "A" || n == "B" || n == "C" || n == "D" || n == "E" || n == "F" || n == "G" || n == "H" || n == "I" || n == "J" || n == "K" || n == "L" || n == "M" || n == "N" || n == "O" || n == "P" || n == "Q" || n == "R" || n == "S" || n == "T" ||  n == "U" || n == "V" || n == "W" || n == "X" || n == "Y" || n == "Z" )
		{
		 Big_Char=true;
		}
		
		//if (n == "~" || n == "!" || n == "@" || n == "#" || n == "$" || n == "%" || n == "^" || n == "&" || n == "*" || n == "(" || n == ")" || n == "_" || n == "+" || n == "=" || n == "[" || n == ']' || n == "{" || n == "}" || n == "/"  )
		//{
		// Special=true;
		//}
		
	}
	//End Of For //////////////////
	var str=""
	if (digit == false)
	  str="حداقل یک رقم"+ "\n"
	 
    if (Small_Char == false && Big_Char == false)
      str=str  + "حداقل یک حرف" + "\n"
      
    else if (Small_Char == false )
      str=str  + "حداقل یک حرف کوچک"  + "\n"
    else if (Big_Char == false)
         str=str  + "حداقل یک حرف بزرگ"  + "\n"
         
   // if (Special == false )
     // str=str  + "کاراکترهای ویژه" + "\n"
      
    if (str == "")
     { 
            return form;
     }
     
    else 
      { 
      str1="شما باید برای کلمه عبور موارد زیر را رعایت نمایید" + "\n"
      str= str1  + str
      alert(str)
      return ""
      }


 //alert("Here")
 return form ; 
}

else
  return "";
  
}
// **********************************

function Loading()
{
 sImgName = 'Img_Middle1'
 
 sImgFile = document.getElementById("hid_Img1").value
  document.images[sImgName].src = sImgFile ;
 
 sImgName = 'Img_Middle2'
 sImgFile = document.getElementById("hid_Img3").value
 document.images[sImgName].src = sImgFile ;
 
}

// ************************************



// ***********************************
function PicOver(e)
{
  e.className="PicArchive1"
  e.style.cursor='hand';
}

function PicLeave(e)
{
 
  e.className="PicArchive"
  e.style.cursor='hand';
}

// ***********************************
function GOver(e)
{
  e.className="G1"
  e.style.cursor='hand';
}

function GLeave(e)
{
  e.className="G"
  e.style.cursor='hand';
}

function Overb(e)
{
  e.className="blue1"
  e.style.cursor='hand';
}

function Leaveb(e)
{
  e.className="blue"
  e.style.cursor='hand';
}

function WOver(e)
{
  
  e.className="WTD1"
  e.style.cursor='hand';
}

function WLeave(e)
{
  e.className="WTD"
  e.style.cursor='hand';
}


function Over(e)
{
e.className="A1"
e.style.cursor='hand';
}

//*****************************************************

function Leave(e)
{
e.className="A"
}


//*****************************************************

function Over2(e)
{
e.className="C1"
}

//*****************************************************

function Leave2(e)
{
e.className="C"
}

//*****************************************************

function Over3(e)
{
e.className="D1"
e.style.cursor='hand';
}

//*****************************************************

function Leave3(e)
{
e.className="D"
}

//*****************************************************

function Over4(e)
{

e.className="TD1"
e.style.cursor='hand';
}

//*****************************************************

function Leave4(e)
{
e.className="TD"
}

//*****************************************************

function Over5(e)
{
e.className="E1"
e.style.cursor='hand';
}

//*****************************************************

function Leave5(e)
{

e.className="E"
}

//*****************************************************

function Over6(e)
{
e.className="H1"
//e.style.cursor='hand';
}

//*****************************************************

function Leave6(e)
{

e.className="H"
}

//*****************************************************
function Over7(e)
{

e.className="F1"
e.style.cursor='hand';
}

//*****************************************************

function Leave7(e)
{
e.className="F"
}
//*****************************************************

function checkBlank(form)
{
   var value=form.value;
   var len=value.length;
    //var value=form
   // var len=value.length;
    var InsertedStr="";
    var i;
	
	for (i=0; i<len; i++)
		InsertedStr=InsertedStr+value.charAt(i).replace (" ","")
	
	if (InsertedStr=="")
		return true;
	else
		return false;
		
}

//*****************************************************

function newcheckmail(Form)
{

  if  (Form !='')
  {
 
 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Form))
 
		return true
   else

		return false

  }		
  else
  
   return true
}

//*****************************************************

function CheckDigit(form)
{

var value=form.value;
var len=value.length;
var i;


if (len > 0 )
{

for (i=0; i<len; i++)
	{
		n=value.charAt(i)
		if (n == '1' || n == '2' || n == '3' || n == '4' || n == '5' || n == '6' || n == '7' || n == '8' || n == '9' || n == '0' )
		 {}
		else
		 { 
		  alert("فقط مجاز به استفاده از ارقام می باشید");
		  return '';
		}
			  
	}
}

 return value;

}



var oldgridSelectedColor;

function setMouseOverColor(element)
{
  alert(element)
    oldgridSelectedColor = element.style.backgroundColor;
 element.style.backgroundColor='#EFE0BB';
    //element.style.cursor='hand';
   // element.style.textDecoration='underline';
}

function setMouseOutColor(element)
{
    element.style.backgroundColor=oldgridSelectedColor;
   // element.style.textDecoration='none';
}


function check_date(val)
{

var check="true";
var value=val;
var len=value.length;
var i;

if ( len > 0 )
{
var arr=value.split("/")

if (len < 8 )
{
  alert("لطفا تاریخ رابه صورت صحیح وارد نمایید");
  return ''
}
else
{
for (i=0; i<len; i++)
	{
		if (value.charAt(i) == " ")
		
			check="false";
			
		else if (value.charAt(i) == '"' || value.charAt(i) == "'")
			check="false";
		else
		{
		n=value.charAt(i)
		if (n != '1' && n != "2" && n != "3" && n != "4" && n != "5" && n != '6' && n != "7" && n != "8" && n != "9" && n != "0" && n != "/" )
		    check="false";
		}	
			
	}
	if (check == "false")
	{
      alert("لطفا تاریخ را به صورت صحیح وارد نمایید")
      return ''
   }
 } 
 //******************
 var day =arr[2];
 var month=arr[1];
 var year=arr[0];
var flag=false;
 if (day.length > 2 || day.length < 1 )
  flag="false";
 else if (day == 0 || day > 31)
  check="false";

if ( month.length > 2  ||  month.length < 1)
  flag="false";
else if(month == 0 || month > 12)
  check="false";

if ( year.length != 4   )
    flag="false";


 if ( check == "false" )
 {

 alert("لطفا تاریخ را به صورت صحیح واردنمایید")
 return ''
 }
 
 if ( flag == "false" )
 {
 
 var str="وارد نمایید"  + "(dd/mm/yyyy)" + "لطفا تاریخ را با فرمت"
 alert(str)
 return ''
 }
 
}
 
 return val; 
}







