function OpenInNewWindow(WindowURL, WindowName)
{
	var WindowProperties=''
	switch(WindowName)
	{
		//case 'PLA':
		//	WindowProperties = 'toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,status=1,width=1024,height=675,left=0,top=0';			
		//	break;
		//case 'PreTest':	
		//	WindowProperties = 'toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,status=1,width=1024,height=675,left=0,top=0';
		//	break;
		//uma
		case 'GenerateReport':
			WindowProperties = 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,top=0,left=0,width=800,height=600';
			break;
		//uma
		case 'FullScreen':	
			WindowProperties = 'toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,status=1,width=1024,height=675,left=0,top=0';
			break;
		case 'OpenFile':
			WindowProperties = 'toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes, resizable=yes,width=1024,height=693,left=0,top=0';
			break;
		case 'OpenFile1':
			WindowProperties = 'toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes, resizable=yes,width=1024,height=693,left=0,top=0';
			break;
		case 'IMOWWindow':
			WindowProperties = 'toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes, resizable=yes,width=1024,height=750,left=0,top=0';
			break;
		case 'IMOVWindow':
			WindowProperties = 'toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes, resizable=yes,width=1024,height=768,left=0,top=0';
			break;
		case 'LearnerMessage':
			WindowProperties = 'toolbar=no,statusbar=no,menubar=no,scrollbars=yes, resizable=no,width=600,height=450,left=0,top=0';
			break;	
		// ANIKET for New Login Page
		case 'LoginInstructions':
			WindowProperties = 'toolbar=no,location=no,directories=no,menubar=no,scrollbars=no, resizable=no,width=600,height=250,left=300,top=300';
			break;
		// ANIKET for New Login Page
                case 'LearnerAssessment':   
		            WindowProperties = 'toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,status=1,width=1024,height=700,left=0,top=0';
			break;
									
	}
	//WindowURL = UnMaskChar(WindowURL);	
	WindowURL = UrlFullDecode(UrlFullEncode(WindowURL));
	//alert(WindowURL);
	var newWin = window.open(WindowURL, WindowName, WindowProperties);
} 

function OpenInNewWindowForSimulation(WindowURL, WindowName)
{
	var WindowProperties=''
	switch(WindowName)
	{		
		case 'FullScreen':	
			WindowProperties = 'toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,status=1,width=1024,height=675,left=0,top=0';
			break;					
	}
	//WindowURL = UnMaskChar(WindowURL);		
	WindowURL = UrlFullDecode(UrlFullEncode(WindowURL));	
	var newWin = window.open(WindowURL, WindowName, WindowProperties);
} 



function ismaxlength(obj)
{
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
{
obj.value=obj.value.substring(0,mlength)
alert("Maximum limit is exceeded.")
}
}

function UrlFullEncode(str) 
{
    str = escape(str);
    str = str.replace('%','%*');
    return str;
}

function UrlFullDecode(str)
{
    str = str.replace('%*','%');
    str = unescape(str);
    return str;
}

//Uma Changes 29 jan 2009
function NumberValidation(value)
{
    var value;
    
    if (isNaN(value)) 
    {
    	
        return false;
    }
    else
    {
    	
        
         if(value.indexOf('e') != -1 || value.indexOf('E') != -1 )
         {
           return false; 
         }
        
        return true;
    }
    
}

//Uma Changes 29 jan 2009


             
function UnMaskChar(URL)
{
	return URL.replace("$quote$","'");
}

function onEnterKeyPress()
{
	if ((event.which && event.which == 13) || (event.keyCode &&	event.keyCode == 13))
	{			
		event.keyCode=0;				
		return false;
	}
}

function onF5KeyPress()
{
	if ((event.which && event.which == 116) || (event.keyCode && event.keyCode == 116))
	{			
		event.keyCode=0;				
		return false;
	}

	if ((event.which && event.which == 13) || (event.keyCode &&	event.keyCode == 13))
	{			
		event.keyCode=0;				
		return false;
	}
}

function OnBeforeResultPrint()
{
	//document.all.PrintTable.bordercolor = "blue";
	document.all.PrintTable.border = "1";
	document.all.PrintHide1.style.visibility = "hidden";
	document.all.PrintHide2.style.visibility = "hidden";
	document.all.PrintHide3.style.visibility = "hidden";
	document.all.PrintHide4.style.visibility = "hidden";
	document.all.PrintHide5.style.visibility = "hidden";
}

function OnAfterResultPrint()
{
	document.all.PrintTable.border = "0";
	document.all.PrintHide1.style.visibility = "visible";
	document.all.PrintHide2.style.visibility = "visible";
	document.all.PrintHide3.style.visibility = "visible";
	document.all.PrintHide4.style.visibility = "visible";
	document.all.PrintHide5.style.visibility = "visible";
}




function reloadparentwindow()
{
	window.opener.location.reload(); 
	window.close();
}

function reloadparentwindow1()
{
	window.opener.location.reload(); 
	
	//window.close();
}

////Nikhil Rescheduling End
////Nikhil Rescheduling End

