
//-------------------
// Confirm Delete
//-----------------
function confirmDelete()
{
   var del=confirm("Do you really want to delete this record?");
   return del;		
}
//-------------------
// Confirm Payment Status Change
//-----------------
function confirmPayStatChange()
{
	var del=confirm("Do you really want to change the payment status?");
   return del;		
}

//-------------------
// Validate Phone Number
//-----------------

function validatePhoneNumber(ctrl)
{
	if((event.keyCode < 48 || event.keyCode>57||ctrl.value.length>11))
	event.returnValue= false
		
	if(ctrl.value.length==3 || ctrl.value.length==7)
	ctrl.value=ctrl.value+'-';
}


function limitOtherSchool(ctrl)
{
	if((event.keyCode ==13||ctrl.value.length>160))
	event.returnValue= false;
}

function limitfamilyWithDematha(ctrl)
{
	if((event.keyCode ==13||ctrl.value.length>160))
	event.returnValue= false
}

function limitContactName(ctrl)
{
	if((event.keyCode ==13||ctrl.value.length>30))
	event.returnValue= false
}

function limitContactTitle(ctrl)
{
	if((event.keyCode ==13||ctrl.value.length>30))
	event.returnValue= false
}


function limitdisability(ctrl)
{
	if((event.keyCode ==13||ctrl.value.length>320))
	event.returnValue= false
}

function limitClubs(ctrl)
{
	if((event.keyCode ==13||ctrl.value.length>720))
	event.returnValue= false
}
function limit_essay(ctrl)
{

	if(event.keyCode ==13)
	event.returnValue= false
	var i;var noWord=0;
	var prev="";
	var str=ctrl.value;

	for(i=0;i<str.length;i++)
	{
		if(str.charAt(i)==' ')
		{
		  if(prev!=' ')
			{
			noWord++;			
			}
			
		}
		prev=str.charAt(i);
		
		if(noWord==200)
		{
			event.returnValue=false;
		}
	}
}

function limit_middle(ctrl)
{
	if((ctrl.value.length>0))
	event.returnValue= false
		
	//if(ctrl.value.length==3 || ctrl.value.length==7)
	//ctrl.value=ctrl.value+'-';
}

function limit_zip(ctrl)
{
	if((event.keyCode < 48 || event.keyCode>57||ctrl.value.length>4))
	event.returnValue= false
}

//-------------------
// Validate Social Security Number
//-----------------
function validateSocialSecurityNumber(ctrl)
{
	if((event.keyCode < 48 || event.keyCode>57||ctrl.value.length>10))
	event.returnValue= false
		
	if(ctrl.value.length==3 || ctrl.value.length==6)
	ctrl.value=ctrl.value+'-';
}
//-------------------
// Email Validation
//-----------------
function checkEmail(emailStr) {
   if (emailStr.length == 0) {
	   return true;
   }
   var emailPat=/^(.+)@(.+)$/;
   var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
   var validChars="\[^\\s" + specialChars + "\]";
   var quotedUser="(\"[^\"]*\")";
   var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/;
   var atom=validChars + '+';
   var word="(" + atom + "|" + quotedUser + ")";
   var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
   var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$");
   var matchArray=emailStr.match(emailPat);
   if (matchArray == null) {
	   return false;
   }
   var user=matchArray[1];
   var domain=matchArray[2];
   if (user.match(userPat) == null) {
	   return false;
   }
   var IPArray = domain.match(ipDomainPat);
   if (IPArray != null) {
	   for (var i = 1; i <= 4; i++) {
		  if (IPArray[i] > 255) {
			 return false;
		  }
	   }
	   return true;
   }
   var domainArray=domain.match(domainPat);
   if (domainArray == null) {
	   return false;
   }
   var atomPat=new RegExp(atom,"g");
   var domArr=domain.match(atomPat);
   var len=domArr.length;
   if ((domArr[domArr.length-1].length < 2) ||
	   (domArr[domArr.length-1].length > 3)) {
	   return false;
   }
   if (len < 2) {
	   return false;
   }
   return true;
}
//-------------------
// Declare Vars
//-----------------
var ie5 = (document.all && !document.getElementById) ? 1 : 0;
var ie6 = (document.all && document.getElementById) ? 1 : 0;
var mozilla = (!document.all && document.getElementById) ? 1 : 0;
//-------------------
// Get Object
//-----------------
function getObject(e) {
	var obj;
	if(ie5)
		obj = eval("document.all." + e);
	else if(ie6 || mozilla)
		obj = document.getElementById(e);
	return obj;
}
function validateDate( strValue )
{

  var objRegExp = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
 
  if(!objRegExp.test(strValue))
    return false; //doesn't match pattern, bad date
  else{
    //var strSeparator = strValue.substring(2,3) //find date separator
    var strSeparator = strValue.substring(4,5) //find date separator
    
    var arrayDate = strValue.split(strSeparator); //split date into month, day, year [now Year, mon, day]
   
    var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,'10' : 31,'11' : 30,'12' : 31}
    var intDay = parseInt(arrayDate[2],10); //was 1 for day

   
    if(arrayLookup[arrayDate[1]] != null) { //was 0 for month
      if(intDay <= arrayLookup[arrayDate[1]] && intDay != 0) 
        return true;
    }
 
    var intMonth = parseInt(arrayDate[1],10); //was 0 for month
    if (intMonth == 2) { 
       var intYear = parseInt(arrayDate[0]); // was 2 for year
       if (intDay > 0 && intDay < 29) {
           return true;
       }
       else if (intDay == 29) {
         if ((intYear % 4 == 0) && (intYear % 100 != 0) || (intYear % 400 == 0)) {
           
             return true;
         }   
       }
    }
  }  
  return false;
}
//-------------------
// Is Number
//-----------------
 function isNumber(inputVal)
 {
	oneDecimal = false
	inputStr = inputVal.toString()
	for (var i = 0; i < inputStr.length; i++)
	{
		var oneChar = inputStr.charAt(i)
		if (oneChar == "." && !oneDecimal)
		{
			oneDecimal = true
			continue
		}
		if (oneChar < "0" || oneChar > "9")
		{
			return false
		}
	}
	return true
 }
