/*functions to set tab active*/

function extractPageName(hrefString)
{
/* this functions enables to extract module name from url string*/
	var strURL = hrefString; /*retrieve's URL*/
	var str = strURL.toString();
	var str1 = str.indexOf('.php');
	if(str1 == -1)
	{
		var str1 = str.indexOf('partner/');
	}
	var str2 = str.length;
	var strR = str.substr(str1, str2); 
	var strModule = strR.substr(strR.indexOf('/')+1, strR.indexOf('/')); /*retrieve's module name here*/
	return strModule.toLowerCase();

}
function setActiveMenu(arr, crtPage)
{
	for(var i=0; i < arr.length; i++)
		if(extractPageName(arr[i].href) == crtPage)
		{	
			arr[i].className = "current";
			arr[i].parentNode.className = "current";
		}
}

function setPage()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location.toString();

	if (document.getElementById("menu")!=null) 
		setActiveMenu(document.getElementById("menu").getElementsByTagName("a"), extractPageName(hrefString));
	
}
function extractLinkID(hrefString)
{
	var str = hrefString.toString();
	
	var strLinkID = str.substr(str.lastIndexOf('/')+1, str.length); /*retrieve's module name here*/
	return strLinkID.toLowerCase();

}

function setActiveTabs(arr, crtPage)
{
	
	for(var i=0; i < arr.length; i++)
		if(extractLinkID(arr[i].href) == crtPage)
		{
			arr[i].className = "current_tab";
			arr[i].parentNode.className = "current_tab";
		}
}
function setNavTabs()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location.toString();

	if (document.getElementById("nav_tabs")!=null) 
		setActiveTabs(document.getElementById("nav_tabs").getElementsByTagName("a"), extractLinkID(hrefString));
		
		
	setActiveTabs(document.getElementById('activeschools'), extractLinkID(hrefString));
}

function setDefaultTab()
{

if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location.toString();
		
	var str = hrefString.toString();
	var strList = str.indexOf('list').toString();
	var strSlash =  str.lastIndexOf('/').toString();
if(strList > strSlash)
{
	
window.location.assign(""+hrefString+"/lstStatus/1")
//document.getElementById('activeschools').className = 'current_tab';
	return true;
		
	}
}
/*functions to set tab active*/
/*functions to set tab active*/
/*function to check check boxes*/
function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}

function check_all(group, action)
{
    if(group.length>1)
    {
         for (var i=0; i<group.length; i++)
          group[i].checked = action;
    }
    else
    {
        group.checked=action;
    }
}


function check_all_new(group1,group2,th)
{
/*This function is written by Sandip to replicate above fucntion written by Aashish for minor changes*/
 for (var i=0; i<group1.length; i++)
  group1[i].checked = th.checked;
 for (var i=0; i<group2.length; i++)
  group2[i].checked = th.checked;
}

/*function to check check boxes*/
		/*function for image pre-loading*/
		
		<!--
		var myimages = new Array();
		function preloading(){
		for (x=0; x<preloading.arguments.length; x++){
		myimages[x] = new Image();
		myimages[x].src = preloading.arguments[x];
		}
		}
		var getImages = document.images;
		
		for (var i=0; i<= getImages.length; i++  )
		{
			if(typeof(getImages[i])!='undefined')
			{
				preloading(getImages[i]);
			}
		}
		// -->

/*JS function to hide/show container, this function considers main section id & it's parent container's id as it's arguments*/
function getContainerID(ident, CntrlID)
{
var conT = document.getElementById(CntrlID).getElementsByTagName('span');
var conT_ID = conT.id;
	for(var i=0; i<conT.length; i++)
	{
	var conT_ID = conT[i].id;
		
		if(ident == conT_ID)
		{
			document.getElementById(conT_ID).style.display='block';
		}
		else
		{
			document.getElementById(conT_ID).style.display='none';
		}
	}
}
/*JS function to hide/show container ends here*/

/*JS function for tool tip display*/

var xPos;
var yPos;

function showToolTip(title,msg,evt){
	
    if (evt) {
        var url = evt.target;
    }
    else {
        evt = window.event;
        var url = evt.srcElement;
    }
    xPos = evt.clientX;
    yPos = evt.clientY;

   var toolTip = document.getElementById("toolTip");
   toolTip.innerHTML = "<h1>"+title+"</h1><p align='center'>"+msg+"</p>";
   toolTip.style.top = parseInt(yPos)+2 + "px";
   toolTip.style.left = parseInt(xPos)+2 + "px";
   toolTip.style.visibility = "visible";
   
}

function hideToolTip(){
   var toolTip = document.getElementById("toolTip");
   toolTip.style.visibility = "hidden";
}

/*JS function for tool tip display*/

function showToolTip2(title,msg,evt){
	
    if (evt) {
        var url = evt.target;
    }
    else {
        evt = window.event;
        var url = evt.srcElement;
    }
    var xPos2 = evt.clientX;
   var yPos2 = evt.clientY;

  var toolTip2 = document.getElementById("toolTip2");


   toolTip2.innerHTML = "<h1>"+title+"</h1><p align='center'>"+msg+"</p>";
   toolTip2.style.top = parseInt(yPos2)+2 + "px";
   toolTip2.style.left = parseInt(xPos2)+2 + "px";
   toolTip2.style.visibility = "visible";
   
}

function hideToolTip2(){
var toolTip2 = document.getElementById("toolTip2");

   toolTip2.style.visibility = "hidden";
}
/*JS function for tool tip display*/

