var d = document;

function getBrowserInfo() {
	alert("you're using " + navigator.appName + ", version " + navigator.appVersion)
}

function getCookie(c_name)
{
	if (document.cookie.length>0) { 
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start != -1) { 
			c_start = c_start + c_name.length + 1 
			c_end = document.cookie.indexOf(";",c_start)
			if (c_end == -1) c_end = document.cookie.length
			return unescape(document.cookie.substring(c_start,c_end))
		} 
	}
	return ""
}

function setCookie(c_name,value,expiredays) {
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : "; expires=" + exdate.toGMTString())
}

/*
function checkCookie() {
	username=getCookie('username')
	if (username!=null && username!="") {
		alert('Welcome again '+username+'!')}
	else {
		username=prompt('Please enter your name:',"")
		if (username!=null && username!="") {setCookie('username',username,365)}
	}
}
*/

function popup(url,w,h)
{
	newwindow=window.open(url,'name','height=' + h + ',width=' + w);
	if (window.focus) {newwindow.focus()}
}
function newWindow(mypage,myname,w,h,scroll,pos){
	if(pos=="random"){
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){
		LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
}

function hide(obj) {
	document.getElementById(obj).style.display = "none";
}

function show(obj) {
	document.getElementById(obj).style.display = "block";
}

function toggleDisplay(obj) {
	// this function needs testing...
	if (document.getElementById(obj).style.display = "block") {
		document.getElementById(obj).style.display = "none";
	} else {
		document.getElementById(obj).style.display = "block";
	}
}

// BEGIN REGULAR EXPRESSIONS

function isValid(pattern, str) {
	return pattern.test(str);
}

function stripChars(pattern, str) {
	return str.replace(pattern, "");
}

function replaceChars(pattern, str, replace) {
	return str.replace(pattern, replace);
}