// JavaScript Document
function showHide(id,val){
 document.getElementById(id).style.display=val;
}

function chageTitle(id,val){
	if(val == 'asc'){
		document.getElementById(id).title='desc';	 
	}
	else{
		document.getElementById(id).title='asc';
	}	
}

function trasfrVal(senderID,receiverID){
 document.getElementById(receiverID).value= document.getElementById(senderID).value;		
}

function disableArea(id){
	 document.getElementById(id).readonly = true;
}

function enableArea(id){
	 document.getElementById(id).readonly = false;
}

function val(id){
	return trimAll(document.getElementById(id).value);
}

function setVal(id,val){
 document.getElementById(id).value=trimAll(val);
}

function doc(id){
 return document.getElementById(id);
}

function trimAll(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function empty(id)
{
	if(trimAll(document.getElementById(id).value)=='')
	{
		return true;	
	}
	else
	{
		return false;
	}
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; vall=document.getElementById(args[i]);
      if (val) { nm=vall.name; if ((vall=vall.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=vall.indexOf('@');
          if (p<1 || p==(vall.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(vall);
          if (isNaN(vall)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } 
	if (errors) {
			doc(args[0]).className = 'invalid';
			doc(args[0]).focus();
		}else{
			doc(args[0]).className = 'inputBox';	
		}
    document.MM_returnValue = (errors == '');
} }

function isValidURL(url){ 
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/; 
    if(RegExp.test(url)){ 
        return true; 
    }else{ 
        return false; 
    } 
}

function Check_Numeric(ee)
	{
		if(ee.keyCode == 8 || ee.charCode == 8)
		{
			return true;
		}
		if ((ee.keyCode < 46 || ee.keyCode > 57) && ee.keyCode!=0) 
		{
			return false;
		}
		else
		{
			//firefox
			if ((ee.charCode < 46 || ee.charCode > 57) && ee.charCode!=0) 
			{
				return false;
			}
		}

	}