/*JS Function to hide Image transparancy of a PNG image
method: just call this function [fixPNG()] on an Onload event of the concerned image.
*/

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}
/*JS Function to hide Image transparancy of a PNG image*/

/* Function to confirm the record Action for Deletion,In-Activate 
   Function written by Sandip to confirm user before his action to delete,inactivate */
function confirmAction(frmPost,th,checkBox_list,division,schoolId,schoolName)
{
	selectVal=th.value;	
	var chkFlag=false;
	if(checkBox_list.length > 0)
	{
		for(i=0;i<checkBox_list.length;i++)
		{  
			//if(checkBox_list[i].checked==true && parseInt(checkBox_list[i].value) )
			if(checkBox_list[i].checked==true)
			{
				chkFlag=true;
				break;
			}
		}	
	}
	if(chkFlag==false)
		{	alert('Select atleast one checkbox to execute action !! ');  th.value='';  return false; }
	var flag=false;
	var msg='';
	switch(selectVal) {
		case 'delete' :
						msg='Are you sure to delete ?';
						flag=true;
						break;
        case 'paid' :
                        msg='Are you sure to Mark as Paid?';
                        flag=true;
                        break;
         case 'notpaid' :
                        msg='Are you sure to Mark as Not Paid?';
                        flag=true;
                        break;
		case 'active' :
						msg='Are you sure to Activate ?';
						flag=true;
						break;
		case 'inactive' :
						msg='Are you sure to De-Activate ?';
						flag=true;
						break;
        case 'reprocessed' :
                        msg='Are you sure to Mark as Reprocessed ?';
                        flag=true;
                        break;
         case 'notreprocessed' :
                        msg='Are you sure to remove Marked as Reprocessed?';
                        flag=true;
                        break;
        case 'repost' :
                        msg='Are you sure to repost marked leads?';
                        flag=true;
                        break;  
        case 'requierd' :
                        msg='Are you sure to set Fields as Required?';
                        flag=true;
                        break; 
        case 'notrequired' :
                        msg='Are you sure to unset Fields as Required?';
                        flag=true;
                        break;  
		case 'hold' :
						msg='Are you sure to set the school on HOLD ?';
						flag=true;
						break;
		case 'unhold' :
						msg='Are you sure to remove the HOLD from school ?';
						flag=true;
						break;
        case 'overcap' :
                        msg='Are you sure to set the school to OVER CAP?';
                        flag=true;
                        break;
        case 'removeovercap' :
                        msg='Are you sure to remove the school from OVER CAP ?';
                        flag=true;
                        break;
		case 'featured' :
						msg='Are you sure to mark this school as featured ?';
						flag=true;
						break;
		case 'unfeatured' :
						msg='Are you sure to unmark this school as featured ?';
						flag=true;
						break;
		case 'dosccexclude' :
						msg='Are you sure to Exclude the school from DOS Call Center search ?';
						flag=true;
						break;
		case 'dosccinclude' :
						msg='Are you sure to Include the school from DOS Call Center search ?';
						flag=true;
						break;
		case 'dossearchexclude' :
						msg='Are you sure to Exclude the school from DOS search ?';
						flag=true;
						break;
		case 'dossearchinclude' :
						msg='Are you sure to Include the school from DOS search ?';
						flag=true;
						break;
		case 'markproduction' :
						msg='Are you sure to mark selected leads as production leads ?';
						flag=true;
						break;
		case 'marktest' :
						msg='Are you sure to mark selected leads as test leads ?';
						flag=true;
						break;
		case 'sendpartnerfpiintimation' :
						msg='Are you sure to send FPI update intimation to partners for selected schools ?';
						flag=true;
						break;
		case 'excludefromaddfieldpage' :
						msg='Are you sure to exclude selected fields from common field listing of Add Field page ?';
						flag=true;
						break;
		case 'includetoaddfieldpage' :
						msg='Are you sure to include selected fields to common field listing of Add Field page ?';
						flag=true;
						break;
		case 'scrublead' :
						msg='Are you sure to scrub the selected leads ?';
						flag=true;
						break;
		case 'validatelead' :
						msg='Are you sure to make the selected leads valid ?';
						flag=true;
						break;
		case 'acceptonlineleads' :
						msg='Are you sure to set the selected schools to accept online leads ?';
						flag=true;
						break;
		case 'dontacceptonlineleads' :
						msg='Are you sure to set the selected schools not to accept online leads ?';
						flag=true;
						break;
		case 'acceptgroundleads' :
						msg='Are you sure to set the selected schools to accept ground leads ?';
						flag=true;
						break;
		case 'dontacceptgroundleads' :
						msg='Are you sure to set the selected schools not to accept ground leads ?';
						flag=true;
						break;
		case 'pending' :
						msg='Are you sure to set the status of selected review to Pending ?';
						flag=true;
						break;
		case 'approved' :
						msg='Are you sure to approve the selected reviews?';
						flag=true;
						break;
		case 'rejected' :
						msg='Are you sure to reject the selected reviews?';
						flag=true;
						break;
		case 'repostaffleadasnaturallead' :
						msg='Please note that only rejected affiliate leads can be reposted as natural leads. Do you want to continue?';
						flag=true;
						break;
		case 'assigncat' :
						var thisForm=document.frmShowPrograms;	
						if(thisForm.strSPAction.value == "assigncat")
						{
							if(!form_isSelected(thisForm.lstCATEGORYPROGRAM_ID)) 
							{
								alert('Please select atleast one category');
								thisForm.lstCATEGORYPROGRAM_ID.focus();
								return false;
							}
						}
						msg='Are you sure to assign category to selected program ?';
						flag=true;
						break;
		case 'assigncattools' :
						var thisForm=document.getElementById(frmPost);
						if(thisForm.strSPAction.value == "assigncattools")
						{
							if(!form_isSelected(thisForm.lstCATEGORYPROGRAM_ID)) 
							{
								alert('Please select atleast one category');
								thisForm.lstCATEGORYPROGRAM_ID.focus();
								return false;
							}
						}
						msg='Are you sure to assign category to selected program ?';
						flag=true;
						break;
		case 'assigndeg' :
						var thisForm=document.frmShowPrograms;	
						if(thisForm.strSPAction.value == "assigndeg")
						{
							if(!form_isSelected(thisForm.lstPROGRAMDEGREELEVEL_ID)) 
							{
								alert('Please select degree level.');
								thisForm.lstPROGRAMDEGREELEVEL_ID.focus();
								return false;
							}
						}
						msg='Are you sure to assign degree level to selected program ?';
						flag=true;
						break;
		case 'changevendor' :
						var thisForm=document.frmShowPrograms;	
						if(thisForm.strSPAction.value == "changevendor")
						{
							if(!form_isSelected(thisForm.lstPROGRAM_SCHOOLVENDOR)) 
							{
								alert('Please select vendor.');
								thisForm.lstPROGRAM_SCHOOLVENDOR.focus();
								return false;
							}
						}
						msg='Are you sure to change vendor to selected program ?';
						flag=true;
						break;
		case 'assigncampus' :
						var thisForm=document.frmShowPrograms;	
						if(thisForm.strSPAction.value == "assigncampus")
						{
							if(!form_isSelected(thisForm.lstPROGRAMCAMPUS_ID)) 
							{
								alert('Please select atleast one campus');
								thisForm.lstPROGRAMCAMPUS_ID.focus();
								return false;
							}
						}
						msg='Are you sure to assign campus to selected program ?';
						flag=true;
						break;
		case 'unassigncampus' :
						var thisForm=document.frmShowPrograms;	
						if(thisForm.strSPAction.value == "unassigncampus")
						{
							if(!form_isSelected(thisForm.lstUNPROGRAMCAMPUS_ID)) 
							{
								alert('Please select atleast one campus');
								thisForm.lstUNPROGRAMCAMPUS_ID.focus();
								return false;
							}
						}
						msg='Are you sure to un-assign campus from selected program ?';
						flag=true;
						break;
		case 'assignfieldgroup' :
						var thisForm=document.frmShowFields;	
						if(thisForm.strSFAction.value == "assignfieldgroup")
						{
							if(!form_isSelected(thisForm.lstFIELDGROUP_ID)) 
							{
								alert('Please select field group.');
								thisForm.lstFIELDGROUP_ID.focus();
								return false;
							}
						}
						msg='Are you sure to assign field group to selected field ?';
						flag=true;
						break;
		default : 		flag=false;
						break;
	}	
	if(flag){ 
			if(eval("confirm('"+msg+"')"))
            { 
								if(division!=null)
								{
									if(selectVal == 'scrublead' || selectVal == 'validatelead')
									{
										Popup.showModal('modal_hold');
										$('hidCOMMON_REASON').value='';
										$('reasonDivision').value=division;
										$('reasonSchoolId').value=schoolId;
										$('reasonSchoolName').value=schoolName;
										$('reasonSelectVal').value=selectVal;
										$('reasonFormName').value=frmPost;
										$('txaCOMMON_REASON').focus();
										$('txaCOMMON_REASON').value='';		
										return false;
									}
									else
									{
										call_ajax_SchoolDetailsActions(division,schoolId,schoolName,checkBox_list,selectVal);
									}
                }
                else
                {
                   //if(window.location.toString().indexOf('schools/list') != -1 && (selectVal=='active' || selectVal=='inactive'))
                   if(window.location.toString().indexOf('/schools/list') != -1 && (window.location.toString().indexOf('/schools/listschoolpage') == -1 && window.location.toString().indexOf('/schools/listcustoschoolpage')== -1 && window.location.toString().indexOf('/schools/listfpiupdate') == -1) && (selectVal=='active' || selectVal=='inactive'))
								   {
									   	Popup.showModal("modal_hold");
										$('hidSCHOOL_COMMON_REASON').value='';
										$('txaCOMMON_REASON').focus();
										$('txaCOMMON_REASON').value='';		
										return false;
								   }
								   else if(window.location.toString().indexOf('/tools/checkStudent') != -1 && (selectVal=='scrublead' || selectVal == 'validatelead'))
								   {
									   	Popup.showModal("modal_hold");
										$('hidCOMMON_REASON').value='';
										$('txaCOMMON_REASON').focus();
										$('txaCOMMON_REASON').value='';		
										return false;
								   }
								   else
								   {
				                    	eval('document.'+frmPost+'.submit()'); 
								   }
                }
            }	
            else 
            { th.value=''; }		
		} else { 
			th.value='';
		}
}
function set_reason(source_id,target_id,source_div_id,form_name)
{
	//if($(source_id).value != '')
	if(!form_isEntered($(source_id)))
	{
		alert('Enter Reason For Selected Action.');
		$(source_id).focus();
		return false;		
	}
	else
	{
		$(target_id).value=$(source_id).value;
		Popup.hide(source_div_id);
		$(source_id).value='';
		eval('document.'+form_name+'.submit()'); 
	}
	
}
/* End of above function */
/*this function is written by sheetal to find from date and to date validation*/
// from date, to date validation function
function fnValidateDate(dtFromDate,dtToDate)
{
    var strFromDate=dtFromDate.replace(/-/g,'/');
   
    var strToDate=dtToDate.replace(/-/g,'/');
     var flagValid=0;   
    if(Date.parse(strFromDate)>Date.parse(strToDate))
         flagValid=1;  
    
        
    if(flagValid==1)
        return (0);
    else
        return (1);
    
}
/* End of above function*/
//###############################################
/*this function is written by sheetal to find from time and to time validation*/
// from time, to time validation function, Time must be seperated by ":".
function fnValidateTime(dtFromTime,dtToTime)
{
    var strFromTime=dtFromTime;
    var strToTime=dtToTime; 
    var arrFromTime=strFromTime.split(':');
    var arrToTime=strToTime.split(':');
    var flagValid=0;
    
    if(arrFromTime[0]<=arrToTime[0] && arrFromTime[1]<=arrToTime[1])
        flagValid=1;
        
    if(flagValid==1)
        return (1);
    else
        return (0);
    
}
/* End of above function*/


