<!--
// Start of Tab Section -------------------------------
function init()
{
MM_reloadPage(true);
}

function MM_reloadPage(init) {  
  if (init==true) with (navigator) 
	{if ((appName=="Netscape")&&(parseInt(appVersion)==4)) 
		{document.MM_pgW=innerWidth;
		 document.MM_pgH=innerHeight;
		 onresize=MM_reloadPage; }
	}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
	}




function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	obj.visibility=v; }  
	
}
// End of Tab Section -------------------------------
// Start of Skin Section -------------------------------
// This function finds the type of the browser
function browserData()
{
    var useragnt = navigator.userAgent
    this.canDoDOM = (document.getElementById) ? true : false
    if ( useragnt.indexOf('Opera') >= 0)
        this.name = 'Opera'
    else if (  useragnt.indexOf('MSIE') >= 0 )
        this.name = 'InternetExplorer'
    else
        this.name = 'Another'
}

// This function toggles the visibility state of the panel componnent
function toggleShowHide(panel_id2){	
    var myBrowser = new browserData()
    
    if (document.getElementById){
        if ( myBrowser.name == "InternetExplorer" ){
            if ( eval('document.getElementById("panel_' + panel_id2 + '")').style.display == 'none'){
                eval('document.getElementById("panel_' + panel_id2 + '")').style.display='inline';
                eval('document.getElementById("show_' + panel_id2 + '")').style.display='none';
                eval('document.getElementById("hide_' + panel_id2 + '")').style.display='inline';
            }
            else{
                eval('document.getElementById("panel_' + panel_id2 + '")').style.display='none';
                eval('document.getElementById("hide_' + panel_id2 + '")').style.display='none';
                eval('document.getElementById("show_' + panel_id2 + '")').style.display='inline';
            }
        }
        else if ( myBrowser.name == "Opera" ){
            if ( document.getElementById("panel_" + panel_id2).style.visibility == 'visible' ){
                document.getElementById("panel_" + panel_id2).style.visibility = 'hidden'
                document.getElementById("show_" + panel_id2).style.visibility = 'visible'
                document.getElementById("hide_" + panel_id2).style.visibility = 'hidden'
            }
            else{
                document.getElementById("panel_" + panel_id2).style.visibility = 'visible'
                document.getElementById("show_" + panel_id2).style.visibility = 'hidden'
                document.getElementById("hide_" + panel_id2).style.visibility = 'visible'
            }
        }
        else{
            if ( eval('document.getElementById("panel_' + panel_id2 + '")').style.position == 'absolute'){
                eval('document.getElementById("panel_' + panel_id2 + '")').style.position='relative';
                eval('document.getElementById("panel_' + panel_id2 + '")').style.visibility='visible';
                eval('document.getElementById("hide_' + panel_id2 + '")').style.position='relative';
                eval('document.getElementById("show_' + panel_id2 + '")').style.position='absolute';
                eval('document.getElementById("hide_' + panel_id2 + '")').style.visibility='visible';
                eval('document.getElementById("show_' + panel_id2 + '")').style.visibility='hidden';
            }
            else{
                eval('document.getElementById("panel_' + panel_id2 + '")').style.position='absolute';
                eval('document.getElementById("panel_' + panel_id2 + '")').style.visibility='hidden';
                eval('document.getElementById("show_' + panel_id2 + '")').style.position='relative';
                eval('document.getElementById("hide_' + panel_id2 + '")').style.position='absolute';
                eval('document.getElementById("show_' + panel_id2 + '")').style.visibility='visible';
                eval('document.getElementById("hide_' + panel_id2 + '")').style.visibility='hidden';
            }
        }
        return false;
    }
    else{
        if(eval('document.panel_' + panel_id2 ).visibility == 'hide'){
            eval('document.panel_' + panel_id2 ).visibility='show'
            eval('document.blank_' + panel_id2).layers[1].visibility='hide'
            eval('document.blank_' + panel_id2).layers[0].visibility='show'
        }
        else{
            eval('document.panel_' + panel_id2 ).visibility='hide'
            eval('document.blank_' + panel_id2).layers[0].visibility='hide'
            eval('document.blank_' + panel_id2).layers[1].visibility='show'
        }
    }
}
// End of Skin Section -------------------------------
// Start of Side by Side Section -------------------------------
// These functions is related to side by side menus ----------
function addit(_OL,_SL)
{
  /*uncomment this to see what it is adding as it is adding it */
  /*alert(_v.SourceList.selectedIndex);*/
  
  
  var si = _OL.selectedIndex;  
  if(si >=0){  
		var st = _OL.options[si].text;
		var sv = _OL.options[si].value;
		var flag=true;  
		for(var i=0; i<_SL.options.length; i++) 
				if(_SL.options[i].value==sv)
					flag=false;

		if(flag) {		
		  var ni = _SL.options.length++;  
			_SL.options[ni].text=st;
			_SL.options[ni].value=sv; 
		}
	}
}
function removeit(_SL) {
	for(var i=0; i<_SL.options.length; i++) {
		if(_SL.options[i].selected && _SL.options[i] != "") {
			_SL.options[i].value = "";
			_SL.options[i].text = "";
			}
		}
		BumpUp(_SL);
} 
function BumpUp(abox) {
	for(var i = 0; i < abox.options.length; i++) {
		if(abox.options[i].value == "")  {
			for(var j = i; j < abox.options.length - 1; j++)  {
				abox.options[j].value = abox.options[j + 1].value;
				abox.options[j].text = abox.options[j + 1].text;
			}
			var ln = i;
			break;
		}
	}
	if(ln < abox.options.length)  {
		abox.options.length -= 1;
		BumpUp(abox);
	}
}
// End of Side by Side Section -------------------------------
// Start of Tree Section -------------------------------------------------------------
function change(){
   if(!document.all)
      return
   if (event.srcElement.id=="TreeHeader") {
      var srcIndex = event.srcElement.sourceIndex
      var nested = document.all[srcIndex+1]
      if (nested.style.display=="none") {
         nested.style.display=''
         event.srcElement.style.listStyleImage="url(images/open.gif)"
      }
      else {
         nested.style.display="none"
         event.srcElement.style.listStyleImage="url(images/fold.gif)"
      }
   }
}
function changeWithCheckBox(){
   if(!document.all)
      return
   if (event.srcElement.id=="TreeHeader") {
      var srcIndex = event.srcElement.sourceIndex
      var nested = document.all[srcIndex+2]
      if (nested.style.display=="none") {
         nested.style.display=''
         event.srcElement.style.listStyleImage="url(images/open.gif)"         
         nested.style.status='checked'
      }
      else {
         nested.style.display="none"
         event.srcElement.style.listStyleImage="url(images/fold.gif)"
      }
   }
}
// End of Tree Section ---------------------------------------------------------------
// Start of Select Section For thisForm ,SelectedItem ,SelectAll 
//                             ListOddSelectedRow, ListOddRow,
//							   ListEvenSelectedRow, ListEvenRow,    
function Toggle(e)
    {
	if (e.checked) {
	    Highlight(e);
//	    document.thisForm.SelectAll.checked = AllChecked();
	}
	else {
	    Unhighlight(e);
//	    document.thisForm.SelectAll.checked = false;
	}
}

