<!--
/*
  JAVASCRIPT COMMON VALIDATIONS
*/
//Objects for Various Validations
var objUsername 			= ".0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
var objNumber   			= ".0123456789";
var objSpecialNumber  		= "-+ ,.0123456789%";
var objCurrency   			= ".0123456789";
var objWholeNumber  		= "0123456789";
var objPassword		  		= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-0123456789";//+_#$&*!@=?/><^~|\][{}.
var objTelephone    		= "-()0123456789,+";
var objNumber   			= ".0123456789";
var objFax		    		= "-()0123456789,+";
var objName     			= " ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'-";
var objEmail    			= ".@0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-";
var objAlpha 				= "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz -";
var objAlphaNumeric 		= "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0123456789,- :.+ ";
var objPageName				= "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0123456789- :.+% ";
var objTitle		 		= "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz.";
var objFileName				= "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-0123456789/?=";

var objCode					= "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-0123456789";
var objSpecialChar 			= "@&$#()=/!*ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0123456789,'- :.+%/ ";
var objZipCode 				= "0123456789";
var objAlphaNumericOnly		= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var objOnlyAlpha 			= "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz ";
var objFoldername			= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
var objUrl					= "/:.-\ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
var objAll					=	'';
var objSpecialUserChar 		= "-[]'ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0123456789 ";

/* Max Lengths for Various Values */
var nameMaxLength			= 	50;
var largeNameMaxLength		=	80;
var usernameMaxLength		= 	50; 
var pwdMaxLength			= 	25;
var phoneMaxLength			=	40;  
var faxMaxLength			=	40;  
var codeMaxLength			=	25;
var textareaMaxLength		=	255;
var ZipCodeMaxLength		=	7;
var EmailMaxLength			=	80;
var mediumtextMaxLength		=	500;
var SectionMaxLength	=	250;
var objPageTitle		= "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz:. ";
	
//comparing date...
var month=new Array(12)									
month["Jan"]=0									
month["Feb"]=1									
month["Mar"]=2									
month["Apr"]=3									
month["May"]=4				
month["Jun"]=5					
month["Jul"]=6					
month["Aug"]=7				
month["Sept"]=8					
month["Oct"]=8					
month["Nov"]=10				
month["Dec"]=11	

var currentTime = new Date()

/****************************************************************************/	
function isRule(oComp, sRule, nLength, fdecimal, minLength,fieldName,maxLength)
{
    //alert(sRule)
	if(fdecimal == "" || typeof(fdecimal) == "undefined")
	{
		fdecimal = false;
	}

	//If the object is not specified return false
	if (typeof(oComp) == 'undefined' || oComp == null || oComp == '')
	{
		alert(g_js_error_obj_not_defined);
		return false;
	}
	//If neither rule nor max length is specified, return false
	else if (typeof(sRule) == 'undefined' && typeof(nLength) == 'undefined')
	{
		alert(g_js_error_max_input);
		return false;
	}

	var noErrorFlg = true;
	
	if(sRule != objAll)
	{
		//If object is specified and either of rule is specified,
		if(typeof(sRule) != 'undefined' && sRule != null)
		{
			var temp;
			sRule = sRule + "";
			var discardChars = false;
			if(sRule.length > 0 && sRule.charAt(0) == "~")
			{
				sRule = sRule.substring(1);
				discardChars = true;
			}
	
			if(typeof(oComp) == "undefined" || typeof(sRule) == "undefined")
				return false;
	
			for (var i = 0;i < oComp.value.length;i++)
			{
				temp = oComp.value.charAt(i);
				
				if((!discardChars && sRule.indexOf(temp) == -1) || (discardChars && sRule.indexOf(temp) >= 0))
				{
					
					oComp.value = oComp.value.substring(0,i);// + (oComp.value.length > i ? oComp.value.substring(i+1):"");
					alert(g_js_invalid_charac);
					
					noErrorFlg = false;
					break;
				}
			}
			
		}
	}
	if(nLength)
	{
	
		if(fdecimal)
		{
			nLength -= fdecimal;
			var dp = oComp.value.indexOf(".");
			var p1;
			var p2 = "";;
			if(dp >= 0)
			{
				p1 = oComp.value.substring(0,dp);
				p2 = oComp.value.substring(dp+1);
			}
			else
			{
				p1 = oComp.value;
			}
			if(p1.length > nLength)
			{
				oComp.value = oComp.value.substring(0,nLength);
				return noErrorFlg;
			}
			for(var i = 0;i < p2.length;i++)
			{
				var ch = p2.charAt(i);
				if(ch < '0' || ch > '9')
				{
					oComp.value = p1 + "." + p2.substring(0,i);
					return noErrorFlg;
				}
			}
			if(p2.length > fdecimal)
			{
				oComp.value = p1 + "." + p2.substring(0,fdecimal);
			}
		}
		else if(oComp.value.length > nLength)
		{
			oComp.value = oComp.value.substring(0,nLength);
			//oComp.focus();
			//noErrorFlg = false;
		}
		else if(minLength && oComp.value.length < minLength)
		{
			alert(g_please_enter_atleast + minLength + g_charac);
			oComp.focus();
			noErrorFlg = false;
		}
		else if(maxLength && oComp.value.length > maxLength)
		{
			alert(g_please_enter_less + maxLength + g_charac);
			oComp.focus();
			noErrorFlg = false;
		}
	}
	return noErrorFlg;
}
/****************************************************************************/
//Clear Text Value
function clearValue(txtobj1,txtobj2)
{
	if(txtobj1)
	{
		txtobj1.value="";
	}
	if(txtobj2)
	{
		txtobj2.value="";
	}
}
/****************************************************************************/
//Email Validation
function isEmail(newstr)
{
	var emailexp = /^[a-z][a-z_0-9\-\.]+@[a-z_0-9\-\.]+\.[a-z]{2,5}$/i
	//Check that the email entry is valid
	if (!emailexp.test(newstr) || newstr.indexOf("..") >= 0)
	{
		return false;
	}
	return true;
}
/****************************************************************************/
function set_initial_focus(form_object)
{
	
	if(form_object )
	{
		form_object.focus();
	}

}
/****************************************************************************/
function clearValue(elementobj)
{
	if(elementobj && elementobj.value!="" )
		elementobj.value="";
}
/****************************************************************************/

