﻿// JScript File
var retVal;

function fnOpenPopup(TableName,ColumnName,AliasName,WhereClause,ReturnControl){
    var q = "?TableName=" + TableName + "&ColumnName=" + ColumnName + "&AliasName=" + AliasName + "&WhereClause=" + WhereClause + "&ReturnControl=" + ReturnControl;
   // var IEsetting="dialogHeight:450px;dialogWidth:800px;dialogLeft:150px;dialogTop:150px;resizable:no;scroll:yes;status:no;";
   // var IEsetting="dialogHeight: 450px; dialogWidth: 640px; dialogTop: 646px; dialogLeft: 220px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;"
    var Mozilasetting="toolbar=no,status=no,scrollbar=yes,width=800,height=400,left=150,top=150,modal=yes";
//    if (window.showModalDialog) 
//    {
//       retVal = ShowModalDialog('../frmPopup.aspx'+q+'&Browser=IE','',IEsetting);
//    }
//    else
//    {
    //Added By hardik 
      window.open('../frmPopup.aspx'+q,"Search",Mozilasetting);
//       document.getElementById('outer').style.visibility = "visible";
//    document.getElementById('outermost').style.visibility = "visible";
//    document.getElementById('outermost').style.height = document.documentElement.scrollHeight + "px";
//    document.getElementById('outermost').style.width = document.documentElement.scrollWidth + "px";
//    document.getElementById('outer').style.height = "400px";
//    document.getElementById('outer').style.width = "700px";
//    makecenter('outer');
//    document.getElementById('outer').innerHTML="<iframe height='400' width='700' scrolling='yes' src='../frmPopup.aspx" + q + "'></iframe>";
//    //}
    //End Added
    
    return false;
}

function fnOpenFind(TableName,ColumnName,AliasName,WhereClause,ReturnControl){
    var q = "?TableName=" + TableName + "&ColumnName=" + ColumnName + "&AliasName=" + AliasName + "&WhereClause=" + WhereClause + "&ReturnControl=" + ReturnControl;
    var setting="toolbar=no,status=yes,scrollbar=yes,width=700,height=400,left=150,top=150";
   //window.open('../frmFind.aspx'+q,"Find",setting);
    
    document.getElementById('outer').style.visibility = "visible";
    document.getElementById('outermost').style.visibility = "visible";
    document.getElementById('outermost').style.height = document.documentElement.scrollHeight + "px";
    document.getElementById('outermost').style.width = document.documentElement.scrollWidth + "px";
    document.getElementById('outer').style.height = "400px";
    document.getElementById('outer').style.width = "700px";
    makecenter('outer');
    document.getElementById('outer').innerHTML="<iframe height='400' width='700' scrolling='yes' src='../frmFind.aspx" + q + "'></iframe>";
    
}

dFeatures = 'dialogHeight: 450px; dialogWidth: 640px; dialogTop: 646px; dialogLeft: 220px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;';//default features

modalWin = "null";
function xShowModalDialog( sURL, vArguments, sFeatures )
{
if (sURL==null||sURL=='')
{
alert ("Invalid URL input.");
return false;
}
if (vArguments==null||vArguments=='')
{
vArguments='';
}
if (sFeatures==null||sFeatures=='')
{
sFeatures=dFeatures;
}
//alert("window.navigator.appVersion="+window.navigator.appVersion);
if (window.navigator.appVersion.indexOf("MSIE")!=-1)
{

retVal=window.showModalDialog ( sURL, vArguments, sFeatures );
return false;
}
sFeatures = sFeatures.replace(/ /gi,'');
aFeatures = sFeatures.split(";");
sWinFeat = "directories=0,menubar=0,titlebar=0,toolbar=0,";
for ( x in aFeatures )
{
aTmp = aFeatures[x].split(":");
sKey = aTmp[0].toLowerCase();
sVal = aTmp[1];
switch (sKey)
{
case "dialogheight":
sWinFeat += "height="+sVal+",";
pHeight = sVal;
break;
case "dialogwidth":
sWinFeat += "width="+sVal+",";
pWidth = sVal;
break;
case "dialogtop":
sWinFeat += "screenY="+sVal+",";
break;
case "dialogleft":
sWinFeat += "screenX="+sVal+",";
break;
case "resizable":
sWinFeat += "resizable="+sVal+",";
break;
case "status":
sWinFeat += "status="+sVal+",";
break;
case "center":
if ( sVal.toLowerCase() == "yes" )
{
sWinFeat += "screenY="+((screen.availHeight-pHeight)/2)+",";
sWinFeat += "screenX="+((screen.availWidth-pWidth)/2)+",";
}
break;
}
}
modalWin=window.open(String(sURL),"",sWinFeat);
if (vArguments!=null&&vArguments!='')
{
modalWin.dialogArguments=vArguments;
}
}

