var ary = null;
var ieah_window = null;
var ambush_window = null;
var rest_window = null;

function open_ieah() {
	var w = 800;
	var h = 600;
	if(!ieah_window || ieah_window.closed) {
		windowprops = "scrollbars,resizable,toolbar=yes,menubar=yes,statusbar=yes,location=yes,top=0,left=0,resizable=yes,screenX=0,screenY=0,outerHeight=" + h + ",outerWidth=" + w;
		ieah_window = window.open('http://www.ieah.com','AMBUSH',windowprops);
	}
}

function open_ambush() {
	var w = 800;
	var h = 600;
	if(!ambush_window || ambush_window.closed) {
		windowprops = "scrollbars,resizable,toolbar=yes,menubar=yes,statusbar=yes,location=yes,top=0,left=0,resizable=yes,screenX=0,screenY=0,outerHeight=" + h + ",outerWidth=" + w;
		ambush_window = window.open('http://www.ambushpestservices.com','AMBUSH',windowprops);
	}
}

function open_restaurant_demo() {
	var w = 800;
	var h = 600;
	if(!rest_window || rest_window.closed) {
		windowprops = "scrollbars,resizable,toolbar=yes,menubar=yes,statusbar=yes,location=yes,top=0,left=0,resizable=yes,screenX=0,screenY=0,outerHeight=" + h + ",outerWidth=" + w;
		rest_window = window.open('http://www.russotechnologies.com/cgi-bin/rest_demo/rest_demo.cgi','DEMO',windowprops);
	}
}

function open_art_glorious() {
   alert("Art Glorious is currently offline.");
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function FixCookieDate(date) {
	var base = new Date(0);
	var skew = base.getTime(); // dawn of (Unix) time - should be 0
	if (skew > 0)
		date.setTime (date.getTime() - skew);
}

function GetCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function SetCookie(name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

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";
	}
}
//
// Examples
//
//var expdate = new Date ();
//FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object!
//expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000)); // 24 hrs from now
//SetCookie ("ccpath", "http://www.hidaho.com/colorcenter/", expdate);
//SetCookie ("ccname", "hIdaho Design ColorCenter", expdate);
//SetCookie ("tempvar", "This is a temporary cookie.");
//SetCookie ("ubiquitous", "This cookie will work anywhere in this domain",null,"/");
//SetCookie ("paranoid", "This cookie requires secure communications",expdate,"/",null,true);
//SetCookie ("goner", "This cookie must die!");
//document.write (document.cookie + "<br>");
//DeleteCookie ("goner");
//document.write (document.cookie + "<br>");
//document.write ("ccpath = " + GetCookie("ccpath") + "<br>");
//document.write ("ccname = " + GetCookie("ccname") + "<br>");
//document.write ("tempvar = " + GetCookie("tempvar") + "<br>");

function isEmpty(inputStr) {
        if (inputStr == null || inputStr == "") {
                return true
        }
        return false
}

function submit_form_go() {
        if(isEmpty(window.document.forms[0].user.value)) {
                alert("Please enter a valid user name");
                return false;
        }
        if(window.document.forms[0].forgotpassword) {
            window.document.forms[0].forgotpassword.value="false";
        }
        window.document.forms[0].submit();
        return true;
}

function submit_form() {
   alert("Authorization Not Granted.");return false;
        if(isEmpty(window.document.forms[0].user.value)) {
                alert("Please enter a valid user name");
                return false;
        }
        if(window.document.forms[0].forgotpassword) {
            window.document.forms[0].forgotpassword.value="false";
        }
        return true;
}

function submit_rt_form() {
        if(isEmpty(window.document.forms[0].name.value)) {
                alert("Please enter your name.");
                return false;
        }
        if(isEmpty(window.document.forms[0].email.value)) {
                alert("Please enter a valid email address.");
                return false;
        }
        return true;
}

function submit_pr() {
        if(isEmpty(window.document.forms[0].name.value)) {
                alert("Please enter your name.");
                return false;
        }
        if(isEmpty(window.document.forms[0].email.value)) {
                alert("Please enter a valid email address.");
                return false;
        }
        return true;
}

function submit_forgot_form() {
        if(window.document.forms[0].forgotpassword) {
            window.document.forms[0].forgotpassword.value="true";
        }
        if(isEmpty(window.document.forms[0].email.value)) {
                alert("Please enter a valid email address.");
                return false;
        }
        window.document.forms[0].submit();
        return true;
}

function open_new_window(target_page, postfix) {
	if(!target_page) {
		return false;
	}

	var mywindow = window.open(target_page, 'CHILD_WINDOW'+postfix,'scrollbars,resizable,toolbar=NO,menubar=YES,statusbar=NO,HEIGHT=425,WIDTH=785');
	mywindow.focus();
	mywindow.moveTo(20,20);
}


function startup(html_page_name) {
   var fp = GetCookie("fp");
   if(fp) {
   	ary = fp.split("|");

   	if( (!isEmpty(ary[0])) && (!isEmpty(ary[1])) ) {
   		window.document.forms[0].user.value = ary[0];
   		window.document.forms[0].pass.value = ary[0];
   		window.document.forms[0].sess.value = ary[1];
   	}
   }
   if(document.forms[0].button) {
      document.forms[0].button.focus();
   }
}