function ToggleDirectory(e)
    {        
	if (e.checked) {
	    Highlight(e);	    
//	    document.thisForm.SelectAllDirectory.checked = AllCheckedDirectory();
	}
	else {
	    Unhighlight(e);
//	    document.thisForm.SelectAllDirectory.checked = false;
	}		
}

function ToggleAll(e)
    {
	if (e.checked) {
	    CheckAll();
	}
	else {
	    ClearAll();
	}
}

function ToggleAllDirectory(e)
    {
	if (e.checked) {
	    CheckAllDirectory();
	}
	else {
	    ClearAllDirectory();
	}
}


function Check(e)
    {
	e.checked = true;
	Highlight(e);
}

function Clear(e)
    {
	e.checked = false;
	Unhighlight(e);
}

function CheckAll()
    {
	var ml = document.thisForm;
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
	    var e = ml.elements[i];
	    if (e.name == "SelectedItem") {
		Check(e);
	    }
	}
	//ml.SelectAll.checked = true;
}

function ClearAll()
    {
	var ml = document.thisForm;
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
	    var e = ml.elements[i];
	    if (e.name == "SelectedItem") {
		Clear(e);
	    }
	}
	//ml.SelectAll.checked = false;
    }
function CheckAllDirectory()
    {
	var ml = document.thisForm;
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
	    var e = ml.elements[i];
	    if (e.name == "SelectedDirectory") {
		Check(e);
	    }
	}
