﻿// JScript File

 
function textCounter( txtSource, labelDest)
 {
 
   if(window.ActiveXObject)
   {   
   labelDest.innerText=txtSource.value.length;     
   }
   else
   {        
   labelDest.textContent=txtSource.value.length;
   }
 }


//function Yndrpdwn(parameter,parameter1)
//{
//    
//    var Gdrlvalue="ctl00$ContentPlaceHolder1$";
//    var CtrlValue=document.getElementById(Gdrlvalue+parameter).value;
//    var TglValue=document.getElementById("ctl00_ContentPlaceHolder1_"+parameter1);
//    if(CtrlValue=='N')
//    {
//        TglValue.innerHTML="";
//        TglValue.disabled=true;
//    }
//    else
//        TglValue.disabled=false;
//    
//}


function fnMoveItems(lstbxFrom,lstbxTo)
{

 var varFromBox = document.getElementById(lstbxFrom);
 var varToBox = document.getElementById(lstbxTo); 
 
 if ((varFromBox != null) && (varToBox != null)) 
 { 
 
  if(varFromBox.length < 1) 
  {
   //alert('There are no items in the source ListBox');
   return false;
  }
  if(varFromBox.options.selectedIndex == -1) // when no Item is selected the index will be -1
  {
   //alert('Please select an Item to move');
   return false;
  }
  while ( varFromBox.options.selectedIndex >= 0 ) 
  { 
   var newOption = new Option(); // Create a new instance of ListItem 
   newOption.text = varFromBox.options[varFromBox.options.selectedIndex].text; 
   newOption.value = varFromBox.options[varFromBox.options.selectedIndex].value; 
   varToBox.options[varToBox.length] = newOption; //Append the item in Target Listbox
   varFromBox.remove(varFromBox.options.selectedIndex); //Remove the item from Source Listbox 
  } 
 }
 return false; 
}



//// // JScript File for TextArea
////	// Keep user from entering more than maxLength characters
//	function doKeypress(control){
//	
//	    maxLength = control.attributes["maxLength"].value;
//	    value = control.value;
//	    
//	     if(maxLength && value.length > maxLength-1){
//	     
//	          event.returnValue = false;          

//	          maxLength = parseInt(maxLength);
//	     }
//	    
//	}
//	// Cancel default behavior
//	function doBeforePaste(control){
//	
//	    maxLength = control.attributes["maxLength"].value;
//	    
//	     if(maxLength)
//	     {
//	          event.returnValue = false;
//	     }
//	}
//	// Cancel default behavior and create a new paste routine
//	function doPaste(control){
//	
//	    maxLength = control.attributes["maxLength"].value;
//	    value = control.value;
//	     if(maxLength){
//	          event.returnValue = false;
//	          maxLength = parseInt(maxLength);
//	          var oTR = control.document.selection.createRange();
//	          var iInsertLength = maxLength - value.length + oTR.text.length;
//	          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
//	          oTR.text = sData;
//	     }
//	}



// Keep user from entering more than maxLength characters
function doKeypress(controlId, e)
{

    var charCode;
    if(window.ActiveXObject)
    {        
        charCode = (event.charCode) ? event.charCode : ((event.keyCode) ? event.keyCode : ((event.which) ? event.which : 0));
    }
    else
    {        
        charCode = (e.charCode) ? e.charCode : ((e.keyCode) ? e.keyCode : ((e.which) ? e.which : 0));
    }
    if (charCode != 8 && charCode !=46)
    {
        var control = document.getElementById(controlId);
        maxLength = control.attributes["maxLength"].value;
        value = control.value;
        //alert(value);
        if(maxLength)
        {
            maxLength = parseInt(maxLength);
            //alert(value.length);
           // alert(maxLength-1);
            if(value.length > maxLength-1)
            {
               // alert(1);
               // return false;                
               if(window.ActiveXObject)
               {        
                event.returnValue = false;
               }
               else
               {        
                return false;         
               }
               
            }
        }
    }
    return true;
}
// Cancel default behavior

        function doBeforePaste(controlId)
        {
                var control = document.getElementById(controlId);
                maxLength = control.attributes["maxLength"].value;
                if(maxLength)
                {
                return false;
                }
          }
                // Cancel default behavior and create a new paste routine

        function doPaste(controlId)
        {
                var control = document.getElementById(controlId);
                maxLength = control.attributes["maxLength"].value;
                value = control.value;
                if(maxLength){

                maxLength = parseInt(maxLength);
                var oTR = control.document.selection.createRange();
                var iInsertLength = maxLength - value.length + oTR.text.length;
                var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
                oTR.text = sData;

                return false;
                }
            }


//function CWR_toggle(id)
//{
//	var tr = document.getElementById(id);
//	if (tr==null) { return; }
//	var bExpand = tr.style.display == '';
//	tr.style.display = (bExpand ? 'none' : '');
//}
//function CWR_changeimage(id, sMinus, sPlus)
//{
//	var img = document.getElementById(id);
//	if (img!=null)
//	{
//	    var bExpand = img.src.indexOf(sPlus) >= 0;
//		if (!bExpand)
//			img.src = sPlus;
//		else
//			img.src = sMinus;
//	}
//}
//function ShowHide()
//{
//    var obj;
//    alert(document.('chkJobAlert'));
//    if(document.getElementById('ctl00_ContentPlaceHolder1_chkJobAlert'))
//    {
//        obj = document.getElementById('ctl00_ContentPlaceHolder1_chkJobAlert').checked;
//        alert(obj);
//    }
////    if(!obj.checked)
////    {  document.getElementById('JobAlertDet4').style.Display="none";}
////    else
////    {document.getElementById('JobAlertDet4').style.Display ="Block";}
////    }
//}

function pop( location ) 
{

var winWidth = 800 ; 

var winHeight = 800 ; 

var posLeft = ( screen.width - winWidth ) / 2 ; 

var posTop = ( screen.height - winHeight ) / 2 ; 
myWindow = window.open( location,

'mywindow','width=' + winWidth + ',height=' + winHeight +',top=' + posTop + ',left=' + posLeft + 

',resizable=yes,scrollbars=yes,toolbar=no,titlebar=no,' + 

'location=no,directories=no,status=no,menubar=no,copyhistory=no' ) ; 
 
return false; 

}

function ResetDdnWidth(object)
{
    if(object.originalWidth!="")    {
        object.style.position = "";
        object.style.width = object.originalWidth;
        object.originalWidth = "";
    }
}

function RearrangeDdnWidth(object)
{
    var objectPosition = fGetXY(object);
    if(object.originalWidth=="")    {
    //alert(object.style.width);
		object.style.position = "absolute";
		object.style.top = objectPosition[1];
		object.style.left = objectPosition[0];
		object.originalWidth = object.style.width;
		object.style.width = "";
		object.focus();
	}	
}

function fGetXY(aTag){
  var p=[0,0];
  while(aTag!=null){
  	p[0]+=aTag.offsetLeft;
  	p[1]+=aTag.offsetTop;
  	aTag=aTag.offsetParent;
  }
  return p;
}