//changes the give string with dashes (added this function for making the directoryname by taking the actual school name)
function make_directoryname(str)
{
	if(str != '')
	{
		str=trim(str);
		str=str.replace(/ /g,'-');
		str=str.replace(/'/g,'');
		str=str.replace(/\(/g,'');
		str=str.replace(/\)/g,'');
		str=str.replace(/\.htm/g,'');
		str=str.replace(/\.html/g,'');
		str=str.replace(/\.php/g,'');
		str=str.replace(/\./g,'');
		str=str.replace(/\./g,'');
		str=str.replace(/\,/g,'');
		str=str.replace(/\//g,'-');
		str=str.replace(/\\/g,'-');
		str=str.replace(/&/g,'-');
		str=escape(str).replace(/-%u2013-/g,'-');		
		str=str.replace(/---/g,'-');
		str=str.replace(/--/g,'-');
	}
	return str;
}

//validation functions
function get_elem(id) {
	var elem = 	(document.getElementById) ? document.getElementById(id) :
					((document.all) ? document.all(id) : null);
	return elem;
}

function form_isFile(obj) {
	//obj.value=trim(obj.value);
	if (obj.value.length < 1 ){
		return false;
	}
	else
	{
		return true;	
	}
}

function form_isEntered(obj) {
	//alert(obj.name.indexOf("f"));
	obj.value=trim(obj.value);
	if (obj.value.length < 1 ){
		return false;
	}
	else if(obj.name.indexOf("txtFIRST_NAME")!=-1 || obj.name.indexOf("txtLAST_NAME")!=-1 || obj.name.indexOf("txtCITY")!=-1)
	{
		//code wirtten by sheetal to check for 0 entered for scan alert dated 30 may 08
		var spChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?~_0123456789"; 
		
		for(i=0; i< obj.value.length; i++)
		{
			
            if(spChars.indexOf(obj.value.charAt(i))!=-1)
			{
				//alert("Your string have special characters.");
				return false;
			}
		} 
		if(isNaN(obj.value)===false) return false;	
		if (obj.value.length <= 1 ) return false;	
	}
	
	return true;
}

function form_isEnteredName(obj) {
	if (obj.value.length < 2) return false;
	return true;
}

function form_inNumberRange(obj, minimum, maximum) {
		if (!form_isNumber(obj) || obj.value < minimum || obj.value > maximum) return false;
		return true;
}

/*function form_isNumber(obj) {
		if (isNaN(obj.value)) return false;
		return true;
}*/
function form_isNumber(obj) {
		var numb = '0123456789.';
		for (i=0; i<obj.value.length; i++) {
		if (numb .indexOf(obj.value.charAt(i),0) == -1) return false;
		}
		return true;
}

function form_isAlphabetdash(obj) {
		var numb = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-';
		for (i=0; i<obj.value.length; i++) {
		if (numb .indexOf(obj.value.charAt(i),0) == -1) return false;
		}
		return true;
}

function form_isSelected(obj) {
	for (var i = 0; i < obj.length; i++) {
		if (obj.options[i].value != '' && obj.options[i].selected) return true;
	}
	return false;
}

function form_selected(obj) {
	for (var i = 0; i < obj.length; i++) {
		if (obj.options[i].value != '' && obj.options[i].selected) return obj.options[i].value;
	}
	return false;
}

function form_isZip(obj) {
	obj.value=trim(obj.value);
	zip = obj.value;
	if (zip.length != 5) return false;
	var validChars = "0123456789";
	for (i=0; i<5; i++)
	{  
		var currentChar = zip.charAt(i)
		if (validChars.indexOf(currentChar) < 0) {
			return false;
		}
	}
	return true;
}
function form_isCAZip(obj) {
	zip = obj.value;
	if (zip.length != 6) return false;
	var validChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	for (i=0; i<5; i++)
	{  
		var currentChar = zip.charAt(i)
		if (validChars.indexOf(currentChar) < 0) {
			return false;
		}
	}
	return true;
}
function form_isPostal(obj) {
	obj.value=trim(obj.value);
	postal = obj.value;
	pval = /^[a-cehj-npr-tvxy]\d[a-z](\s)?\d[a-z]\d$/i;
	if (pval.test(postal)) { return true; }
	return false;
}
/*Old Email Validation function,
this function is now commented, because after entering certain number of characters the script was getting terminated abruptly causing the page execution to be stopped amidst.
*/
/*function form_isEmail(obj) {	
	//address = RTrim(obj.value);
	obj.value=trim(obj.value); 
    address=trim(obj.value);
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(address)) {
		return true;
	}
	return false;
}*/
/*Old Email Validation function, ends here.*/
/*New Email Address Validation function;
Function added by Aashish & Ashutosh on 07 October2009
*/
//commented by Ashutosh on 06 Jan 10
//because this function is not validating the address text@testcom (check the dot (.) is not present.
/*function form_isEmail(obj) {	
	obj.value=trim(obj.value); 
    address=trim(obj.value).toString();
 var splitted = address.match("^(.+)@(.+)$");
 alert(splitted);
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
   var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
	alert(splitted[2]);
    if(splitted[2] != null)
    {
      var regexp_domain=/^([0-9a-zA-Z]+[0-9,a-z,A-Z,.,-](*).{1}[a-zA-Z]{2,4})+$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
     var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
     if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}*/
//added new function on 06 Jan 10 by Ashutosh
function form_isEmail(obj) 
{	
	obj.value=trim(obj.value); 
    address=trim(obj.value);
	if(/^([^@\s]+)@((?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6})$/.test(address)) 
	{
		return true;
	}
	return false;
}
/*New Email Address Validation function*/
function form_formatPhone(obj, message) {
	message = message == void '' ? '' : message;
	phone = obj.value;
	if (phone.length == 0) return true;
	var phoneNew = '';
	validChars = "0123456789";
	for (i = 0; i < phone.length; i++) {
		currentChar = phone.charAt(i);
		if (validChars.indexOf(currentChar) >= 0) {
			phoneNew = phoneNew + currentChar;
		}
	}

	if (phoneNew.length !== 10) {
		if (message.length) {alert(message); }
		return false;
	} else {
		if(phoneNew.substr(0,3)%100==0){ //To avoid 100, 200 etc. combinations
		return false;
		} 
		if (!form_isPhone_validate_3(phoneNew.substr(0,3)) || !form_isPhone_validate_3_3(phoneNew.substr(3,3))) {
			if (message.length) {				
				alert(message);
			}
			return false;
		}
		if (!form_isPhone_validate_3_4(phoneNew.substr(3,3),phoneNew.substr(6,4))) {
			if (message.length) {				
				alert(message);
			}
			return false;
		}
		if(obj.id == 'txtPHONE_NUMERIC' || obj.id == 'txtEVENING_PHONE_NUMERIC' || obj.id == 'phone_numeric' || obj.id == 'Secondary_Phone_Numeric' || obj.id == 'work_phone_numeric' || obj.id == 'other_phone_numeric')
		{
			obj.value = phoneNew.substr(0,3)+phoneNew.substr(3,3)+phoneNew.substr(6,4);
		}
		else
		{
			obj.value = phoneNew.substr(0,3)+'-'+phoneNew.substr(3,3)+'-'+phoneNew.substr(6,4);
		}
		return true;
	}
}

function form_isOtherPhone(obj) {
phone = obj.value;
if (phone.length == 0) return false;
if(!form_isNumber(obj)) return false;
return true;
}

function form_isNumericRange(obj, rmin, rmax) {
	if (isNaN(obj.value) || obj.value < rmin || obj.value > rmax) return false;
	return true;
}

function form_isPhone(obj) {
	if (obj.value.length == 0) return false;
	if (!form_formatPhone(obj)) {
		return false;
	} else {
		return true;
	}
}

function form_isPhone_validate_3 (phone3) {
	isValid = true;
	if(phone3.length != 3) {
		isValid = false;
	} else if(!numeric(phone3)) {
		isValid = false;
	} else if(phone3 == "111") {
		isValid = false;
	} else if(phone3 == "123") {
		isValid = false;
	} else if(phone3 == "222") {
		isValid = false;
	} else if(phone3 == "333") {
		isValid = false;
	} else if(phone3 == "444") {
		isValid = false;
	} else if(phone3 == "555") {
		isValid = false;
	} else if(phone3 == "666") {
		isValid = false;
	} else if(phone3 == "777") {
		isValid = false;
	} else if(phone3 == "999") {
		isValid = false;
	} else if(phone3 == "911") {
		isValid = false;
	} else if(phone3 == "000") {
		isValid = false;
	} else if(phone3 == "098") {
		isValid = false;
	}
	return isValid;
}
// FOLLOWING FUNCTION IS COPY OF ABOVE FUNCTION CREATED by sandip DATED 6TH JAN 07 
// EARLIER IT WAS USING SAME ABOVE FUNCTION TO CHECK FOR BOTH AREA CODE AND PREFIXES.. 
// BELOW FUNCTION IS WRITTEN TO CHECK FOR PREFIXES SEPERATELY...

function form_isPhone_validate_3_3(phone3) {
	isValid = true;
	if(phone3.length != 3) {
		isValid = false;
	} else if(!numeric(phone3)) {
		isValid = false;
	} else if(phone3 == "111") {
		isValid = false;
	} else if(phone3 == "123") {
		isValid = false;
/*
FOLLOWING PREFIXES ARE COMMENTED BY SANDIP DATED 6TH JAN 07 AS PRFIXES ARE EXTENDED AS PER MAIL BY GENE ON 6TH JAN 07
UPDATED PREFIXES CAN BE FOUND AT : http://www.awesomenet.net/accessnumbers/

	} else if(phone3 == "222") {
		isValid = false;
	} else if(phone3 == "333") {
		isValid = false;
	} else if(phone3 == "444") {
		isValid = false;
*/
	} else if(phone3 == "555") {
		isValid = false;
/*
FOLLOWING PREFIXES ARE COMMENTED BY SANDIP DATED 6TH JAN 07 AS PRFIXES ARE EXTENDED AS PER MAIL BY GENE ON 6TH JAN 07
UPDATED PREFIXES CAN BE FOUND AT : http://www.awesomenet.net/accessnumbers/
		
	} else if(phone3 == "666") {
		isValid = false;
	} else if(phone3 == "777") {
		isValid = false;
	} else if(phone3 == "999") {
		isValid = false;
*/
	} else if(phone3 == "911") {
		isValid = false;
	} else if(phone3 == "000") {
		isValid = false;
	}
	return isValid;
}
//following code checks the combination validation of prefix and phone number
//Added by Ashutosh on 29 June 09
function form_isPhone_validate_3_4(phone2,phone3) {
	isValid = true;
	phone=phone2+'-'+phone3;
	if(phone.length != 8) {
		isValid = false;
	} else if(phone == "123-4567") {
		isValid = false;
	} else if(phone == "456-7890") {
		isValid = false;
	} else if(phone == "000-0000") {
		isValid = false;
	} else if(phone == "111-1111") {
		isValid = false;
	} else if(phone == "222-2222") {
		isValid = false;
	} else if(phone == "333-3333") {
		isValid = false;
	} else if(phone == "444-4444") {
		isValid = false;
	} else if(phone == "555-5555") {
		isValid = false;
	} else if(phone == "666-6666") {
		isValid = false;
	} else if(phone == "777-7777") {
		isValid = false;
	} else if(phone == "888-8888") {
		isValid = false;
	} else if(phone == "999-9999") {
		isValid = false;
	}
	return isValid;
}
function numeric(val)
{
	temp = true;
	for (i=0;i<val.length;i++)
	{
		if(!(val.charAt(i)>='0' && val.charAt(i)<='9'))
		{
			temp = false;
		}
	}
	return temp;
}

function float(val)
{
	temp = true;
	for (i=0;i<val.length;i++)
	{
		if(!((val.charAt(i)>='0' && val.charAt(i)<='9') || (val.charAt(i) == '.')))
		{
			temp = false;
		}
	}
	return temp;
}

function dvhide(obj) {
  if (document.getElementById)
    {document.getElementById(obj).style.display = "none";}
  else
    {if (document.layers)
      {document.layers[obj].visibility = "hide";}
     else
      {document.all(obj).style.visibility = "hidden";}
    }
}
function dvshow(obj) {
  if (document.getElementById)
    {document.getElementById(obj).style.display = "block";}
  else
    {if (document.layers)
      {document.layers[obj].visibility = "show";}
     else
      {document.all(obj).style.visibility = "visible";}
    }
}

//ADDED BY KIRAN ON 28 JUNE 2006
function form_checked(obj)
{
	var tot_checkboxes;
	tot_checkboxes=obj.length;
		flagChk=0;
		for (i=0;i<tot_checkboxes;i++)
		{
			if(obj[i].checked)
			{
				flagChk=1;
				break;
			}
		}
		return flagChk;
}

//ADDED BY KIRAN ON 6 JULY 2006
function form_single_checked(obj)
{
	
	if(!obj.checked)
			return false;
	else
		    return true;
}
//ADDED BY Aashish on 25 OCT 2008
function form_isRadio_checked(obj) {
    var cnt = -1;
    for (var i=obj.length-1; i > -1; i--) 
	{
        if (obj[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return obj[cnt].value;
    else return null;
}

// new phone validations for aakers form
// almost same as that of above but only minor change..
function form_formatPhone1(obj, message) {
	message = message == void '' ? '' : message;
	phone = obj.value;
	if (phone.length == 0) return true;
	var phoneNew = '';
	validChars = "0123456789";
	for (i = 0; i < phone.length; i++) {
		currentChar = phone.charAt(i);
		if (validChars.indexOf(currentChar) >= 0) {
			phoneNew = phoneNew + currentChar;
		}
	}
	
	if (phoneNew.length !== 10) {
		if (message.length) { alert(message); }
		return false;
	} else {
		if(phoneNew.substr(0,3)%100==0){ //To avoid 100, 200 etc. combinations
		return false;
		} 
		if (!form_isPhone_validate_3(phoneNew.substr(0,3)) || !form_isPhone_validate_3_3(phoneNew.substr(3,3))) {
			if (message.length) {
				alert(message);
			}
			return false;
		}
		obj.value = phoneNew.substr(0,3)+phoneNew.substr(3,3)+phoneNew.substr(6,4); // formatting of "-" is removed 
		return true;
	}
}

function form_isPhone1(obj) {
	if (obj.value.length == 0) return false;
	if (!form_formatPhone1(obj)) {
		return false;
	} else {
		return true;
	}
}


////////////////////new phone format for eg. XXX-XXXXXX


function form_formatPhone2(obj, message) {
	message = message == void '' ? '' : message;
	phone = obj;
	if (phone.length == 0) return true;
	var phoneNew = '';
	validChars = "0123456789";
	for (i = 0; i < phone.length; i++) {
		currentChar = phone.charAt(i);
		if (validChars.indexOf(currentChar) >= 0) {
			phoneNew = phoneNew + currentChar;
		}
	}
	
	if (phoneNew.length !== 10) {
		if (message.length) { alert(message); }
		return false;
	} else {
		if(phoneNew.substr(0,3)%100==0){ //To avoid 100, 200 etc. combinations
		return false;
		} 
		if (!form_isPhone_validate_3(phoneNew.substr(0,3)) || !form_isPhone_validate_3_3(phoneNew.substr(3,3))) {
			if (message.length) {
				alert(message);
			}
			return false;
		}
		obj.value = phoneNew.substr(0,3)+'-'+phoneNew.substr(3,3)+phoneNew.substr(6,4); // formatting of "-" is placed only first time
		return true;
	}
}

function form_isPhone2(obj) {
	alert(obj.length);
	if (obj.length == 0) return false;
	if (!form_formatPhone2(obj)) {
		return false;
	} else {
		return true;
	}
}


// Added by Swati on 26-Feb
function form_isDate_US(field){
	
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = ".";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) 
	  {
		 DateTemp = DateTemp + DateValue.substr(i,1);
		 
	  }
	 
   }
   if (DateValue.substr(2,1) != "/" || DateValue.substr(5,1)!= "/")
  	   return false;

   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   
    if (DateValue.length == 0) {
		   return false;}
  
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   day = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   month = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   
   if (err == 0) {
     return true;
   }
   else {
     return false;
   }
}
// ends here

function form_isDate(field){
	
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = ".";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) 
	  {
		 DateTemp = DateTemp + DateValue.substr(i,1);
		 
	  }
	 
   }
   if (DateValue.substr(2,1) != "/" || DateValue.substr(5,1)!= "/")
  	   return false;

   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   
    if (DateValue.length == 0) {
		   return false;}
  
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   
   if (err == 0) {
     return true;
   }
   else {
     return false;
   }
}



// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

//removes extra spaces from begining, trailing spaces.
function trim(s) {
	s = s.replace(/(^\s*)|(\s*$)/gi,"");
	s = s.replace(/[ ]{2,}/gi," ");
	s = s.replace(/\n /,"\n");
	return s;
}

//this function is used to validate the extra editor functions added at add/edit category and add/edit cms pages.
function validate_extra_school_controls()
{
	var format_list = document.getElementById('lstEDITOR_FORMAT_LIST');
	var school_list = document.getElementById('lstEDITOR_SCHOOL_LIST');
	var returnStr;
	if(format_list.value == '')
	{
		alert('Please select the format.');
		format_list.focus();
		return false;
	}
	if((format_list.value == 'school_category_data_' || format_list.value == 'school_name_with_contact_link_') && (school_list && school_list.value == ''))
	{
		school_list.focus();
		alert('Please select the school.');
		return false;
	}
	if(format_list.value == 'school_category_data_' || format_list.value == 'school_name_with_contact_link_')
	{
		returnStr='{'+format_list.value+school_list.value+'}';
	}
	else
	{
		returnStr='{'+format_list.value+'}';	
	}
	tinyMCE.execCommand('mceInsertContent',false,returnStr);
	return true;
}

//added by Ashutosh on 22 July 09 to place current time at stats section of home page of admin panel.
function getCurrentDateTime()
{
	var time = new Date();
	var date = time.getDate();
	var month = time.getMonth()+1;

	switch(month)
	{
		case 1: month = 'Jan';
				break;
		case 2: month = 'Feb';
				break;
		case 3: month = 'Mar';
				break;
		case 4: month = 'Apr';
				break;
		case 5: month = 'May';
				break;
		case 6: month = 'Jun';
				break;
		case 7: month = 'Jul';
				break;
		case 8: month = 'Aug';
				break;
		case 9: month = 'Sep';
				break;
		case 10: month = 'Oct';
				break;
		case 11: month = 'Nov';
				break;
		case 12: month = 'Dec';
				break;
	}
	var year = time.getFullYear()
	year=String(year).substring(2,4);
	var hour = time.getHours()
	var minute = time.getMinutes()
	var second = time.getSeconds()
	var fullDate = month +" "+ date +" "+ year;
	var temp = " " + ((hour > 12) ? hour - 12 : hour)
	if(hour==0) temp = "12"
	if(temp.length==1) temp = " " + temp
	temp += ((minute < 10) ? ":0" : ":") + minute
	//temp += ((second < 10) ? ":0" : ":") + second
	temp += (hour >= 12) ? " PM" : " AM"
	return (fullDate+temp);
}
//check the URL
//Added by Ashutosh on 19 Nov 09
function CheckValidUrl(strUrl)
{
	var RegexUrl = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	return RegexUrl.test(strUrl);
}

//check the Email
//Added by dev5 on 26 April 10
function CheckValidEmail(strEmail)
{
    address=trim(strEmail);
	if(/^([^@\s]+)@((?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6})$/.test(address)) 
	{
		return true;
	}
	return false;
}

//Added by dev5 to IP validation
function form_isIP(obj) 
{	
	obj.value=trim(obj.value); 
    address=trim(obj.value);
	if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(address)) 
	{
		return true;
	}
	return false;
}