function PopupPage(pageUrl, pageWidth, pageHeight,windowName,is_scroll)
{
	//Code to display in the center goes here
	var left = (screen.width - pageWidth)/2;
	var top = (screen.height - pageHeight)/2;
	if (isNaN(left))
		left = 0;
	if (isNaN(top))
		top = 0;
	if (null == windowName )
		windowName = "_blank";
	if(null == is_scroll)
		is_scroll = "no";
	var newPopup = window.open(pageUrl, windowName , "dependent=yes, directories=no, location=no, menubar=no, personalbar=no, resizable=no, scrollbars="+is_scroll+", status=no, toolbar=no, height=" + pageHeight + ", width=" + pageWidth + ", left=" + left + ", top=" + top + ", dialog=yes");
	return newPopup;
}
/****************************************************************************/
function CheckAllCheckBoxes(obj_form) 
{	    	    	    
	for(i = 0; i < obj_form.length; i++) 
    {
         elm = obj_form.elements[i]
		 if (elm.type == 'checkbox') 
         {   
				if (document.getElementById('chkAllItems').checked== true)
				{       	//if(elm.checked == false)          
					elm.checked = true					
				}
				else
				{
					elm.checked = false					
				}
       }
   }
}
/****************************************************************************/
function CheckAtleastOneSelected(obj_form)
{
	var confirm_msg;
	var selectCount = 0;
	for(i = 0; i < obj_form.length; i++) 
    {
         elm = obj_form.elements[i]
		 if (elm.type == 'checkbox') 
         {   
		 	if(elm.checked == true) 
			{       
				selectCount++;
			}
		 }
	}
	
	if(selectCount <= 0)
	{
		alert(g_js_select_atleast_one_msg);
		return false;
	}
	return true;
}
function MM_findObj(n, d) { //v4.01
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 && d.getElementById) x=d.getElementById(n); return x;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function ValidateOperation(obj_form)
{
	var confirm_msg;
	var selectCount = 0;
	for(i = 0; i < obj_form.length; i++) 
    {
         elm = obj_form.elements[i]
		 if (elm.type == 'checkbox') 
         {   
		 	if(elm.checked == true) 
			{       
				selectCount++;
			}
		 }
	}
	if(selectCount <= 0)
	{
		alert(g_js_select_atleast_one_msg);
		return false;
	}	 
	
	list_op = obj_form.list_operation.value;
	if(list_op == "")
	{
		alert(g_js_select_operation_msg);
		return false;
	}
	switch(list_op)
	{
		case "D":
					confirm_msg			= g_js_multiple_delete_msg;
					obj_form.mode.value	= "multi_delete";
					break;
		case "A":
					confirm_msg 		= g_js_multiple_activate_msg;
					obj_form.new_status.value		= g_active_status;
					obj_form.mode.value	= "multi_status";
					break;
		case "I":
					confirm_msg 		= g_js_multiple_inactivate_msg;					
					obj_form.new_status.value		= g_inactive_status;
					obj_form.mode.value	= "multi_status";
					break;
					
					
	}
	if(confirm(confirm_msg))
		{
			obj_form.action	= g_list_operation_action_file;
			//obj_form.submit();
			return true;
		}
	return false;
}
function OpenFullWindow(pageUrl)
{
	var newPopup = window.open(pageUrl,'', "dependent=no, directories=yes, location=yes, menubar=yes, personalbar=yes, resizable=yes, scrollbars=yes, status=yes, toolbar=yes, height=600, width=600, left=0, top=0, dialog=no");

}
function SubmitLanguagePage(frmObj)
{
		if(frmObj.glb_language_id.value != -1)
			{
				frmObj.submit();
			}
}
/****************************************************************************/	
function isRuleDisAllow(oComp, sRule, nLength, fdecimal, minLength,fieldName,maxLength)
{
    //alert(sRule)
	if(fdecimal == "" || typeof(fdecimal) == "undefined")
	{
		fdecimal = false;
	}

	//If the object is not specified return false
	if (typeof(oComp) == 'undefined' || oComp == null || oComp == '')
	{
		alert(g_js_error_obj_not_defined);
		return false;
	}
	//If neither rule nor max length is specified, return false
	else if (typeof(sRule) == 'undefined' && typeof(nLength) == 'undefined')
	{
		alert(g_js_error_max_input);
		return false;
	}

	var noErrorFlg = true;
	
	if(sRule != objAll)
	{
		//If object is specified and either of rule is specified,
		if(typeof(sRule) != 'undefined' && sRule != null)
		{
			var temp;
			sRule = sRule + "";
			var discardChars = false;
			if(sRule.length > 0 && sRule.charAt(0) == "~")
			{
				sRule = sRule.substring(1);
				discardChars = true;
			}
	
			if(typeof(oComp) == "undefined" || typeof(sRule) == "undefined")
				return false;
	
			for (var i = 0;i < oComp.value.length;i++)
			{
				temp = oComp.value.charAt(i);
	
				if((!discardChars && sRule.indexOf(temp) >= 0) || (discardChars && sRule.indexOf(temp) >= 0))
				{
					alert(g_js_invalid_charac);
					oComp.value = oComp.value.substring(0,i);// + (oComp.value.length > i ? oComp.value.substring(i+1):"");
					noErrorFlg = false;
					break;
				}
			}
		}
	}
	if(nLength)
	{
	
		if(fdecimal)
		{
			nLength -= fdecimal;
			var dp = oComp.value.indexOf(".");
			var p1;
			var p2 = "";;
			if(dp >= 0)
			{
				p1 = oComp.value.substring(0,dp);
				p2 = oComp.value.substring(dp+1);
			}
			else
			{
				p1 = oComp.value;
			}
			if(p1.length > nLength)
			{
				oComp.value = oComp.value.substring(0,nLength);
				return noErrorFlg;
			}
			for(var i = 0;i < p2.length;i++)
			{
				var ch = p2.charAt(i);
				if(ch < '0' || ch > '9')
				{
					oComp.value = p1 + "." + p2.substring(0,i);
					return noErrorFlg;
				}
			}
			if(p2.length > fdecimal)
			{
				oComp.value = p1 + "." + p2.substring(0,fdecimal);
			}
		}
		else if(oComp.value.length > nLength)
		{
			oComp.value = oComp.value.substring(0,nLength);
			//oComp.focus();
			//noErrorFlg = false;
		}
		else if(minLength && oComp.value.length < minLength)
		{
			alert(g_please_enter_atleast + minLength + g_charac);
			oComp.focus();
			noErrorFlg = false;
		}
		else if(maxLength && oComp.value.length > maxLength)
		{
			alert(g_please_enter_less + maxLength + g_charac);
			oComp.focus();
			noErrorFlg = false;
		}
	}
	return noErrorFlg;
}


