// JavaScript Document

varStop = 0;

function changeBIG(){
	setTimeout("changeBIG2()",5250);
}

function changeBIG1(){
	if (varStop != 1){
		div = 'changeImage';
		document.getElementById(div).innerHTML = '<A HREF="#" title="SI Portal Overview"  onClick="return changeYouTube(1)"><img border=0 src="images/big_img1.png" title="SI Portal Overview"></a>';
		document.getElementById("li3").className = '';
		document.getElementById("li1").className = 'active';
	}
}

function playImage1(){
	varStop = 1;
	funGetASP('changeImage','youtube.asp?v=1');
	return false;
}



function changeBIG2(){
	if (varStop != 1){
		div = 'changeImage';
		document.getElementById(div).innerHTML = '<A HREF="#" title="Device Overview" onClick="return changeYouTube(2)"><img border=0 src="images/big_img2.png" title="Device Overview"></a>';
		document.getElementById("li1").className = '';
		document.getElementById("li2").className = 'active';
		setTimeout("changeBIG3()",5250);
	}
}

function changeBIG3(){
	if (varStop != 1){
		div = 'changeImage';
		document.getElementById(div).innerHTML = '<A HREF="#" title="SI Portal Mobile Overview"  onClick="return changeYouTube(3)"><img border=0 src="images/big_img3.png" title="SI Portal Mobile Overview"></a>';
		document.getElementById("li2").className = '';
		document.getElementById("li3").className = 'active';
		setTimeout("changeBIG1()",5250);
	}
}


function changeImageBIG1(){
	div = 'changeImage';
	varStop = 1;
	document.getElementById(div).innerHTML = '<A HREF="#" title="SI Portal Overview" onClick="return changeYouTube(1)"><img border=0 src="images/big_img1.png" title="SI Portal Overview"></a>';
	document.getElementById("li3").className = '';
	document.getElementById("li2").className = '';
	document.getElementById("li1").className = 'active';
}


function changeYouTube(varNumber){
	varStop = 1;
	div = 'changeImage';
	url = 'youtube.asp?v=' + varNumber;
	funGetASP2(div,url);
}

function changeImageBIG2(){
	div = 'changeImage';
	varStop = 1;
	document.getElementById(div).innerHTML = '<A HREF="#" title="Device Overview" onClick="return changeYouTube(2)"><img border=0 src="images/big_img2.png" title="SI Portal Overview"></a>';
	document.getElementById("li1").className = '';
	document.getElementById("li3").className = '';
	document.getElementById("li2").className = 'active';
}

function changeImageBIG3(){
	div = 'changeImage';
	varStop = 1;
	document.getElementById(div).innerHTML = '<A HREF="#" title="SI Portal Mobile Overview" onClick="return changeYouTube(3)"><img border=0 src="images/big_img3.png" title="SI Portal Overview"></a>';
	document.getElementById("li2").className = '';
	document.getElementById("li1").className = '';
	document.getElementById("li3").className = 'active';
}


function funCLISubmit(){
return false;
alert('ac');
}

function funSetHomePage(page){
	div = 'SetHomePage';
	url = "siportal-ajax.asp?rID=SetHomePage&HomePage=" + page + "&random=" + Math.random();
	document.getElementById(div).innerHTML = '&nbsp;&nbsp;<img src=/img/wait.gif>';
	GetASP(url,div);	
	return false;
	
}

function checkInt(field){
	value = document.getElementById(field).value;
	if (value!=''){
		if(isInteger(value)==false){
			alert('Enter an integer value for ' + field + '.');
			document.getElementById(field).value = '';
		}
	}
}

function funDelete(text,type,ID,clientID){
	div = 'Delete' + type + ID;		
	document.getElementById(div).innerHTML = "<input type=button value='" + text + "' onClick=funConfirmDelete('" + type + "','" + ID + "','" + clientID + "')><input type=button value='Cancel' onClick=funCancelDelete('" + div + "')>";
	return false;
	
}

function funCancelDelete(div){
	document.getElementById(div).innerHTML = '';
	return false;
}


function sessionRefresh(clientID){
  div = 'Refresh';
  url = "siportal-ajax.asp?rID=Refresh&ClientID=" + clientID + "&random=" + Math.random();
  document.getElementById(div).innerHTML = '&nbsp;&nbsp;<img src=/img/wait.gif>';
  GetASP(url,div);	
  closeDialogBoxSmall();
  window.location.reload( true );
  return false;
}