//	ml.SelectAllDirectory.checked = true;
}

function ClearAllDirectory()
    {
	var ml = document.thisForm;
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
	    var e = ml.elements[i];
	    if (e.name == "SelectedDirectory") {
		Clear(e);
	    }
	}
//	ml.SelectAllDirectory.checked = false;
    }

function Highlight(e)
    {
	var r = null;
	if (e.parentNode && e.parentNode.parentNode) {
	    r = e.parentNode.parentNode;
	}
	else if (e.parentElement && e.parentElement.parentElement) {
	    r = e.parentElement.parentElement;
	}
	if (r) {
	    if (r.className == "ListOddRow") {
		r.className = "ListOddSelectedRow";
	    }
	    else if (r.className == "ListEvenRow") {
		r.className = "ListEvenSelectedRow";
	    }
	}
}

function Unhighlight(e)
    {
	var r = null;
	if (e.parentNode && e.parentNode.parentNode) {
	    r = e.parentNode.parentNode;
	}
	else if (e.parentElement && e.parentElement.parentElement) {
	    r = e.parentElement.parentElement;
	}
	if (r) {
	    if (r.className == "ListOddSelectedRow") {
		r.className = "ListOddRow";
	    }
	    else if (r.className == "ListEvenSelectedRow") {
		r.className = "ListEvenRow";
	    }
	}
}

function AllChecked()
    {
	ml = document.thisForm;
	len = ml.elements.length;
	for(var i = 0 ; i < len ; i++) {
	    if (ml.elements[i].name == "SelectedItem" && !ml.elements[i].checked) {
		return false;
	    }
	}
	return true;
}
function AllCheckedDirectory()
    {    
	ml = document.DirectoryForm;
	len = ml.elements.length;
	for(var i = 0 ; i < len ; i++) {
	    if (ml.elements[i].name == "SelectedDirectory" && !ml.elements[i].checked) {
		return false;
	    }
	}
	return true;
}

// End of Select Section
// Start of Popup Window
// User a full path name for SourceFileName
function OpenPopUp(SourceFileName,W,H)
	{     
		myWindow = window.open("", "Preview","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=" + W + ",height=" + H + "");
        if((W < 800) && (H < 600)) {
			myWindow.moveTo( 400-W/2, 300-H/2);
			}
        myWindow.document.open();                
        //alert("<META HTTP-EQUIV=""refresh"" CONTENT="0;URL='" + SourceFileName + "'"">");
        myWindow.document.write("<META HTTP-EQUIV=refresh CONTENT='0;URL=" + SourceFileName + "'>");
        myWindow.document.close();    
    }
function OpenPopUpNoScroll(SourceFileName,W,H)
	{     
		myWindow = window.open("", "Preview","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=" + W + ",height=" + H + "");
        if((W < 800) && (H < 600)) {
			myWindow.moveTo( 400-W/2, 300-H/2);
			}
        myWindow.document.open();                
        //alert("<META HTTP-EQUIV=""refresh"" CONTENT="0;URL='" + SourceFileName + "'"">");
        myWindow.document.write("<META HTTP-EQUIV=refresh CONTENT='0;URL=" + SourceFileName + "'>");
        myWindow.document.close();    
    }