function checkNumeric(objName,minval, maxval,comma,period,hyphen)
{
	
	
	var numberfield = eval('window.document.all["' + objName.id + '"]');
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		numberfield.focus();
		return true;
	}
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen)
{
	
		var checkOK = "0123456789" + comma + period + hyphen;
		var checkStr = eval('window.document.all["' + objName.id + '"]');
		var allValid = true;
		var decPoints = 0;
		var allNum = "";
		
		//Uma Changes 29 jan 2009
		if(checkStr.value.length==0)
		{
		    checkStr.value=10;
		}
		//Uma Changes 29 jan 2009
		
		for (i = 0; i < checkStr.value.length;  i++)
		{
			ch = checkStr.value.charAt(i);
			if(ch != "")
			{
			  for (j = 0;  j < checkOK.length;  j++)
			     {
			      if (ch == checkOK.charAt(j))
			       {
			          break;
			        }
				  if (j == checkOK.length)
				  {
					allValid = false;
					break;
				   }
				 }
				if (ch != ",")
					allNum += ch;
				}
			}
		if (!allValid)
		{	
			alertsay = "Please enter only these values \""
			alertsay = alertsay + checkOK + "\" ."
			alert(alertsay);
			return (false);
       }

// set the minimum and maximum
	var chkVal = allNum;
	var prsVal = parseInt(allNum);
	
	//Uma Changes 29 jan 2009
	if (!NumberValidation(allNum))
	{
	    alertsay = "Please enter only numeric values."
		//alertsay = alertsay + checkOK + "\" ."
	    alert(alertsay);
		return (false);
	}
	//Uma Changes 29 jan 2009
	
	if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
	{
		alertsay = "Please enter a value greater than or "
		alertsay = alertsay + "equal to \"" + minval + "\" and less than or "
		alertsay = alertsay + "equal to \"" + maxval + "\" ."
		alert(alertsay);
		return (false);
	}
}

function handleEnter (field, event)
 {
 
  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
  if (keyCode == 13) 
  {
	var i;
	for (i = 0; i < field.form.elements.length; i++)
		if (field == field.form.elements[i])
		    break;
		i = (i + 1) % field.form.elements.length;
		field.form.elements[i].focus();
		return false;
		//alert("Press");
  } 
 else
	 return true;
} 

// function to disable cut and paste commands
function validateKey (evt) 
{
	
	if (evt.keyCode == '17')
		{
			alert("You are not allowed to paste here");
			return false
		}
	
	return true
}


// function to disable paste commands
function disableCtl(e)
{
		var key;
		if(window.event)
        {
            key = window.event.keyCode;
			if(window.event.ctrlKey)
			{
				if(String.fromCharCode(key).toLowerCase() == 'v') 
				{
					alert("you can't paste here.");
					return false;
				}
			}
		}
}


function checkInternationalPhone(strPhone)
{
	
	
	debugger;
	// Declaring required variables
	var digits = "0123456789";
	// non-digit characters which are allowed in phone numbers
	var phoneNumberDelimiters = "()- ";
	// characters which are allowed in international phone numbers
	// (a leading + is OK)
	var validWorldPhoneChars = phoneNumberDelimiters + "+";
	// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

	// end
	
	
	var bracket=3
	strPhone=trim(strPhone)
	if(strPhone.indexOf("+")>1) return false
	if(strPhone.indexOf("-")!=-1)bracket=bracket+1
	if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
	var brchr=strPhone.indexOf("(")
	if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
	if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}



function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function isValidEmail(email, required) {
    
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
         
    } 
    
    else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
	return false;
    }
    return true;
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}


//Shilpi 03 dec 09 for disabling paste functionality
function noCopyMouse(e) {
	var isRight = (e.button) ? (e.button == 2) : (e.which == 3);
	if(isRight) {
	return false;
	}
	return true;
}

function noCopyKey(e) {
	var code = (document.all) ? event.keyCode:e.which;
	var msg = "Sorry, this functionality is disabled.";
	if (parseInt(code)==17) //CTRL
	{
		alert(msg);
		window.event.returnValue = false;
	}

}

function disableSelection(target){
	if (typeof target.onselectstart!="undefined") //IE route
	target.onselectstart=function(){return false}
	else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	target.style.MozUserSelect="none"
	else //All other route (ie: Opera)
	target.onmousedown=function(){return false}
	target.style.cursor = "default"
}

//Shilpi 03 dec 09

//Following function added for Simulation by Santosh

function chkLearnerResponse(objName,errorMsg)
  {			 
		var checkStr = eval('window.document.all["' + objName + '"]');
		if(checkStr.value.length==0)
		{
		    alert(errorMsg);
		}
  }
  
  function chkLearnerPresentationResponse(objNameEasyDiff,objNameAnswer,ErrorMsgBoth,ErrorMsgEasyDiff,ErrorMsgAns)
  {			 
		var checkStrEasy = eval('window.document.all["' + objNameEasyDiff + '"]');
		var checkStrAns = eval('window.document.all["' + objNameAnswer + '"]');		
						
		if ((checkStrEasy.value.length==0)&&(checkStrAns.value.length==0))
        {
            alert(ErrorMsgBoth);
        }
        else if (checkStrEasy.value.length==0)
        {
            alert(ErrorMsgEasyDiff);
        }
        else if (checkStrAns.value.length==0)
        {
            alert(ErrorMsgAns);
        }		
  }