function funConfirmDelete(type,ID,clientID){
	div = 'Delete' + type + ID;	
	url = 'siportal-ajax.asp?rID=ConfirmDelete&type=' + type + '&ID=' + ID +'&ClientID=' + clientID + '&Method=Del&random=' + Math.random();
 	GetASP(url,div);
	return false;	
}


function DialogBox(title, htmlContents) {

	var dialogBackground = document.createElement('div');
	dialogBackground.className = "dialogBackground";
	dialogBackground.setAttribute("id", "dialogBackground");
	var dialogBox = document.createElement('div');
	dialogBox.className = "dialogBox";
	dialogBox.setAttribute("id", "dialogBox");
	// create contents of the dialog box
	var dialogBoxContents = "";
	dialogBoxContents += "<table width='100%'><tr>";
	dialogBoxContents += "<td width='100%'>" + title + "</td>";
	dialogBoxContents += "<td><a href='' onclick='closeDialogBox();return false'>X</a></td>";
	dialogBoxContents += "</tr>";
	dialogBoxContents += "<tr>";
	dialogBoxContents += "<td>" + htmlContents + "</td>";
	dialogBoxContents += "</tr></table>";
	dialogBox.innerHTML = dialogBoxContents;
	document.body.appendChild(dialogBox);
	document.body.appendChild(dialogBackground);

}

function closeDialogBox() {
	document.body.removeChild(document.getElementById('dialogBackground'));
	document.body.removeChild(document.getElementById('dialogBox'));
}

function funCancelSkillSet(id){

	funGetASP2("SkillSet","siportal-ajax.asp?rID=CancelSkill&ContactID=" + id);

}

function funUpdateSkill(id,field){

	value = document.getElementById(field + id).value;
	contactID = document.getElementById('ContactID').value;
	div = "divSkill" + id;
	url = "siportal-ajax.asp?rID=UpdateSkill&ContactID=" + contactID + "&Type=" + field + "&value=" + value + "&SkillID=" + id;
	funGetASP2(div,url);
	return false;

}


function updateSkillTypeID(){
	varID = document.EditSkillTypeID.SkillTypeID.value;
//	alert (document.form.EditSkillTypeID.SkillTypeName.value);	
    varValue = document.getElementById('SkillType' + varID).value;
	url="config-ajax.asp?rID=UpdateSkillTypeID&SkillTypeID=" + varID + "&SkillType=" + varValue + "&random=" + Math.random();
    
	div="DivSkill" + varID;
    funGetASP2(div,url);	
	return false;

}




function funAddNewSkillType2(id){
	value = document.getElementById('NewSkillName').value;
	funGetASP2("SkillSet","siportal-ajax.asp?rID=AddSkillType&ContactID=" + id + "&Skill=" + value);
	return false;

}

function funAddNewSkillType(id){

	varText = "<input name=NewSkillName id=NewSkillName><input type=button value='Add Skill Type' onclick='funAddNewSkillType2(" + id + ")'><input type=button value='Cancel' onclick='funCancelSkillSet(" + id + ");'>";
	document.getElementById('SkillSet').innerHTML = varText;
	return false;
	
}




function DialogBoxSmall(title, htmlContents) {

	var dialogBackground = document.createElement('div');
	dialogBackground.className = "dialogBackground";
	dialogBackground.setAttribute("id", "dialogBackground");
	var DialogBoxSmall = document.createElement('div');
	DialogBoxSmall.className = "DialogBoxSmall";
	DialogBoxSmall.setAttribute("id", "DialogBoxSmall");
	// create contents of the dialog box
	var DialogBoxSmallContents = "";
	DialogBoxSmallContents += "<table width='100%'><tr>";
	DialogBoxSmallContents += "<td width='100%'>" + title + "</td>";
	DialogBoxSmallContents += "<td><a href='' onclick='closeDialogBoxSmall();return false'>X</a></td>";
	DialogBoxSmallContents += "</tr>";
	DialogBoxSmallContents += "<tr>";
	DialogBoxSmallContents += "<td>" + htmlContents + "</td>";
	DialogBoxSmallContents += "</tr></table>";
	DialogBoxSmall.innerHTML = DialogBoxSmallContents;
	document.body.appendChild(DialogBoxSmall);
	document.body.appendChild(dialogBackground);

}