//End of Popup Window
// Start of Calendar Section
function CalendarTable(Dt,e)
	{	
	var ShamsiDate;	
	var ShamsiWeek;		
	var YTmp,MTmp,DTmp;
	YTmp = Dt.getFullYear();
	MTmp = Dt.getMonth()+1;
	MTmp = (MTmp <10) ? "0" + MTmp:MTmp;
	DTmp = Dt.getDate();				
	DTmp = (DTmp <10) ? "0" + DTmp:DTmp;	
	ShamsiDate = DateToFarsi(YTmp + "/" + MTmp + "/" + DTmp);	
	ShamsiWeek = Dt.getDay();		
	var SHYear = eval(GetShamsiYear(ShamsiDate));
	var SHMonth = eval(GetShamsiMonth(ShamsiDate));	
	var SHDay = eval(GetShamsiDay(ShamsiDate));			
	var SHW;		
	var Maxdays,Leaf,Tmpy;
	var AnotherYear, AnotherMonth;
	var j , i , d, dFlag;	
	var OTmp;		
	//for setting week day
	SHW = eval(ShamsiWeek);	
	//SHW = (SHW == 0) ? 1 : SHW + 1;				
	SHW = (SHW == 6) ? 0: SHW+1;	
	SHMod= SHDay %7;
	SHW = SHW - (SHMod -1);	
	SHW = (SHW < 0) ? SHW + 7: SHW ;		
	//Calculating leaf and maxdays of month	
	Tmpy = SHYear + 11;	
	Tmpy = Tmpy % 33;	
	if((Tmpy != 32) && (Tmpy %4 == 0))
		Maxdays = (SHMonth < 7) ? 31 :30;	
	else
		Maxdays = (SHMonth < 7) ? 31 :(SHMonth<12)?30:29;	
	//writing table	
	OTmp = "<table cellpadding=0 cellspacing=1 width=140>";
	OTmp = OTmp + "<TR class=ListHeader><TD align=left colspan=2>";	
	AnotherMonth = SHMonth -1;
	AnotherYear = (AnotherMonth==0)? SHYear-1:SHYear;
	AnotherMonth = (AnotherMonth==0)? 12:AnotherMonth;			
	YTmp = AnotherYear;
	MTmp = (AnotherMonth<10)?"0" + AnotherMonth:AnotherMonth;	
	var ADt = new Date(ShamsiToDate(YTmp + "/" + MTmp + "/" + "01" ));			
	YTmp = ADt.getFullYear();
	MTmp = ADt.getMonth()+1;
	MTmp = (MTmp<10)?"0"+MTmp:MTmp;
	DTmp = ADt.getDate();
	DTmp = (DTmp<10)?"0"+DTmp:DTmp;
	OTmp = OTmp + "<A href=\"?Date=" + YTmp + "/" + MTmp + "/" + DTmp + "\" class=Link><font class=SmallBlackText><B>&lt;&lt;</B></font></A>";
	OTmp = OTmp + "</TD><TD align=center colspan=3><font class=SmallBlackText>";
	OTmp = OTmp + SHYear + "/" + SHMonth;
	OTmp = OTmp + "</font></TD><TD align=right colspan=2>";
	AnotherMonth = SHMonth +1;
	AnotherYear = (AnotherMonth==13)? SHYear+1:SHYear;
	AnotherMonth = (AnotherMonth==13)? 1:AnotherMonth;		
	YTmp = AnotherYear;
	MTmp = (AnotherMonth<10)?"0" + AnotherMonth:AnotherMonth;		
	var ADt = new Date(ShamsiToDate(YTmp + "/" + MTmp + "/" + "01" ));	
	YTmp = ADt.getFullYear();
	MTmp = ADt.getMonth()+1;
	MTmp = (MTmp<10)?"0"+MTmp:MTmp;
	DTmp = ADt.getDate();
	DTmp = (DTmp<10)?"0"+DTmp:DTmp;	
	OTmp = OTmp + "<A href=\"?Date=" + YTmp + "/" + MTmp + "/" + DTmp + "\" class=Link><font class=SmallBlackText><B>&gt;&gt;</B></font></A>";	
	OTmp = OTmp + "</TD></TR>"	;
	d=1;dFlag= false;
	var CDt = new Date();
	YTmp = CDt.getFullYear();
	MTmp = 1+CDt.getMonth();
	MTmp = (MTmp<10)?"0"+MTmp:MTmp;
	DTmp = CDt.getDate();
	DTmp = (DTmp<10)?"0"+DTmp:DTmp;		
	var SHCDt = DateToFarsi(YTmp + "/" + MTmp + "/" + DTmp);		
	OTmp = OTmp + "<TR class=ListOddRow><TD align=center>&#1588;</TD><TD align=center>&#1740;</TD><TD align=center>&#1583;</TD><TD align=center>&#1587;</TD><TD align=center>&#1670;</TD><TD align=center>&#1662;</TD><TD align=center>&#1580;</TD></TR>";
	for(i=0; d<=Maxdays ; i++)
		{OTmp = OTmp + "<TR class=";
		 if(i % 2) OTmp = OTmp + "ListEvenRow>";
		 else OTmp = OTmp + "ListOddRow>";
		 for(j=0;(j<7) && (d<=Maxdays);j++)
			{if(!dFlag)
				{if(SHW==j) dFlag=true;
				}						
			 OTmp = OTmp + "<TD align=center ";
			 if(d==GetShamsiDay(SHCDt)){
				 if((GetShamsiYear(SHCDt)==SHYear) && (GetShamsiMonth(SHCDt)==SHMonth))
					{
					OTmp = OTmp + "bgcolor=Salmon";
					}
				 }
			 OTmp = OTmp + "><font class=SmallBlackText>";
			 if(dFlag){
				OTmp = OTmp + "<A href=javascript:" + e + ".value='" + d + "/" + ((SHMonth<10)? "0"+SHMonth:SHMonth) + "/" + SHYear + "';window.close(); class=Link>";
				OTmp = OTmp + d;
				OTmp = OTmp + "</A>";
				d= d+1;	
				}
			 else OTmp = OTmp + " ";
			 OTmp = OTmp + "</font></TD>";
			}
		OTmp = OTmp + "</TR>";
		}
	OTmp = OTmp + "</TABLE>";
	return(OTmp);		
	}

