function openWin(file,winname, w, h)
{	details="top=0,left=0,width="+w+",height="+h+",status=no,";
	details += "resizable=yes,scrollbars=yes,menubar=no,location=no";

	var myWin = window.open(file, winname, details);
	myWin.focus();
}

function showHideDiv(tagname, showhide)
{
    if (showhide == 1)
    {
        //document.all[tagname].style.display = "block"
        document.getElementById(tagname).style.display='block';
    }

    if (showhide == 0)
    {
        //document.all[tagname].style.display = "none"
        document.getElementById(tagname).style.display='none';
    }

}

function validPhoneNumber(thefield)
{
	strobj = new String(thefield.value);
	value = new String (strobj.replace(/\D*/g, ""));

	if(value.length == 10)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function maskPhoneNumber(thefield)
{
	strobj = new String(thefield.value);
	value = new String (strobj.replace(/\D*/g, ""));

	if(value.length > 3)		
	{
		areacode = value.substr(0,3);
		n3 = value.substr(3,3);

		newvalue = areacode + "-";	
		newvalue = newvalue + n3;

		if(value.length > 6)
		{
			n4 = value.substr(6,4);
			newvalue = newvalue + "-" + n4; 
		}

		thefield.value = newvalue;
	}
	else
	{
		thefield.value = value;
	}
}
// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
	begin = dc.indexOf(prefix);
	if (begin != 0) return null;
	} else
	begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" + 
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0)
		date.setTime(date.getTime() - skew);
}

var form_num = 0;
function checkFormNumber()
{
	if(document.forms[0].name == "searchform")
		form_num = 1;
	else
		form_num = 0;
}

function addUserFavorite()
{
	var linkto = 'favorites.php?cmd=add';
	var txt = null;
	txt = prompt('Enter Link Text:', 'Enter Text Here');

	if(txt != null)
	{
		linkto += '&txt='+ txt + '&url='+ window.location;
		// window.location = linkto;
		window.location.replace(linkto);
	}
}

