// JavaScript Document
// JavaScript Document
function getKeyCharCode(event) 
{
	var key = null;
	if (window.event) {
		//ie
		key = window.event.keyCode;
	} else if (event.which) {
		key = event.which;
	}
	return key;
}
function IsNumeric(event)
    {
      /* var key=(evt.which) ? evt.which : event.keyCode
       if ((key >= 48) && (key <58) || (key == 46) || (key==8) || (key==127))
       {
       return true;
       }
       else
       {
       return false;
       }*/
			var isMozilla = false;
			if (!window.event && event.which) 
			{
				isMozilla = true;
			}
			var key = getKeyCharCode(event);
			var isNumeric = false;
			if (key != null) 
			{
				if (key >= 48 && key <= 58)	 
				{
					// key is numeric
					isNumeric = true;
				} 
				else if (key == 46) 
				{
					// key is a decimal point
					isNumeric = true;
				} 
				else if (key == 13) 
				{
					//13 is a return
					isNumeric = true;
				} 
				else if (key == 8 && isMozilla) 
				{
					//8 is a backspace with mozilla
					isNumeric = true;
				}
			} 
			else 
			{
				isNumeric = true;
			}
			return isNumeric;
	   /////
  }
function IsNumericMobile(event)
    {
      /* var key=(evt.which) ? evt.which : event.keyCode
       if ((key >= 48) && (key <58) || (key == 46) || (key==8) || (key==127))
       {
       return true;
       }
       else
       {
       return false;
       }*/
			var isMozilla = false;
			if (!window.event && event.which) 
			{
				isMozilla = true;
			}
			var key = getKeyCharCode(event);
			var isNumeric = false;
			if (key != null) 
			{
				if (key >= 48 && key <= 58)	 
				{
					// key is numeric
					isNumeric = true;
				} 
				else if (key ==43) 
				{
					// key is a decimal point
					isNumeric = true;
				} 
				else if (key == 13) 
				{
					//13 is a return
					isNumeric = true;
				} 
				else if (key == 8 && isMozilla) 
				{
					//8 is a backspace with mozilla
					isNumeric = true;
				}
			} 
			else 
			{
				isNumeric = true;
			}
			return isNumeric;
	   /////
  }
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid Email")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid Email")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid Email")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid Email")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid Email")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid Email")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid Email")
		    return false
		 }

 		 return true					
	}

function chkEmail(obj){
	var emailID=obj
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter email")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function addOption(theSel, theText, theValue)
{
	
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  if(selLength>1)
  {
   for(var k=1; k<selLength;k++){ if(theSel[k].value==theValue) return; }
   }
  theSel.options[selLength] = newOpt;
  theSel.options[selLength].selected=true;
}

function deleteOption(theSel, theIndex)
{ 
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}

function moveOptions(theSelFrom, theSelTo)
{
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  var exist=0;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
	   
    if(theSelFrom.options[i].selected)
    {
		  selectedText[selectedCount] = theSelFrom.options[i].text;
		  selectedValues[selectedCount] = theSelFrom.options[i].value;
		  deleteOption(theSelFrom, i);
		  selectedCount++;
    }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
    addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  
  if(NS4) history.go(0);
}