function DateToFarsi(Dt)
	{
	var Sh_Y,Sh_M,Sh_D;
	var Res, Days, TmpY, Leap;
    var ndt = new Date(Dt);
	var sdt = new Date("1900/01/01");	 	
	Days = ((ndt.getTime()-sdt.getTime()) /(1000 * 60 * 60 * 24));		     	 
    Res = Days     
    if (Res <= 78) {
       Sh_Y = 1278;
       Sh_M = (Res + 10) / 30 + 10;
       Sh_D = (Res + 10) % 30 + 1;
    }
    else{
        Res = Res - 78;
        Sh_Y = 1279;
        while (true) {
            TmpY = Sh_Y + 11;
            TmpY = TmpY % 33;
            if ((TmpY != 32) && (TmpY % 4 == 0))
                Leap = 1;
            else
                Leap = 0;
            if (Res <= (365 + Leap))
                break;
            Res = Res - (365 + Leap);
            Sh_Y = Sh_Y + 1;
        }
        if (Res <= 31 * 6) {
            Sh_M = (Res - 1) / 31 + 1;
            Sh_D = (Res - 1) % 31 + 1;
        }
        else{
            Sh_M = ((Res - 1) - 31 * 6) / 30 + 7;
            Sh_D = ((Res - 1) - 31 * 6) % 30 + 1;
        }
    }	  Sh_M = Math.ceil(Sh_M);	  
	  Sh_D = Math.ceil(Sh_D);	  	  
	  Sh_M = (Sh_M <10)?"0"+Sh_M:Sh_M;
	  Sh_D = (Sh_D <10)?"0"+Sh_D:Sh_D;	  return( Sh_Y + "/" + Sh_M + "/" + Sh_D );
	}