function closeDialogBoxSmall() {
	document.body.removeChild(document.getElementById('dialogBackground'));
	document.body.removeChild(document.getElementById('DialogBoxSmall'));
}


function DialogBoxOpen(title, htmlContents) {

	var dialogBackgroundOpen = document.createElement('divOpen');
	dialogBackgroundOpen.className = "dialogBackgroundOpen";
	dialogBackgroundOpen.setAttribute("id", "dialogBackgroundOpen");
	var DialogBoxOpen = document.createElement('divOpen');
	DialogBoxOpen.className = "DialogBoxOpen";
	DialogBoxOpen.setAttribute("id", "DialogBoxOpen");
	// create contents of the dialog box
	var DialogBoxOpenContents = "";
	DialogBoxOpenContents += "<table width='100%'><tr>";
	DialogBoxOpenContents += "<td width='100%'>" + title + "</td>";
	DialogBoxOpenContents += "<td><a href='' onclick='closeDialogBoxOpen();return false'>X</a></td>";
	DialogBoxOpenContents += "</tr>";
	DialogBoxOpenContents += "<tr>";
	DialogBoxOpenContents += "<td>" + htmlContents + "</td>";
	DialogBoxOpenContents += "</tr></table>";
	DialogBoxOpen.innerHTML = DialogBoxOpenContents;
	document.body.appendChild(DialogBoxOpen);
	document.body.appendChild(dialogBackgroundOpen);

}


function closeDialogBoxOpen() {
	document.body.removeChild(document.getElementById('dialogBackgroundOpen'));
	document.body.removeChild(document.getElementById('DialogBoxOpen'));
}





function showHide(show,hide){

	document.getElementById(show).style.display = '';
	document.getElementById(hide).style.display = 'none';
	return false;

}

function noEnter(e){ //e is event object passed from function invocation
var characterCode //literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
return false;
}
else{
return true;
}

}







function generatePW() {
document.getElementById('generatePW').style.display = '';
document.getElementById('showgeneratePW').innerHTML = '';
showgeneratePW
}



























   var http_request = false;
   
   
   
function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('SIBody').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
}


function makePOSTRequest(url, parameters) {


	      http_request = false;
	      

	      
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");

            } catch (e) {}
         }
      }
      
      

      
      
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
}







function funGetASP(div,url){

	document.getElementById(div).innerHTML= '<img src=images/wait.gif>';
    GetASP(url,div);
	setTimeout("window.location.hash='dac'",1250);
  	return false;	
}


function funGetASP2(div,url){
    url = url + '&random=' + Math.random();
	document.getElementById(div).innerHTML= '<img src=/img/wait.gif>';
    GetASP(url,div);
  	return false;	
}


function changeDIV(div,message){
	document.getElementById(div).innerHTML = message;
}

function funSubmit(){
	document.getElementById("SubmitButton").innerHTML = "<table><Tr><TD><img src=img/wait.gif border=0> Loading...</TD></TR></table>";
}

function helloworld(){
 alert("hello world");
 return false;
}

function dberror(url){
	divError = '<img src=img/wait.gif> Loading Database Error....';
	div = 'error';
	document.getElementById(div).innerHTML= divError;
	
	GetASP(url,div);	
  	return false;	

}