//-------------------
// Integer
//-----------------
 function isPosInteger(inputVal) 
 {
	inputStr = inputVal.toString()
	for (var i = 0; i < inputStr.length; i++) 
	{
		var oneChar = inputStr.charAt(i)
		if (oneChar < "0" || oneChar > "9") 
		{
			return false
		}
	}
	return true
 }

//-------------------
// Check All
//-----------------
function CheckAll(checked) 
{
var x=getObject('div_table').rows;
len = document.frm.elements.length;
    var i;
    for (i=0; i < len; i++) 
	{
        if (document.frm.elements[i].name=='app_id_list[]') 
	{
	document.frm.elements[i].checked=checked;
	if(checked==1)	
	x[i-1].className='change_bg';				
	else x[i-1].className='restore_bg';				
	}
    }
}
//-------------------
// Test Check
//-----------------
function test_check() 
{
len = document.frm.elements.length;
    var i ;
    var trap=0;

    for (i=0; i < len; i++) 
    {
        if (document.frm.elements[i].name=='app_id_list[]') 
	if(document.frm.elements[i].checked==1)
	{

	 trap=1;
	 break;
	}
       
    }
	if(trap==1)
	return true
	else
	{
		alert("Please select applicant to send notification.");
		return false
	}

}
//-------------------
// Show Name
//-----------------
function show_save_name()
{
	//alert('sumon');
	len = document.frm2.elements.length;
	var i ;
	for (i=0; i < len; i++) 
	{
           if (document.frm2.elements[i].name=='saveName') 
	   alert("dfdsfds")
	   document.frm2.elements[i].innerHTML="<input type='text' name='query_name'>"
       
    	}			
}
//-------------------
// Confirm 
//-----------------
function confrm()
{
	var x=confirm("This will update the status of this application. Are you sure?");
	return x;
}
//-------------------
// Confirm Delete
//-------------------
function cnfrm_del()
{
	var x=confirm("Are sure to delete the query?");
	return x;
}
//-------------------
// Check Empty Lable
//-------------------
function lbl_empty()
{
	
	var x=getObject('label_name');
	if(x.value=="")
		{
			alert("Please provide Label Name.");
			return false;
		}
return true;
}
//-------------------
// Load Popups
//-------------------
function loadPopUp(abc,h,w)
{
	//var randomnumber=Math.floor(Math.random()*11);
	var now = new Date();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	randomnumber=minutes +seconds ;	
	window.open(abc,randomnumber,'height='+h+',width='+w+',left=50,top=50,status=no,toolbar=no, menubar=no,location=no, titlebar=no, resizable=no, scrollbars=yes');
}