function GetShamsiYear(Dt) 
     {
		return((Dt+"").substring(0,(Dt+"").indexOf("/")));
     }

function GetShamsiMonth(Dt) 
	 {
	 var DTmp;	 
	 DTmp = (Dt+"").substring((Dt+"").indexOf("/")+1,(Dt+"").length);	 	 
	 return(DTmp.substring(0,DTmp.indexOf("/")));
	 }
function GetShamsiDay(Dt) 
    {var DTmp;
	 DTmp = (Dt+"").substring((Dt+"").indexOf("/")+1,(Dt+"").length);	 	 
	 DTmp = DTmp.substring(DTmp.indexOf("/")+1,DTmp.length);
	 return(DTmp.substring(0,DTmp.length));
    }
function ShamsiToDate(Dt)
	 {	 
     var ndt = new Date();
     var sdt = new Date("1900/01/01");	 
     var I, Leap, D_of_Y;
     var TmpY, Res;     var Sh_Y=eval(GetShamsiYear(Dt));
     var Sh_M=eval(GetShamsiMonth(Dt));     var Sh_D=eval(GetShamsiDay(Dt));
     if (Sh_Y < 100)
		Sh_Y = Sh_Y + 1300;
     if (Sh_M >= 7)
		D_of_Y = 31 * 6 + (Sh_M - 7) * 30 + Sh_D;
     else
		D_of_Y = (Sh_M - 1) * 31 + Sh_D;
     if (Sh_Y == 1278)
		Res = D_of_Y - (31 * 6 + 3 * 30 + 11);
     else
        Res = 365 - (31 * 6 + 3 * 30 + 11) + 1;
	 I = 1279;
     while (I < Sh_Y){
		TmpY = I + 11;
		TmpY = TmpY % 33;
		if ((TmpY != 32) && (TmpY % 4 == 0))
			Leap = 1;
		else
			Leap = 0;
		if (Leap == 1)
			Res = Res + 366;
		else
			Res = Res + 365;
        I = I + 1;
    }
    Res = Res + D_of_Y - 1;
    Res *= 24 * 3600 * 1000 ;
    ndt.setTime(sdt.getTime()+ Res); 
    var YTmp,MTmp,DTmp;
    YTmp=ndt.getFullYear();           
    MTmp= 1+ ndt.getMonth();    
    DTmp= ndt.getDate();
	MTmp = (MTmp <10)?"0"+MTmp:MTmp;
	DTmp = (DTmp <10)?"0"+DTmp:DTmp;
    return( YTmp + "/" + MTmp + "/" + DTmp);
}	
// End of Calendar Section