function ShowDilog()
            {
            
                document.getElementById('light').style.visibility = "visible";
                document.getElementById('fade').style.visibility = "visible";
                document.getElementById('light').style.display = "block";
                document.getElementById('fade').style.display = "block";
               // document.getElementById('fade').style.height = "800px";
                document.getElementById('fade').style.height = document.documentElement.scrollHeight + "px";
                document.getElementById('fade').style.width = document.documentElement.scrollWidth + "px";
                document.getElementById('light').style.height = "200px";
                document.getElementById('light').style.width = "400px";
                
                makecenter('light');
             //   document.getElementById('DivAddStu').style.visibility = 'hidden';
                
                return false;    
            }


//  check for valid numeric strings	
function IsNumeric(strString)
{
    var strValidChars = "0123456789.-";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return true;

    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
    return blnResult;
}
function checkDate(Element, Format, Message)
{
	strValue = Element.value;
//	if(FieldAttrib["FullYear"]){
//		if(FieldAttrib["FullYear"]=="Yes"){
//			var objRegExp = /^\d{1,2}(\/)\d{1,2}(\/)\d{1,4}$/;
//		}else{
//			var objRegExp = /^\d{1,2}(\/)\d{1,2}(\/)\d{1,2}$/;
//		}
//	}
//	else
//	{
//			
//		var objRegExp = /^\d{1,2}(\/)\d{1,2}(\/)\d{1,2}$/;
//	}
    var objRegExp = /^\d{1,2}(\/)\d{1,2}(\/)\d{1,4}$/;
    alert(objRegExp.test(strValue));    
  	if(!objRegExp.test(strValue))
	{
		alert("Please enter a valid 0" + Message);		
		Element.focus();
		return false;
	}
  	else
	{
		var arrayDate = strValue.split("\/"); //split date into month, day, year
	    
		if(Format=="mm/dd/yy" || Format=="mm/dd/yyyy")
		{
			var intDay = parseInt(arrayDate[1],10); 
			var intYear = parseInt(arrayDate[2],10);
			var intMonth = parseInt(arrayDate[0],10);
		}
		else if(Format=="dd/mm/yy" || Format=="dd/mm/yyyy")
		{	
			var intDay = parseInt(arrayDate[0],10); 
			var intYear = parseInt(arrayDate[2],10);
			var intMonth = parseInt(arrayDate[1],10);
		}
		if(intMonth > 12 || intMonth < 1) {
			alert("Please enter a valid 1" + Message);
			Element.focus();   
			return false;
		}
		else
		{
			var arrayLookup = { '1' : 31,'3' : 31, '4' : 30,'5' : 31,'6' : 30,'7' : 31,
								'8' : 31,'9' : 30,'10' : 31,'11' : 30,'12' : 31}
			if(intMonth != 2) {
			  if(intDay <= arrayLookup[intMonth] && intDay != 0)
				return true;
			}
			else
			{
				if(FieldAttrib["FullYear"]=="Yes"){
					var booLeapYear = (intYear % 4 == 0 && (intYear % 100 != 0 || intYear % 400 == 0));
					if( ((booLeapYear && intDay <= 29) || (!booLeapYear && intDay <=28)) && intDay !=0)
					  return true;
				}else{
					return true;
				}
			}
		}
	}
	alert("Please enter a valid 2" + Message);	
	Element.focus();
  	return false;
}


