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


function CheckEmptyString(txt,msg)
{
	if (Trim(txt.value) =="") 
		{
			alert(msg);
			txt.value="";
			txt.focus();   
			return false;
		}

}

function CheckDropdownSelection(txt,msg)
{
	if (Trim(txt.value) =="0") 
		{
			alert(msg);
			txt.focus();   
			return false;
		}

}

function CheckNumberString(txt,msg)
{
	if (Trim(txt.value) !="") 
	{
		if (isNaN(Trim(txt.value)))
		{
			alert(msg);
			txt.value="";
			txt.focus();   
			return false;
		}
	}

}

function CheckYesNo(rdo,msg)
{
	if (rdo[0].checked == false && rdo[1].checked == false)
		{
			alert(msg);
			rdo[0].focus();   
			return false;
		}

}

function numeric()
{  
	if (((event.keyCode<48)  ||(event.keyCode>57)) && (event.keyCode != 9)&& (event.keyCode != 13))
	{		
		event.keyCode="";
		return false;
	}	
	return false;
}


function TogglePanel_Header(img,Panel,tr1,tr2)

		{
		
			//divHeading.innerHTML 
			 
			if (Panel.status == false)
			{
				
				
				//tdmenu.width="20%";
				tr1.style.height="5%"
				tr2.style.height="95%"
				Panel.style.display="block";	
				Panel.status =true;
				img.src="../Images/Minus.gif";
			}
			else
			{
				
				tr1.style.height="0%"
				tr2.style.height="100%"
				//tdmenu.width="0%";
				Panel.style.display="none";
				Panel.status =false;
				img.src="../Images/plus.gif";				
			}
		}		
function TogglePanel_Menu(img,Panel,tdmenu,SpanPanel)
		{
			//divHeading.innerHTML 
			 
			if (Panel.status == false)
			{
				tdmenu.style.width="20%";
				//SpanPanel.innerHTML="Hide"; 
				//tdmenu.width="20%";
				Panel.style.display="block";	
				Panel.status =true;
				img.src="../Images/Minus.gif";
			}
			else
			{
				//SpanPanel.innerHTML="Show"; 
				tdmenu.style.width="0%";
				//tdmenu.width="0%";
				Panel.style.display="none";
				Panel.status =false;
				img.src="../Images/plus.gif";				
			}
		}
		
function TogglePanel_Panel(img,Panel)
		{
			//divHeading.innerHTML 
			 
			if (Panel.style.display=="none")
			{
				
				
				//tdmenu.width="20%";
				Panel.style.display="block";	
				Panel.status =true;
				img.src="../Images/Minus.gif";
			}
			else
			{
				
				//tdmenu.width="0%";
				Panel.style.display="none";
				Panel.status =false;
				img.src="../Images/plus.gif";				
			}
		}		
		
function checkEmailAddress(txt,msg) 
		{
				if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(txt.value))
				{
					return (true);
				}
			alert(msg);
			txt.select();
			return (false);
		}		
function CheckFieldLength(txt,len,msg)
	{
		if (Trim(txt.value).length>eval(len))
		{
			alert(msg);
			txt.focus();
			return false;
		}
			return true;
	}		
	
	
function ConvertData()	
{

	for (i=0;i<document.all.length;i++)
	{
		
		if(document.all.item(i).type=="text" || document.all.item(i).type=="textarea" || document.all.item(i).type=="hidden")
		{
			convert(document.all.item(i),document.all.item(i).value,"'","''");
		}
	}  
}



function convert(txt,val,convertto,convertby)
{
	
	var str,str1;
	str="";
	var i;
	if (val.length>0)
	{
		while(val.indexOf(convertto)>0)
		{
			str1=val.substring(0,val.indexOf(convertto)+convertto.length)
			val=val.replace(str1,"");
			str=str + str1.replace(convertto,convertby)
			
			
		}
		str=str+val;
		txt.value=Trim(str);
	} 
}	
function TogglePanel_LeftMenu(img,Panel)
		{
			
			//divHeading.innerHTML 
			 
			if (Panel.style.display=="none")
			{
				
				
				//tdmenu.width="20%";
				Panel.style.display="block";	
				Panel.status =true;
				img.src="../Images/Minus_menu.gif";
			}
			else
			{
				
				//tdmenu.width="0%";
				Panel.style.display="none";
				Panel.status =false;
				img.src="../Images/plus_menu.gif";				
			}
		}		
function ToggleAll_LeftMenu(img,imgoption1,imgoption2,imgoption3,imgoption4,imgoption5,imgoption6,imgoption7,divoption1,divoption2,divoption3,divoption4,divoption5,divoption6,divoption7)
{
	
	if (img.status==true)
	{
		img.status=false;
		divoption1.style.display="block";
		divoption2.style.display="block";
		divoption3.style.display="block";
		divoption4.style.display="block";
		divoption5.style.display="block";
		divoption6.style.display="block";
		divoption7.style.display="block";
		TogglePanel_LeftMenu(imgoption1,divoption1);
		TogglePanel_LeftMenu(imgoption2,divoption2);
		TogglePanel_LeftMenu(imgoption3,divoption3);
		TogglePanel_LeftMenu(imgoption4,divoption4);
		TogglePanel_LeftMenu(imgoption5,divoption5);
		TogglePanel_LeftMenu(imgoption6,divoption6);
		TogglePanel_LeftMenu(imgoption7,divoption7);
		img.src="../Images/plus_menu.gif";
	}
	else
	{
		
		
		img.status=true;
		divoption1.style.display="none";
		divoption2.style.display="none";
		divoption3.style.display="none";
		divoption4.style.display="none";
		divoption5.style.display="none";
		divoption6.style.display="none";
		divoption7.style.display="none";
		TogglePanel_LeftMenu(imgoption1,divoption1);
		TogglePanel_LeftMenu(imgoption2,divoption2);
		TogglePanel_LeftMenu(imgoption3,divoption3);
		TogglePanel_LeftMenu(imgoption4,divoption4);
		TogglePanel_LeftMenu(imgoption5,divoption5);
		TogglePanel_LeftMenu(imgoption6,divoption6);
		TogglePanel_LeftMenu(imgoption7,divoption7);
		
		img.src="../Images/Minus_menu.gif";
	}
}
function RevertXMLCharacters()	
{

	for (i=0;i<document.all.length;i++)
	{
		if(document.all.item(i).type=="text" || document.all.item(i).type=="textarea" || document.all.item(i).type=="hidden")
		{
			
			convert(document.all.item(i),document.all.item(i).value,"&amp;","&");
			convert(document.all.item(i),document.all.item(i).value,"&lt;","<");
			convert(document.all.item(i),document.all.item(i).value,"&gt;",">");
			convert(document.all.item(i),document.all.item(i).value,"&quot;","\"");
			convert(document.all.item(i),document.all.item(i).value,"&#39;&#39;","''");
			convert(document.all.item(i),document.all.item(i).value,"''","'");
			
		}
	}  
}
function FormatPhone(txt)
	{

		if (Trim(txt.value)!="")
		{
			var str;
			str=txt.value;
			str=str.replace("(","");
			str=str.replace(")","");
			str=str.replace(" ","");
			str=str.replace("-","");
			txt.value=str;
		}
		
	}
