
var imageLoc = 'images/gui/';
var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_mac = (agt.indexOf("mac")!=-1);
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);
var is_opera = (agt.indexOf("opera") != -1);
var iePos  = appVer.indexOf('msie');
var is_mac_ie = false;
if (iePos !=-1) 
{
   is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
   is_major = parseInt(is_minor);
}
var is_ie = ((iePos!=-1) && (!is_opera));
if (is_mac && is_ie) {
	is_mac_ie = true;
}
var is_ie5up = (is_ie && is_minor >= 5);
var is_ie5_5up =(is_ie && is_minor >= 5.5);
var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
var nn4 = false;
if (document.layers) {
	nn4 = true;
}

function turnOnMyStore(imgName,imgPath) {
    document[imgName].src = imgPath;
}

function rollOver(imgName) {
	document[imgName].src = eval(imgName + "_over.src");
}

function rollOff(imgName) {
	document[imgName].src = eval(imgName + "_off.src");
}

function navOver(imgNum) {
	imgName = "nav" + imgNum;
	divName = "pos" + imgNum;
	var tmpImg = getImg(imgName, divName);

	tmpImg.src = eval(imgName + "_over.src");
}

function navOff(imgNum) {
	imgName = "nav" + imgNum;
	divName = "pos" + imgNum;
	var tmpImg = getImg(imgName, divName);
	tmpImg.src = eval(imgName + "_off.src");
}
function ResetBackground(x) {
        if (x == "0" ) { document.all.td1.background = 'images/gui/leftcap.png';}
        if (x == "1" ) { document.all.td2.background = 'images/gui/middlecap.png';}
        if (x == "2" ) { document.all.td3.background = 'images/gui/middlecap.png';}
        if (x == "3" ) { document.all.td4.background = 'images/gui/middlecap.png';}
        if (x == "4" ) { document.all.td5.background = 'images/gui/middlecap.png';}
        if (x == "5" ) { document.all.td6.background = 'images/gui/middlecap.png';}
		if (x == "6" ) { document.all.td7.background = 'images/gui/middlecap.png';}
        if (x == "9" ) { document.all.td9.background = 'images/gui/rightcap.png';}
        if (x == "c1" ) { document.all.CT1.background = 'images/gui/middlecap.png';}
        if (x == "c2" ) { document.all.CT2.background = 'images/gui/middlecap.png';}
        if (x == "c3" ) { document.all.CT3.background = 'images/gui/middlecap.png';}
        if (x == "c4" ) { document.all.CT4.background = 'images/gui/middlecap.png';}


}
function changeBackground(x) {
        if (x == "0" ) { document.all.td1.background = 'images/gui/leftcap_on.png';}
        if (x == "1" ) { document.all.td2.background = 'images/gui/middlecap_on.png';}
        if (x == "2" ) { document.all.td3.background = 'images/gui/middlecap_on.png';}
        if (x == "3" ) { document.all.td4.background = 'images/gui/middlecap_on.png';}
        if (x == "4" ) { document.all.td5.background = 'images/gui/middlecap_on.png';}
        if (x == "5" ) { document.all.td6.background = 'images/gui/middlecap_on.png';}
		if (x == "6" ) { document.all.td7.background = 'images/gui/middlecap_on.png';}
        if (x == "9" ) { document.all.td9.background = 'images/gui/rightcap_on.png';}
        if (x == "c1" ) { document.all.CT1.background = 'images/gui/middlecap_on.png';}
        if (x == "c2" ) { document.all.CT2.background = 'images/gui/middlecap_on.png';}
        if (x == "c3" ) { document.all.CT3.background = 'images/gui/middlecap_on.png';}
        if (x == "c4" ) { document.all.CT4.background = 'images/gui/middlecap_on.png';}



}
if (document.images) {

	//top nav preloads
        pic1= new Image(); 
        pic1.src=imageLoc + "leftcap_on.png";
        pic2= new Image(); 
        pic2.src=imageLoc + "middlecap_on.png";
        pic3= new Image(); 
        pic3.src=imageLoc + "rightcap_on.png";
    
	help_over = new Image();
	help_over.src = imageLoc + "help_on.png";
	help_off = new Image();
	help_off.src = imageLoc + "help.png";
		
	myacnt_over = new Image();
	myacnt_over.src = imageLoc + "myacnt_on.png";
	myacnt_off = new Image();
	myacnt_off.src = imageLoc + "myacnt.png";
		
	about_over = new Image();
	about_over.src = imageLoc + "about_on.png";
	about_off = new Image();
	about_off.src = imageLoc + "about.png";
		
	credits_over = new Image();
	credits_over.src = imageLoc + "credits_on.png";
	credits_off = new Image();
	credits_off.src = imageLoc + "credits.png";
		
	support_over = new Image();
	support_over.src = imageLoc + "support_on.png";
	support_off = new Image();
	support_off.src = imageLoc + "support.png";
		
	forums_over = new Image();
	forums_over.src = imageLoc + "forums_on.png";
	forums_off = new Image();
	forums_off.src = imageLoc + "forums.png";
		
	links_over = new Image();
	links_over.src = imageLoc + "links_on.png";
	links_off = new Image();
	links_off.src = imageLoc + "links.png";

	north_over = new Image();
	north_over.src = imageLoc + "move_n_on.png";
	north_off = new Image();
	north_off.src = imageLoc + "move_n.png";

	south_over = new Image();
	south_over.src = imageLoc + "move_s_on.png";
	south_off = new Image();
	south_off.src = imageLoc + "move_s.png";

	west_over = new Image();
	west_over.src = imageLoc + "move_w_on.png";
	west_off = new Image();
	west_off.src = imageLoc + "move_w.png";

	east_over = new Image();
	east_over.src = imageLoc + "move_e_on.png";
	east_off = new Image();
	east_off.src = imageLoc + "move_e.png";
}
function validated(string) {
    for (var i=0, output='', valid=" 1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*/?!@$&()+-='<>{}[]"; i<string.length; i++)
       if (valid.indexOf(string.charAt(i)) != -1)
          output += string.charAt(i)
    return output;
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

var logoutWin;
function logout(){ //Define arbitrary function to run desired DHTML Window widget codes
	logoutWin=dhtmlmodal.open("ajaxbox", "ajax", "logout.php", "LOGOUT:", "width=300px,height=100px,center=1,resize=0,scrolling=0")
	logoutWin.onclose=function(){
		window.location = "index.php"
		return true;
	}
}
function test(){
	logoutWin.hide()
}