//used to validate the entered zip in campus degree pages.
function validateCampusDegreeSearch()
{
	var thisForm=document.frmCampusDegreeSearch;
	
	if(thisForm.txtDegreeZip.value != '')
	{
		if (!form_isZip(thisForm.txtDegreeZip) && !form_isPostal(thisForm.txtDegreeZip)) 
		{
			alert("Entered zip code must be of US or Canada.");
			thisForm.txtDegreeZip.focus();
			return false;
		}
	}
	return true;
}

//gets the browser info
function getBrowserInfo()
{
	var str = '';
	if(typeof(navigator) !== 'undefined') 
	{
		str = 'Browser CodeName: ' + navigator.appCodeName + '\r\n';
		str += 'Browser Name: ' + navigator.appName + '\r\n';
		str += 'Browser Version: ' + navigator.appVersion + '\r\n';
		str += 'Cookies Enabled: ' + navigator.cookieEnabled + '\r\n';
		str += 'Platform: ' + navigator.platform + '\r\n';
		str += 'User-agent header: ' + navigator.userAgent + '\r\n';
	}
	return str;
}
function validateNewDesignFindYourSchoolSection()
{
	var thisForm = document.frmNewDesignFindYourSchoolSection;
	if(thisForm.lstSchoolType && thisForm.lstSchoolType.value == '')
	{
		alert('Please select a school type.');
		thisForm.lstSchoolType.focus();
		return false;
	}

	if(thisForm.lstCategory && thisForm.lstCategory.value == '')
	{
		alert('Please select a program type.');
		thisForm.lstCategory.focus();
		return false;
	}
	return true;
}