function ValidateDownloadForm(form_obj){
	var teststring;
	teststring=/\S/;
	
	/*if(form_obj.name && !teststring.test(form_obj.name.value))
	{
		
		alert(g_js_name_msg);
		form_obj.name.focus();
		return false;
	}*/
	if(form_obj.email && !teststring.test(form_obj.email.value))
	{
		
		alert(g_js_email_msg);
		form_obj.email.focus();
		return false;
	}

	if(form_obj.email && teststring.test(form_obj.email.value) && !isEmail(form_obj.email.value))
	{
		
		alert(g_js_valid_email_msg);
		form_obj.email.focus();
		return false;
	}
	
	if(form_obj.country && !teststring.test(form_obj.country.value))
	{
		
		alert(g_js_country_msg);
		form_obj.country.focus();
		return false;
	}
	return true;

}
function ValidateContactForm(form_obj){
	var teststring;
	teststring=/\S/;
	
	if(form_obj.name && !teststring.test(form_obj.name.value))
	{
		alert(g_js_name_msg);
		form_obj.name.focus();
		return false;
	}
	if(form_obj.email && !teststring.test(form_obj.email.value))
	{
		
		alert(g_js_email_msg);
		form_obj.email.focus();
		return false;
	}

	if(form_obj.email && teststring.test(form_obj.email.value) && !isEmail(form_obj.email.value))
	{
		
		alert(g_js_valid_email_msg);
		form_obj.email.focus();
		return false;
	}
	/*if(form_obj.captcha && !teststring.test(form_obj.captcha.value))
	{
		
		alert(g_js_captcha_msg);
		form_obj.captcha.focus();
		return false;
	}*/
	
	
	return true;

}
-->