function sf(){document.form.CLI.focus();}
window.clk=function(b,c,d,h,i,j){if(document.images){var a=window.encodeURIComponentComponent?encodeURIComponentComponent:escape,e="",f="",g="";if(b){e="&url="+a(b.replace(/#.*/,"")).replace(/\+/g,"%2B")}if(c){f="&oi="+a(c)}if(d){g="&cad="+a(d)}(new Image).src="/url?sa=T"+f+g+"&ct="+a(h)+"&cd="+a(i)+e+"&ei=0tL8RfaoKaCYYJHp2IoP"+j}return true};



function isExisting(obj){
  return typeof(obj)!='undefined';
}



function ShowHide(arrowID,div,bool1){
	
	alert(bool1);
}



function GetASPValue(url,div){
	var xmlHttp;
	try
  	{  // Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	}
	catch (e)
	{  // Internet Explorer 
		   try
		    {    
					xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
			}
			catch (e)
		   	{
		    	try
      			{      
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
				}
		    	catch (e)
      			{
				      alert("Your browser does not support AJAX!");      return false;     
				}
	     	}
		}
		xmlHttp.onreadystatechange=function()
	    {
    		if(xmlHttp.readyState==4)
			{
			//	 alert(xmlHttp.responseText);
			      document.getElementById(div).value=xmlHttp.responseText;
      		}
    }
    
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null); 

}



function GetASP(url,div){
	
	var xmlHttp;
	try
  	{  // Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	}
	catch (e)
	{  // Internet Explorer 
		   try
		    {    
					xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
			}
			catch (e)
		   	{
		    	try
      			{      
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
				}
		    	catch (e)
      			{
				      alert("Your browser does not support AJAX!");      return false;     
				}
	     	}
		}
		xmlHttp.onreadystatechange=function()
	    {
    		if(xmlHttp.readyState==4)
			{
			//	 alert(xmlHttp.responseText);
			      document.getElementById(div).innerHTML=xmlHttp.responseText;
      		}
    }
    
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null); 

}

		


function GetASPNotWorking(url,div){
	
	var xmlHttp;
	try
  	{  // Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	}
	catch (e)
	{  // Internet Explorer 
		   try
		    {    
					xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
			}
			catch (e)
		   	{
		    	try
      			{      
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
				}
		    	catch (e)
      			{
				      alert("Your browser does not support AJAX!");      return false;     
				}
	     	}
		}
		xmlHttp.onreadystatechange=function()
	    {
    		if(xmlHttp.readyState==4)
			{
			//	 alert(xmlHttp.responseText);
			    if (div != ''){
			      document.getElementById(div).innerHTML=xmlHttp.responseText;
		    	}
      		}
    }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null); 

}






function RemoveUsers(){
	
	document.getElementById("RemoveUsers").innerHTML= '';
	document.getElementById("RemoveUsers2").innerHTML= '';
	
}




function HideSideMenu(varBool,varPage)
{
	
	var url = window.parent.document.location.protocol + '//' + location.hostname + '/';
	
	if (document.LeftRightArrow.src == url + 'img/arrowleft.gif')
	{
 		document.LeftRightArrow.src = "img/arrowright.gif";
 		varHide = true;
 		varMenu = document.getElementById('SideMenu').innerHTML;
 		document.getElementById('SideMenu').innerHTML = '';
 		document.getElementById('SideMenu').style.visibility = 'hidden';
		document.getElementById('SideMenuTD').width="1"
		
	
		url = 'siportal-ajax.asp?AjaxRID=HideSideMenu&Hide=' + varHide + '&random=' + Math.random();
		div="HideMenu";
		GetASP(url,div);
		return false; 
	
	}
	else
	{

		if (document.LeftRightArrow.src == url + 'img/arrowright.gif')
		{
			document.LeftRightArrow.src = "img/arrowleft.gif";
			varHide = false;
  		    document.getElementById('SideMenu').style.visibility = 'visible';
  		    if (document.getElementById('SideMenu').innerHTML == ''){
	 			document.getElementById('SideMenu').innerHTML = varMenu;
 			}
			
			url = 'siportal-ajax.asp?AjaxRID=HideSideMenu&Hide=' + varHide + '&random=' + Math.random();
			div="HideMenu";
			GetASP(url,div);
			
			if (varBool == 'True'){
			document.getElementById('SideMenuTD').width="170";
			window.location = varPage;
			}
			
			return false; 
			
			
		}		
		else
		{
			alert('javascript;hidesidemenu() failed, img/arrowright.gif\n or img/arrowleft.gif not found');
		}
	}


		    
	if (varHide == false){
		alert(varHide);	
	}
	
	
}	






function gbpopup(pagina,descripcion,x,y) { 
                GB_showCenter(descripcion,pagina, y, x); 
} 

function HideMenus()
{
	
		
 		document.getElementById('TopMenu').style.display = 'none';
		document.getElementById('TopMenuTD').height="0"

		document.getElementById('HeaderMenu').style.display = 'none';
		document.getElementById('HeaderMenu').innerHTML= '';		
		document.getElementById('HeaderMenuTD').height="0";		
		document.getElementById('HeaderMenuRedTD').height="0";		
 		document.getElementById('SideMenu').style.display = 'none';
		document.getElementById('SideMenuTD').width="0"		

		
 		document.getElementById('BottomMenu').style.display = 'none';
		document.getElementById('BottomMenuBlackContent').innerHTML= '';

		document.getElementById('BottomMenuTD').height="0";		
		document.getElementById('BottomMenuBlackTD').height="0";
}	









function CancelButton(div,text){

	document.getElementById(div).innerHTML= text;
	return false;

}

function Default(){
 //function to run when clicking clients from the si portal menu
}	








/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

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 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++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}




   function isTime(strTime) 
   { 
      var strTestTime = new String(strTime); 
      strTestTime.toUpperCase(); 

      var bolTime = false; 
      
      if (strTestTime.indexOf("PM",1) != -1 || strTestTime.indexOf("AM",1)) {
         bolTime = true; 
	}     
     if (bolTime && strTestTime.indexOf(":",0) == 0) {
         bolTime = false; 
 	}
      var nColonPlace = strTestTime.indexOf(":",1); 
      if (bolTime && ((parseInt(nColonPlace) + 5) > (strTestTime.length - 1) || (parseInt(nColonPlace) + 4) > (strTestTime.length - 1))) {
         bolTime = false; 
    }
         
      return bolTime; 
   } 






function isDateOK(dateStr) {

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null) {
alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
return false;
}

month = matchArray[1]; // p@rse date into variables
day = matchArray[3];
year = matchArray[5];

if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
return false;
}

if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn`t have 31 days!")
return false;
}

if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day > 29 || (day==29 && !isleap)) {
alert("February " + year + " doesn`t have " + day + " days!");
return false;
}
}
return true; // date is valid
}   
   