function createNewDesignShowHideJavascriptForCMSPages(functionName,arrTabId,arrDescId)
{
	var str = '';

	if(functionName == '')
	{
		alert('Function name is not specified please specify it.');
		return str;
	}

	var tabCount = arrTabId.length;
	var descCount = arrDescId.length;

	if(tabCount <= 0 || descCount <= 0)
	{
		alert('Either tab or description array is empty');
		return str;
	}

	if(tabCount != descCount)
	{
		alert("The tab count and display container count does not match. Please correct it.")
		return str;
	}

	var str = 'function '+functionName+'(descId,tabId)\
	{\
		jQuery(document).ready(function(){';
		for(i = 0; i < arrTabId.length; i++)
		{
			str += 'var newDescId = "#'+arrDescId[i]+'";';
			str += 'var newTabId = "#'+arrTabId[i]+'";';
			str += 'var actualDescId = "#"+descId;';
			str += 'var actualTabId = "#"+tabId;';

			str += 'if(actualDescId != newDescId)\
			{\
				if(jQuery(newDescId) && jQuery(newDescId).css("display") == "block")\
				{\
					jQuery(newDescId).slideUp("slow");\
					if(jQuery(newTabId) && jQuery(newTabId).attr("class") == "first-tab-active")\
					{\
						jQuery(newTabId).removeClass("first-tab-active").addClass("first-tab");\
					}\
					if(jQuery(newTabId) && jQuery(newTabId).attr("class") == "last-tab-active")\
					{\
						jQuery(newTabId).removeClass("last-tab-active").addClass("last-tab");\
					}\
					if(jQuery(newTabId) && jQuery(newTabId).attr("class") == "middle-tab-active")\
					{\
						jQuery(newTabId).removeClass("middle-tab-active").addClass("middle-tab");\
					}\
				}\
			}';
			str += 'else';
			str += '{\
				jQuery(actualDescId).slideDown("slow");\
				if(jQuery(actualTabId) && jQuery(actualTabId).attr("class") == "first-tab")\
				{\
					jQuery(actualTabId).removeClass("first-tab").addClass("first-tab-active");\
				}\
				if(jQuery(actualTabId) && jQuery(actualTabId).attr("class") == "last-tab")\
				{\
					jQuery(actualTabId).removeClass("last-tab").addClass("last-tab-active");\
				}\
				if(jQuery(actualTabId) && jQuery(actualTabId).attr("class") == "middle-tab")\
				{\
					jQuery(actualTabId).removeClass("middle-tab").addClass("middle-tab-active");\
				}';
			str += '}';
		}
		str += '});\
	}';

	return str;
}

function executeFieldEventsDyanically(elmField)
{
	if(elmField)
	{
		var fireOnThis = elmField;
		//for rest of IE browsers
		if( document.createEvent )
		{
			//onchange event
			var evObj = document.createEvent('Events');
			evObj.initEvent('change', true, true );
			fireOnThis.dispatchEvent(evObj);
			
			//onclick event 
			var evObj = document.createEvent('Events');
			evObj.initEvent('click', true, true );
			fireOnThis.dispatchEvent(evObj);
			
			//onfocus event
			var evObj = document.createEvent('Events');
			evObj.initEvent('focus', true, true );
			fireOnThis.dispatchEvent(evObj);
			
			//onblur event
			var evObj = document.createEvent('Events');
			evObj.initEvent('blur', true, true );
			fireOnThis.dispatchEvent(evObj);
		}
		//for IE
		else if( document.createEventObject ) 
		{
			//onchange event
			fireOnThis.fireEvent('onchange');
			
			//onclick event
			fireOnThis.fireEvent('onclick');
			
			//onfocus event
			fireOnThis.fireEvent('onfocus');
			
			//onblur event
			fireOnThis.fireEvent('onblur');
		}
	}
}