//-------- Email Validation Checker----------
function EmailValidation(FieldValue,MaxLength,FieldName,Required)
{
	atsign=0;
	t = FieldValue;
	n= t.length;
	if ((n > MaxLength)||(n < 5 ))
	{
		if(Required)
		{ 
			alert("Enter between 5 to " + MaxLength + " charachters in \"" + FieldName + "\" as email address to continue.");
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{		
		for (i=0;i<=n;i++)
		{
			if (t.substring(i,i+1)=="@")
			{
			atsign++;
			}
		}
		if ((atsign==1)&(t.indexOf(".")!=-1))
		{
			return true;
		}
		else
		{
			alert("Enter correct email address in \"" + FieldName + "\" to continue.");
			return false;
		}
	}
}
//----------------------------------------------
//-------- Date Validation Checker --------
function DateValidation(FieldValue,FieldName,Required)
{		
	var Day = FieldValue.substring(0,FieldValue.indexOf("/"));
	FieldValue = FieldValue.substring(FieldValue.indexOf("/")+1,FieldValue.length);		
	var Month = FieldValue.substring(0,FieldValue.indexOf("/"));
	var Year = FieldValue.substring(FieldValue.indexOf("/")+1,FieldValue.length);			
	var sdt = new Date(Year + "/" + Month + "/" + Day);	
	if((sdt.getFullYear()==Year) && (sdt.getMonth()==Month -1) && (sdt.getDate()==Day))
		{return true;
		}
	else{
		alert("Enter correct date in \"" + FieldName + "\" to continue.");
		return false;
		}	
}
//-----------------------------------------
//-------- Date Validation Checker2 --------
function DateValidation2(FieldValue,FieldName,Required)
{		
	if (FieldValue.length==0)
	{
		return true;
	}
	else
	{
		
		
		var Year = FieldValue.substring(0,FieldValue.indexOf("/"));
		FieldValue = FieldValue.substring(FieldValue.indexOf("/")+1,FieldValue.length);		
		var Month = FieldValue.substring(0,FieldValue.indexOf("/"));
		var Day = FieldValue.substring(FieldValue.indexOf("/")+1,FieldValue.length);			
		var sdt = new Date(Year + "/" + Month + "/" + Day);	
		
		
		if((sdt.getFullYear()==Year) && (sdt.getMonth()==Month -1) && (sdt.getDate()==Day))
			{return true;
			}
		else{
			alert("Enter correct date in \"" + FieldName + "\" to continue.");
			return false;
			}	
	}
}
//-----------------------------------------
//-------- Time Validation Checker --------
function TimeValidation(FieldValue,FieldName,Required)
{	
	var Hour = FieldValue.substring(0,FieldValue.indexOf(":"));
	FieldValue = FieldValue.substring(FieldValue.indexOf(":")+1,FieldValue.length);			
	var Minute = FieldValue.substring(0,2);		
	var anum=/(^\d+$)|(^\d+\.\d+$)/;
	if (!anum.test(Hour))
	{	
		return false;
	}
	if (!anum.test(Minute))
	{
		return false;
	}	
	if (FieldValue.indexOf("PM") >= 0)
		{Hour = eval(Hour) + 12;	
		 if(Hour==24) Hour =0;
		}	
	if((Hour>=0) && (Hour<24) && (Minute>=0) && (Minute<60))
		{return true;		
		}
	else{
		alert("Enter correct time in \"" + FieldName + "\" to continue.");
		return false;
		}	
}
//-----------------------------------------
//-------- Number Validation Checker----------
function NumberValidation(FieldValue,MaxLength,FieldName,Required)
{
	var x=FieldValue
	n= x.length;
	if ((n > MaxLength)||(n == 0 ))
	{	
		if(Required)
		{
			alert("Enter between 1 to " + MaxLength + " digits in \"" + FieldName + "\" to continue.");
			return false;
		}
		else
		{
			return true;
		}
	}
	var anum=/(^\d+$)|(^\d+\.\d+$)/;
	if (anum.test(x))
	{
		testresult=true;
	}
	else
	{
		alert("Enter correct number in \"" + FieldName + "\" to continue.");
		testresult=false;
	}
	return (testresult);
}
//-------------------------------
//-------- Number Validation Checker 2----------
function NumberValidation2(FieldValue,MaxLength,FieldName,Required)
{
	var x=FieldValue
	n= x.length;
	if (n < MaxLength)
	{	
		if(Required)
		{
			alert("Enter " + MaxLength + " digits in \"" + FieldName + "\" to continue.");
			return false;
		}
		else
		{
			return true;
		}
	}
	var anum=/(^\d+$)|(^\d+\.\d+$)/;
	if (anum.test(x))
	{
		testresult=true;
	}
	else
	{
		alert("Enter correct number in \"" + FieldName + "\" to continue.");
		testresult=false;
	}
	return (testresult);
}
//-------------------------------
//-------- Number Validation Checker 3----------
function NumberValidation3(FieldValue,MaxLength,FieldName,Required)
{
	var x=FieldValue
	n= x.length;
	if (n==0)
		{
		Required=false;
		}
	if (n < MaxLength)
	{	
		if(Required)
		{
			alert("Enter between 1 to " + MaxLength + " digits in \"" + FieldName + "\" to continue.");
			return false;
		}
		else
		{
			return true;
		}
	}
	var anum=/(^\d+$)|(^\d+\.\d+$)/;
	if (anum.test(x))
	{
		testresult=true;
	}
	else
	{
		alert("Enter correct number in \"" + FieldName + "\" to continue.");
		testresult=false;
	}
	return (testresult);
}
//-------------------------------
//-------------Phone Validation Checker
function PhoneValidation(FieldValue,MinLength,MaxLength,FieldName,Required)
{
	var x=FieldValue;
	n=x.length;
	if((n > MaxLength)||(n < MinLength))
	{
		if(Required)
		{
			alert("Enter between " + MinLength + " to " + MaxLength + " digits as phone number in \"" + FieldName + "\" to continue.");
			return false;
		}
		else
		{
			return true;
		}
	}	
	var checkOK ="+()0123456789- " ;     	
	var checkStr = x;
	var allValid = true;
	for (i = 0; i <checkStr.length;i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;j < checkOK.length;j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j >= checkOK.length)
		{
			allValid = false;
			break;
		}
	}
	if (!allValid)
	{
		alert("Enter correct phone number in \"" + FieldName + "\" to continue.");
		return false;
	}
	else
	{
		return true;
	}
}
	
//----------------------------------
//-------------Fax Validation Checker
function FaxValidation(FieldValue,MinLength,MaxLength,FieldName,Required)
{
	var x=FieldValue;
	n=x.length;
	if((n > MaxLength)||(n < MinLength))
	{
		if(Required)
		{
			alert("Enter between " + MinLength + " to " + MaxLength + " digits as phone number in \"" + FieldName + "\" to continue.");
			return false;
		}
		else
		{
			return true;
		}
	}	
	var checkOK ="+()0123456789- " ;     	
	var checkStr = x;
	var allValid = true;
	for (i = 0; i <checkStr.length;i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;j < checkOK.length;j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j >= checkOK.length)
		{
			allValid = false;
			break;
		}
	}
	if (!allValid)
	{
		alert("Enter correct Fax number in \"" + FieldName + "\" to continue.");
		return false;
	}
	else
	{
		return true;
	}
}