//----------------------
// Tree Menu
//----------------------
function changeTreeStyle(fiRow)
{
	
	var fiRow1=fiRow+'-b';	
	var fiRow2=fiRow+'-c';
	var fiRow3=fiRow+'-img';
	
	rowObj1 = getObject(fiRow1);
	rowObj2 = getObject(fiRow2);
	rowObj3 = getObject(fiRow3);
		
	if(rowObj1.style.display =='none' )
	{
		rowObj1.style.display ='Block';
		rowObj2.style.display ='none';
	}
	else
	{
		rowObj1.style.display ='none' ;
		rowObj2.style.display ='Block';
	}
}
//----------------------
// Show Hide
//----------------------
function showHideURLBox()
{
	rowObj1 = getObject('urlBox');
	rowObj2 = getObject('pageBox');
	rowObj3 = getObject('urlBoxTitle');
	rowObj4 = getObject('menu_type');

	if(rowObj1.style.display =='none' )
	{
		rowObj1.style.display ='Block';
		rowObj2.style.display ='none';
		rowObj3.innerHTML ='<b>Link To URL</b>';
		rowObj4.value =3;
	}
	else
	{
		rowObj1.style.display ='none' ;
		rowObj2.style.display ='Block';
		rowObj3.innerHTML ='<b>Link To Page</b>';
		rowObj4.value =2;
	}
} 
//----------------------
// Show Hide
//----------------------
function showHideMenuBox()
{
	rowObj1 = getObject('childMenus');
	rowObj2 = getObject('newChildMenu');
	rowObj3 = getObject('new_menu');

	if(rowObj1.style.display =='none' )
	{
		rowObj1.style.display ='Block';
		rowObj2.style.display ='none';
		rowObj3.value ='';
	}
	else
	{
		rowObj1.style.display ='none' ;
		rowObj2.style.display ='Block';
		rowObj3.value =1;
	}
} 
//-------------
//-------------
function fname_disappear(ctrl)
{
	if(ctrl.value=='First Name')
	ctrl.value='';			
}
//-------------
//-------------
function fname_appear(ctrl)
{
	if(ctrl.value=='')
	ctrl.value='First Name';
}
//-------------
//-------------
function mname_disappear(ctrl)
{
	if(ctrl.value=='M.I.')
	ctrl.value='';			
}
//-------------
//-------------
function mname_appear(ctrl)
{
	if(ctrl.value=='')
	ctrl.value='M.I.';
}
//-------------
//-------------
function lname_disappear(ctrl)
{
	if(ctrl.value=='Last Name')
	ctrl.value='';			
}
//-------------
//-------------
function lname_appear(ctrl)
{
	if(ctrl.value=='')
	ctrl.value='Last Name';
}

//-------------
//-------------
function address_disappear(ctrl)
{
	if(ctrl.value=='Address')
	{
	ctrl.value='';			
	}
}

//-------------
//-------------
function address_appear(ctrl)
{
	if(ctrl.value=='')
	ctrl.value='Address';
}
//-------------
//-------------
function street_disappear(ctrl)
{
	if(ctrl.value=='Street')
	ctrl.value='';			
}
//-------------
//-------------
function street_appear(ctrl)
{
	if(ctrl.value=='')
	ctrl.value='';
}
function email_disappear(ctrl)
{
	if(ctrl.value=='E-mail Address')
	ctrl.value='';			
}
//-------------
//-------------
function email_appear(ctrl)
{
	if(ctrl.value=='')
	ctrl.value='E-mail Address';
}
//-------------
//-------------

//-------------
//-------------

function zip_disappear(ctrl)
{
	if(ctrl.value=='Zip')
	ctrl.value='';			
}
//-------------
//-------------
function zip_appear(ctrl)
{
	if(ctrl.value=='')
	ctrl.value='Zip';
}
//-------------
//-------------
function city_disappear(ctrl)
{
	if(ctrl.value=='City')
	ctrl.value='';			
}
//-------------
//-------------
function city_appear(ctrl)
{
	if(ctrl.value=='')
	ctrl.value='City';
}
//-------------
//-------------
function lockUser(val)
{
	var str,del;
   if (val==1) str="Do you want Lock this User?";
   else str="Do you want Unlock this User?";
   del=confirm(str);
   return del;		
}
//-----------
//-----------
function resetPassword()
{
   del=confirm("Do you want to Reset the Password?");
   return del;		
}