function makecenter(id)
{
       
       var brSize = getBRSize();
	    
	    var WWidth='';
        WWidth=document.getElementById(id).style.width;
        WWidth=parseInt(WWidth.substring(0,WWidth.length-2));
       
        var Wheight='';
        Wheight=document.getElementById(id).style.height;
        Wheight=parseInt(Wheight.substring(0,Wheight.length-2));
        
	    document.getElementById(id).style.left=((brSize[0]-WWidth)/2)+'px';
	    document.getElementById(id).style.top=((brSize[1]-Wheight)/2)+'px';
    
}

  function getBRSize()
	    {
    	    var bodyWidth = document.documentElement.clientWidth;
    	    var bodyHeight = document.documentElement.clientHeight;
        	
		    var bodyWidth, bodyHeight; 
		    if (self.innerHeight){ // all except Explorer 
		       bodyWidth = self.innerWidth; 
		       bodyHeight = self.innerHeight; 
		    }  else if (document.documentElement && document.documentElement.clientHeight) {
		       // Explorer 6 Strict Mode 		 
		       bodyWidth = document.documentElement.clientWidth; 
		       bodyHeight = document.documentElement.clientHeight; 
		    } else if (document.body) {// other Explorers 		 
		       bodyWidth = document.body.clientWidth; 
		       bodyHeight = document.body.clientHeight; 
		    } 
		   var nav4=window.event?true:false;
           if (nav4) {
                     x =  document.documentElement.scrollLeft + document.body.scrollLeft;
                     y = document.documentElement.scrollTop + document.body.scrollTop;
                }
            else {
                     x =window.scrollX;
                     y = window.scrollY;
                }
            if(x == 'undefined' || x == null) x =0;    
            if(y == 'undefined' || y == null) y =0;    

            bodyWidth=bodyWidth+x;
            bodyHeight=bodyHeight+y
      
		    return [bodyWidth,bodyHeight];		
    		
	    }
	   
	   
	   function NumbersWithDotOnly(e)
            {
	            //alert('hi');
	            var unicode=e.charCode? e.charCode : e.keyCode
	            //alert(e.keyCode);
	            if (unicode!=8 && unicode!=9)
	            { //if the key isn't the backspace key(8) and Tab key (9) (which we should allow)
               if (unicode!=46)
	            { //if the key is "."
	            if (unicode<48||unicode>57) //if not a number
	            return false //disable key press
	            }
	            }
	        }
	   function NumbersWithSpace(e)
            {
	            var unicode=e.charCode? e.charCode : e.keyCode
	            if (unicode!=8 && unicode!=9)
	            { //if the key isn't the backspace key(8) and Tab key (9) (which we should allow)
                if (unicode!=32)
	            { //if the key is " "
	            if (unicode<48||unicode>57) //if not a number
	            return false //disable key press
	            }
	            }
	        }
         function NumbersOnly(e)
            {
	            //alert('hi');
	            var unicode=e.charCode? e.charCode : e.keyCode
	            //alert(unicode + ':' + e.keyCode);
	            if (unicode!=8 && unicode!=9)
	            { //if the key isn't the backspace key(8) and Tab key (9) (which we should allow)
	               
	                if (unicode<48||unicode>57) //if not a number
	                return false //disable key press
	               
	            }
	         }
	         
	     function AlphaNumericOnly(e)
            {
                var keycode;

                if (window.event) 
                    keycode = window.event.keyCode;
                else if (event) 
                    keycode = event.keyCode;
                else if (e) 
                    keycode = e.which;
                else return 
                    true;
                
                if( (keycode >= 47 && keycode <= 57) || (keycode >= 65 && keycode <= 90) || (keycode >= 97 && keycode <= 122) || keycode == 32)
                {
                    return true;
                }
                else
                {
                    return false;
                }
               return true;
            }
            
     function fnSearch()
       {                     
        var searchText = document.getElementById('txtSearch').value;
        searchText = searchText.replace (/\s+/g, '')
      
         if(searchText == '')
         {
           alert('Please enter keyword for search.');
           document.getElementById('txtSearch').focus();
           return false;
         } 
         else
         { 
           //window.location.href= "http://www.gksgujarat.org/frmSearch.aspx?SearchText=" + searchText; 
           //window.location.href="/about_department/frmSearch.aspx?SearchText=" + searchText;
           window.location.href="/about_department/frmSearch.aspx?SearchText=" + searchText;           
         }
       }
       
    function NumbersWithColonOnly(e,ctl)
    {
        var unicode=e.charCode? e.charCode : e.keyCode
        if(unicode != 9)
	    {
            if (unicode!=8)
	        {
               switch(ctl.value.length)
               {
                    case 0:{     
                            if (unicode<48||unicode>50)
                                return false;
                            break;}
                    case 1:{
                            if(ctl.value == "0" || ctl.value == "1" )
                            {    if (unicode<48||unicode>57)
                                    return false;
                            }   
                            else
                            {
                                 if (unicode<48||unicode>51)
                                    return false;
                            }
                            break;}
                    case 2:{
                            ctl.value += ":";
                           }
                    case 3:{
                            if (unicode<48||unicode>53)
                                return false;
                            break;}
                    case 4:{
                            if (unicode<48||unicode>57)
                            return false;
                           break;}
               }
            }
	    }
    }
            
            