function isDate(dtStr){
	
  if (dtStr!=''){	
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
  }
return true
}












 function validateInt()
   {
      var o = document.frmInput.txtInput;
      switch (isInteger(o.value))
      {
         case true:
            alert(o.value + " is an integer")
            break;
         case false:
            alert(o.value + " is not an integer")
      }
   }

   function validateRange()
   {
      var s = document.frmInput.txtInput.value;
      var A = document.frmInput.txtA.value;
      var B = document.frmInput.txtB.value;

      switch (isIntegerInRange(s, A, B))
      {
         case true:
            alert(s + " is in range from " + A + " to " + B)
            break;
         case false:
            alert(s + " is not in range from " + A + " to " + B)
      }
   }

// isIntegerInRange (STRING s, INTEGER a, INTEGER b)
   function isIntegerInRange (s, a, b)
   {   if (isEmpty(s))
         if (isIntegerInRange.arguments.length == 1) return false;
         else return (isIntegerInRange.arguments[1] == true);

      // Catch non-integer strings to avoid creating a NaN below,
      // which isn't available on JavaScript 1.0 for Windows.
      if (!isInteger(s, false)) return false;

      // Now, explicitly change the type to integer via parseInt
      // so that the comparison code below will work both on
      // JavaScript 1.2 (which typechecks in equality comparisons)
      // and JavaScript 1.1 and before (which doesn't).
      var num = parseInt (s);
      return ((num >= a) && (num <= b));
   }

   function isInteger (s)
   {
      var i;

      if (isEmpty(s))
      if (isInteger.arguments.length == 1) return 0;
      else return (isInteger.arguments[1] == true);

      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);

         if (!isDigit(c)) return false;
      }

      return true;
   }

   function isEmpty(s)
   {
      return ((s == null) || (s.length == 0))
   }

   function isDigit (c)
   {
      return ((c >= "0") && (c <= "9"))
   }

   
   
   function isDecimal( str )
{
return /^\d*\.?\d*$/.test( str );
}
   
function checkDecimal(DigitsAfterDecimal)
    {
        
        if(document.getElementById(DigitsAfterDecimal).value == '' )
        {
            alert("Please enter valid decimal value");
            return false;
        }
        else
        {
            
           if(isNaN(document.getElementById(DigitsAfterDecimal).value))
           {
                alert("Please enter valid decimal value");
                return false;
           }
           else
           {
                var val = document.getElementById(DigitsAfterDecimal).value;
                if(val.indexOf(".") > -1)
                {
                    
                    if(val.length - (val.indexOf
                        (".")+1) > 
                           DigitsAfterDecimal)
                    {
                        alert("Please enter valid decimal value. Only " +
                          DigitsAfterDecimal + " digits are allowed after decimal.");



                         return false;
                    }
                    else
                    {
                      return true;
                    }
                }
                else
                {
                    if(parseInt(val) > 0)
                    {
                        return true;
                    }
                    else
                    {
                       alert("Value must be greater than 0"); 

                       return false;
                     }
                }
           }
        }
    }





















































