
//var oPopup = window.createPopup();
//
//	function showToolTip(obj) {
//		var x = obj.offsetLeft + window.screenLeft;
//		var y = obj.offsetTop + window.screenTop;
//		var tooltip = '<div style=""position: absolute; top:0; left:0; width:100%; height:100%; border:1px solid black; font:normal 10pt tahoma;  filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=gold, EndColorStr=#FFFFFF); padding:5px"">';
//
//		var title = obj.title;
//		oPopup.document.body.innerHTML= tooltip  + title  + '</div>';
//		var Hght = parseInt(title.length / 80); 
//		oPopup.show(x, y+15, 170,  Hght *35);
//	}
	
////////////////////////////////////////////////////////////////////////////
///////////// Script For Collapseabe Panel /////////////////////////////////
////////////////////////////////////////////////////////////////////////////

		function Toggle(toggleId, ClosedImage, OpenImage, HiddenField)
		{
		
			//alert(toggleId + ' '+document.getElementById(HiddenField).value)

/*
			if (!e) {
				e = window.event;
			}
*/

			if (!document.getElementById) {
				return false;
			}
			
			var body = document.getElementById(toggleId);

/*
			var tbl = document.getElementById("tbl" + toggleId);
			if (tbl)
				tbl.width = "1%";
*/
			if (!body) {
			return false;
			} 

			var im = toggleId + "_toggle";

			if (body.style.display == 'none') {
				body.style.display = 'block';
				//alert(body.className);// = body.className + "";
			if (document.images[im]) {
				document.images[im].src = ClosedImage;
			}
			} else {
				body.style.display = 'none';
				
				if (document.images[im]) {
					document.images[im].src = OpenImage;
				}
			}

			if(document.getElementById(HiddenField)!=null)
				document.getElementById(HiddenField).value = body.style.display;
				
			body = null;

/*
			if (e) {
				e.cancelBubble = true;
				if (e.stopPropagation) {
				e.stopPropagation();
				}
			}
*/

			
		}		
			
		function ToggleErrorLabel(toggleId, ClosedImage, OpenImage, HiddenField, iFrameId, errorCount)
		{
			//alert(id)
			//alert(document.getElementById(HiddenField))
						
			//divQueue.style.width = _width;
			Toggle(toggleId, ClosedImage, OpenImage, HiddenField)
		
			if(document.getElementById(iFrameId) != null)
			{
				var myFrame = document.getElementById(iFrameId)
				
				if(document.getElementById(HiddenField) != null)
				{
					//alert(document.getElementById(HiddenField).value)
					if(document.getElementById(HiddenField).value != 'none')
					{
					//alert(document.getElementById(errorCount))
						if(document.getElementById(errorCount)!=null)
						{
							//if(document.getElementById(topTable)!=null)
						
							//alert(document.getElementById(errorCount).value)
							//alert(document.getElementById(errorCount).value * 25)
							// TODO:...............
							//alert(errorCount)
							//alert(document.getElementById(errorCount).value)
							myFrame.height = 40 + document.getElementById(errorCount).value * 15
							//alert(myFrame.height)
						}
						else
							myFrame.height = 25
					}
					else
						myFrame.height = 25
				}
				
				myFrame = null;
			}
			
			
		}

		function ToggleCallBack(toggleId, uniqueID, args, ClosedImage, OpenImage, HiddenField, StateChange)
		{
			var renderState = "_PanelRender"+ toggleId;

			if(StateChange.toLowerCase() == 'true')
			{
				Callback_FireEvent(uniqueID,
									args,
									function(result){
										// Hide Progress Bar
										HideProcessingImage();
									},
									null,
									true,
									true
									);
			}
			else
			{
				if(document.getElementById(renderState).value == "false")
				{
					document.getElementById(renderState).value = "true";
					Callback_FireEvent(uniqueID,
										args,
										function(result){
											// Hide Progress Bar
											HideProcessingImage();
										},
										null,
										true,
										true
										);

					if(document.getElementById(HiddenField)!=null)
						document.getElementById(HiddenField).value = "block";
				}
				else
				{
					Toggle(toggleId, ClosedImage, OpenImage, HiddenField);
				}
			}
			
			//Toggle(toggleId, ClosedImage, OpenImage, HiddenField);
		}
		
		
////////////////////////////////////////////////////////////////////////////
////////////////////// Script For TextArea /////////////////////////////////
////////////////////////////////////////////////////////////////////////////

		function MaxLength(textAreaID, maxLength, e)
		{
			var textArea = document.getElementById(textAreaID);
			if(textArea != null)
			{
				switch(e.keyCode) {
					case 37: // left
						return true;
					case 38: // up
						return true;
					case 39: // right
						return true;
					case 40: // down
						return true;
					case 8: // backspace
						return true;
					case 46: // delete
						return true;
					case 27: // escape
						el.value='';
					return true;
				}
				
				return (textArea.value.length<maxLength);
			}
		}
		
	// 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;
		}
	}


	function CharCheck(uniqueID){
		var txtbox = document.getElementById(uniqueID);
	
		if(txtbox != null){
		
			if(Trim(txtbox.value).length < 2){
				alert("WARNING: You have Entered less than 2 characters, which will cause NCB Enquiry to be rejected.")
			}
		}
	}
	
	function Trim(TRIM_VALUE){
		if(TRIM_VALUE.length < 1){
			return"";
			}
		TRIM_VALUE = RTrim(TRIM_VALUE);
		TRIM_VALUE = LTrim(TRIM_VALUE);
		if(TRIM_VALUE==""){
			return "";
			}
		else{
			return TRIM_VALUE;
		}
	} //End Function

	function RTrim(VALUE){
		var w_space = String.fromCharCode(32);
		var v_length = VALUE.length;
		var strTemp = "";
		if(v_length < 0){
			return"";
		}
		var iTemp = v_length -1;

		while(iTemp > -1){
			if(VALUE.charAt(iTemp) == w_space){
			}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

		} //End While
	return strTemp;

	} //End Function

	function LTrim(VALUE){
		var w_space = String.fromCharCode(32);
		if(v_length < 1){
			return"";
		}
		var v_length = VALUE.length;
		var strTemp = "";

		var iTemp = 0;

		while(iTemp < v_length){
			if(VALUE.charAt(iTemp) == w_space){
			}
			else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
			}
		iTemp = iTemp + 1;
		} //End While
		return strTemp;
	} //End Function


	
	
	
	



////////////////////////////////////////////////////////////////////////////