//-------------Letter Validation Checker
// Set MaxLength = 0 for Optional Data
// Set FieldType = LETTERS for Letters
// Set FieldType = LETTERS_NS for Letters with no space
// Set FieldType = LETTERS_NUMBERS for Letters and Numbers
// Set FieldType = LETTERS_NUMBERS_NS for Letters and Numbers with no space
// Set FieldType = LETTERS_WHITESPACES for Letters and Whitespaces
// Set FieldType = ALL for all type of texts
	
function LetterValidation(FieldValue,MaxLength,FieldType,FieldName,Required)
{
	var x=FieldValue
	n=x.length;
	if((n > MaxLength)||(n==0))
	{
		if(Required)
		{
			alert("Enter between 1 to " + MaxLength + " charachters in \"" + FieldName + "\" to continue.");
			return false;
		}
		else
		{
			return true;
		}
	}	
	if (FieldType == "LETTERS" )
	{
		var checkOK =" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmanopqrstuvwxyz";     
	}
	if (FieldType == "LETTERS_NS" )
	{
		var checkOK ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";     
	}
	if (FieldType == "LETTERS_NUMBERS" )
	{
		var checkOK =" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	}
	if (FieldType == "LETTERS_NUMBERS_NS" )
	{
		var checkOK ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";     
	}
	if (FieldType == "LETTERS_WHITESPACES" )
	{
		var checkOK =" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz()_\|*&^%$#@!~`><.,?/+-";     
	}
	if (FieldType == "ALL" )
	{
		var checkOK =" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()_\|*&^%$#@!~`><.,?/+-";     
	}
	
	var checkStr = x;
	var allValid = true;
	for (i = 0; i <checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
	}
	if (!allValid)
		{
		alert("Enter correct text in \"" + FieldName + "\" to continue.");
		return false;
		}
	else 
		{
		return true;
		}
}
//-->
