	ns4 = (document.layers) ?1:0;
	ie4 = (document.all) ?1:0;
	dom = (document.getElementById) ?1:0;	

	if (ns4) document.captureEvents(Event.KEYDOWN);

	var xmlRequest=false;
	var browser;
	//var rootpath="http://pcd-17/soundboard/";
	var rootpath="http://soundboard.com/";
	var chkFlag=false;
	var winhandle=null;
	
	if (window.ActiveXObject)
	{	
		/******************
		Check jscript version
		When writing a script for a Web page, always place conditional compilation code 
		in comments. This allows hosts that do not support conditional compilation to 
		ignore it. 
		******************/
		//turn on conditional compilation
		/*@cc_on
		@if (@_jscript_version >= 5)
		try 
		{
			xmlRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try
			{
				xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (E)
			{
				xmlRequest = false;
			}
		}
	
		@else
			xmlRequest = false;
		@end @*/
		
		browser="IE";
	}
	
	else if(window.XMLHttpRequest)
	{
		
		/*if (window.netscape && netscape.security && netscape.security.PrivilegeManager.enablePrivilege) 
		{
		netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead UniversalBrowserWrite');
		}
		*/
		
		if (!xmlRequest && typeof XMLHttpRequest != 'undefined')
		{
			try 
			{
				xmlRequest = new XMLHttpRequest();
			}
			catch (e) 
			{
				xmlRequest = false;
			}
		}			
		
		browser="NS";
	}	

	function callXML(method,pageUrl,syncMode)
	{
		xmlRequest.open(method, pageUrl, syncMode);
		xmlRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlRequest.send(null);
	}

	function callXMLAsync(method,pageUrl)
	{
		xmlRequest.open(method, pageUrl, true);
		xmlRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	}

	function stripXmlTags(StrResponse)
	{
		var str2="xml version=\"1.0\" encoding=\"utf-8\"";
		var str3="";
		var newstr = StrResponse.replace(new RegExp(str2,'g'),str3);
		
		var str2="<br />";
		var str3="|";
		var newstr = newstr.replace(new RegExp(str2,'g'),str3);
		
		str2="<";
		var str3="";
		
		newstr = newstr.replace(new RegExp(str2,'g'),str3);
		
		var str2=">";
		str3="";
		
		newstr = newstr.replace(new RegExp(str2,'g'),str3);
		var finalstr = newstr.split("??");
		return finalstr[1];
	}

	function clearDropdown(objDropdown)
	{
		for(i=objDropdown.options.length-1;i>=0;i--)
				objDropdown.remove(i);
	}

	function onlyDigits(e) 
	{			
		var Code = (ie4) ? window.event.keyCode : e.which;				
		if(!(Code==8) && !(Code==0) && !(Code>=48 && Code<=57))
		{
			if(ie4)
				window.event.keyCode=0;
			else
				return false;
		}
	}
	
	function onlyFloats(e) 
	{
		
		var Code = (ie4) ? window.event.keyCode : e.which;				
		//window.alert(Code);
		if(!(Code==46) && !(Code==8) && !(Code==0) && !(Code>=48 && Code<=57))
		{
			if(ie4)
				window.event.keyCode=0;
			else
				return false;			
		}
	}
				
	function onlyChars(e) 
	{
			
		var Code = (ie4) ? window.event.keyCode : e.which;				
		//window.alert(Code);return;
		if(!(Code==8) && !(Code==0) && !(Code==32) && !(Code>=65 && Code<=90) && !(Code>=97 && Code<=122))
		{
			if(ie4)
				window.event.keyCode=0;
			else
				return false;
		}
	}

	function onlyAlpha(e)
	{
		var Code = (ie4) ? window.event.keyCode : e.which;				
		//window.alert(Code);
		if(!(Code==8 || Code==0 || Code==95 || Code==32 || (Code>=48 && Code<=57) || (Code>=65 && Code<=90) || (Code>=97 && Code<=122)))
		{
			if(ie4)
				window.event.keyCode=0;
			else
				return false;
		}
		//95 = underscore,32 space bar
	}
	
	function onlyUsername(e)
	{
		var Code = (ie4) ? window.event.keyCode : e.which;				
		//window.alert(Code);
		if(!(Code==8 || Code==0 || Code==95 || (Code>=48 && Code<=57) || (Code>=65 && Code<=90) || (Code>=97 && Code<=122)))
		{
			if(ie4)
				window.event.keyCode=0;
			else
				return false;			
		}
		//95 = underscore,32 space bar,45 - hypen
	}

	function winopen(winpath,width,height,boolwinbars,boolscrollbars)
	{
		if(boolwinbars=='undefined')
			boolwinbars=false;

		if(boolscrollbars=='undefined')
			boolscrollbars=false;

		var winname="newwin";
		var winbars = 'directories='+boolwinbars+',location='+boolwinbars+',menubar='+boolwinbars+',status='+boolwinbars+',titlebar='+boolwinbars+',toolbar='+boolwinbars
		var winoptions = 'scrollbars='+boolscrollbars+',top=0,left=0,resizeable=yes,width='+width+',height='+height;
		var winfeatures = winbars + "," + winoptions;
		var winhandle = window.open(winpath,winname,winfeatures);
		winhandle.focus();
	}

	function topcenterwin(winpath,width,height,boolwinbars,boolscrollbars)
	{
		if(boolwinbars=='undefined')
			boolwinbars=false;

		if(boolscrollbars=='undefined')
			boolscrollbars=false;

		var winname="newwin";
		var winbars = 'directories='+boolwinbars+',location='+boolwinbars+',menubar='+boolwinbars+',status='+boolwinbars+',titlebar='+boolwinbars+',toolbar='+boolwinbars
		var winoptions = 'scrollbars='+boolscrollbars+',top=0,left='+(screen.width/2-(width/2))+',resizeable=yes,width='+width+',height='+height;
		var winfeatures = winbars + "," + winoptions;
		winhandle = window.open(winpath,winname,winfeatures);
		if(window.focus)
			winhandle.focus();
	}

	function centerwin(winpath,width,height,boolwinbars,boolscrollbars)
	{
		if(boolwinbars=='undefined')
			boolwinbars=false;

		if(boolscrollbars=='undefined')
			boolscrollbars=false;

		var winname="newwin";
		var winbars = 'directories='+boolwinbars+',location='+boolwinbars+',menubar='+boolwinbars+',status='+boolwinbars+',titlebar='+boolwinbars+',toolbar='+boolwinbars
		var winoptions = 'scrollbars='+boolscrollbars+',top='+(screen.height/2-(height/2))+',left='+(screen.width/2-(width/2))+',resizeable=yes,width='+width+',height='+height;
		var winfeatures = winbars + "," + winoptions;
		var winhandle = window.open(winpath,winname,winfeatures);
		winhandle.focus();
	}

	function openzerowin(path)
	{
		var myBars = 'directories=yes,location=yes,maximize=yes,menubar=yes,status=yes,titlebar=yes,toolbar=yes';
		var myOptions = 'scrollbars=no,top='+(screen.height)+',left='+(screen.width)+',resizeable=no,width=1,height=1';
		//var myOptions = 'scrollbars=yes,top=1,left=1,resizeable=yes,width=780,height=780';
		var myFeatures = myBars + "," + myOptions;
		var x = window.open(path,"DLwin",myFeatures);
		x.focus();		
	}

	function openfullwin(path)
	{
		var winname="newwin";
		var myBars = 'directories=yes,location=yes,menubar=yes,status=yes,titlebar=yes,toolbar=yes';
		var myOptions = 'scrollbars=yes,top=1,left=1,resizeable=yes,width='+screen.width+',height=730';
		var myFeatures = myBars + "," + myOptions;
		var x = window.open(path,winname,myFeatures);
		x.focus();	
	}


	function getrandomnumber()
	{
		return Math.floor(Math.random()*1500)
	}
	
	function replacenewline(str)
	{
		str.replace(/\n/g, "<br />");
		return str;
	}

	function removecomma(str)
	{
		str.replace(/,/g, "");
		return str;
	}

	function isarray(obj) 
	{
		//return (obj.constructor.toString().indexOf("Array") != -1) ? true : false;
		return obj.constructor == Array;
	}


	function checkdate(tmpdate)
	{

		var splitdate;
		splitdate=tmpdate.split("/");
		
		if(isNaN(splitdate[0]) || isNaN(splitdate[1]) || isNaN(splitdate[2]))
		{
			window.alert("Invalid Date");
			return false;
		}
		
		dy=parseInt(splitdate[0],10);
		mn=parseInt(splitdate[1],10);
		yr=parseInt(splitdate[2],10);
		
		if(dy<1 || dy>31)
		{
			window.alert("Invalid date");
			return false;
		}

		if(mn<1 || mn>12)
		{
			window.alert("Invalid month");
			return false;
		}
		
		if(mn==1 || mn==3 || mn==5 || mn==7 || mn==8 || mn==10 || mn==12)
		{
			if(dy<1 || dy>31)
			{
				window.alert("Invalid date");
				return false;
			}
		}

		else if(mn==4 || mn==6 || mn==9)
		{
			if(dy<1 || dy>30)
			{
				window.alert("Invalid date");
				return false;
			}
		}
		
		else if(mn==2)
		{
			if(dy<1 || dy>29)
			{
				window.alert("Invalid date");
				return false;
			}
			
			if(dy==29 && (!checkleapyear(yr)))
			{
				window.alert("Invalid Leap Year date")
				return false;
			}
	
		}
		
		return true;
	}
			
	function checkleapyear(yr)
	{
		year = parseInt(yr,10);
		return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? true : false;
	}

	function comparedates(ttdate1,ttdate2,flagAlert)
	{

		tdate1=ttdate1.split("/");
		tdate2=ttdate2.split("/");
						
		sdy=parseInt(tdate1[0],10);
		smn=parseInt(tdate1[1],10);
		syr=parseInt(tdate1[2],10);

		edy=parseInt(tdate2[0],10);
		emn=parseInt(tdate2[1],10);
		eyr=parseInt(tdate2[2],10);

		if(syr>eyr)
		{
			if(flagAlert == 'undefined')
				window.alert("From Date can't be after Till Date");
			return false;
		}
		if(syr==eyr)
		{
			if(smn>emn)
			{
				if(flagAlert == 'undefined')
					window.alert("From Date can't be after Till Date");
				return false;
			}
		}

		if(syr==eyr && smn==emn)
		{
			if(sdy>edy)
			{
				if(flagAlert == 'undefined')
					window.alert("From Date can't be after Till Date");
				return false;
			}
		}
		return true;
	}

	function checkemail(email)
	{		
		return (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)))? false : true;
	}

	function setcheckboxclass(classname)
	{
		var x=document.getElementsByTagName('input')
		for (i=0; i<x.length;i++)
			if (x[i].type=='checkbox')
				x[i].className=classname;		
	}

	function setradioclass(classname)
	{
		var x=document.getElementsByTagName('input')
		for (i=0; i<x.length;i++)
			if (x[i].type=='radio')
				x[i].className=classname;		
	}
	
	function checkall(formname)
	{
		for(i=0;i<document.forms[formname].length;i++)
		if(document.forms[formname].elements[i].type=="checkbox")
			document.forms[formname].elements[i].checked=!chkFlag;
		chkFlag=!chkFlag;
	}