var bname = navigator.appName;
var bversion = parseFloat(navigator.appVersion);

function resizeNS() {
if (bname == "Netscape") {window.location.reload();}
}

var base_dir = "images/";
var imgs = new Array('skills_on.gif','experience_on.gif','projects_on.gif','contact_on.gif');
       for (var i=0; i < imgs.length; i++) {
       var img = new Image();
       img.src = base_dir + imgs[i];
       }
function rollover(name1,img1){
	if (bname == "Netscape") {
		if (bversion < 5) {
			return false;
			}
		}
	if (bname == "Netscape") {
		if (bversion >= 5) {
			document.images[name1].src = base_dir + img1;
			}
		}
		else{
             document.images[name1].src = base_dir + img1;
             }
	}
function rollicon(name1,img1){
	if (bname == "Netscape") {
		if (bversion < 5) {
			return false;
			}
		}
	if (bname == "Netscape") {
		if (bversion >= 5) {
			document.images[name1].src = base_dir + img1;
			}
		}
		else{
             document.images[name1].src = base_dir + img1;
             }
	}
	
/*function rollbox {		 
	if (ie) {
	document.all(imageName).src = 'whatever.gif';
	}
	else {
	document.layers['layerName].document.images['imageName'].src = 'whatever.gif';
	}

}

function rollbox(ID,IMG,SRC) {
 if (navigator.appName == "Microsoft Internet Explorer") {
  document.all(IMG).src = SRC;
  }
 else {
 document.layers[ID].document.images[IMG].src = SRC;
 }
}*/

/*<a href="javascript:rollbox('layerName','imageName','imageSource');">kick me hard</a>*/


function popWin(url,width,height,posx,posy) {
var myWindow = window.open(url, "mainWin", 'resizable=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width='+width+',height='+height+',screenX='+posx+',screenY='+posy+',left='+posx+',top='+posy+'');
myWindow.focus()
}

if (navigator.appName == "Netscape") {
	if (parseInt(navigator.appVersion) < 5) {
		docRef = "document.layers['";
		docStyle = "']";
		ns4 = true;
		ns5 = false;
		ie = false;
		}
	else {
		docRef = "document.getElementById('";
		docStyle = "').style";
		ns4 = false;
		ns5 = true;
		ie = false
		}
	}
else {
	docRef = "document.all('";
	docStyle = "').style";
	ns4 = false;
	ns5 = false;
	ie = true;
}


if(ie || ns5) {
	with(document) {
	write("<style type=\"text/css\"> <!--");
	write("body {background-image : url(images/backg_1152x10001.gif); background-repeat : no-repeat;	margin : 0px;}");
	write(".contentLayer {position: absolute; font-family: verdana, arial, helvetica; font-size: 12px; color: #B3CC80; left: 205px; top: 300px; width: 400px; z-index: 1; display: none;}");
	write(".date {position: absolute; left: 500px; top: 47px; width: 120px; z-index: 2; font-family: verdana, arial, helvetica; font-size: 9.5px; color: #666666;}");
	write(".maincontent {position: absolute; left: 180px; top: 204px; width: 425px; z-index: 2;}");
	write(".projectsubnavLayer {position: absolute; left: 391px; top: 225px; width: 107px; z-index: 2;  display: none;}");
	write(".formfields {position: absolute; background-color: #CCCCCC; font-family: verdana, arial, helvetica; font-size: 11px;}");
	write(".boxesLayer {position: absolute; left: 30px; top: 260px; width: 136px; z-index: 1;}");
	write(".spacer {position: fixed; width: 100%; height: 100%; left : 0px; top: 0px; z-index: 0;}");
	write("a:hover {color: #CC6666;}");
	write("--></style>");
	}
}
else {
	with(document) {
	write("<style type=\"text/css\"> <!--");
	write("body {background-image : url(images/backg_1152x10001.gif); background-repeat : no-repeat;	margin : 0px;}");
	write(".contentLayer {position: absolute; font-family: verdana, arial, helvetica; font-size: 10px; color: #B3CC80; left: 205px; top: 320px; width: 355px; z-index: 1; visibility: hide;}");
	write(".date {position: absolute; left: 500px; top: 47px; width: 120px; z-index: 2; font-family: verdana, arial, helvetica; font-size: 9.5px; color: #666666;}");
	write(".maincontent {position: absolute; left: 180px; top: 204px; width: 425px; z-index: 2;}");
	write(".projectsubnavLayer {position: absolute; left: 391px; top: 225px; width: 107px; z-index: 2;  visibility: hide;}");
	write(".formfields {position: absolute; background-color: #CCCCCC; font-family: verdana, arial, helvetica; font-size: 11px;}");
	write(".boxesLayer {position: absolute; left: 30px; top: 260px; width: 136px; z-index: 1;}");
	write(".spacer {position: fixed; width: 100%; height: 100%; left : 0px; top: 0px; z-index: 0;}");
	write("a:hover {color: #CC6666;}");
	write("--></style>");
	}
}

var layers = new Array("boxes","contact_clickme");
var ProjectsLayer = new Array("skills_start","experience_start","projects_start","projects_lucid","projects_hotsocket","projects_kesler","projects_hubco","projects_jewelry","contactme_click","contactme_thankyou");
var Projects_subnavLayer = new Array("projects_subnav");


function showLayer(id,whichArray) {
	if (ie == true) {
	for (i=0; i<eval(whichArray+'.length'); i++) {
	object = docRef + eval(whichArray+'[i]') + docStyle;
	if (eval(object + ".display") == 'block')
		eval(object + ".display = 'none'");
	}
		object = docRef + id + docStyle;
		if (eval(object + ".display") == 'block') {
		eval(object + ".display = 'none'");
		}
		else {
		eval(object + ".display = 'block'");
		}
	}
	else if (ns4 == true) {
	for (i=0; i<eval(whichArray+'.length'); i++) {
	object = docRef + eval(whichArray+'[i]') + docStyle;
	if (eval(object + ".visibility") == 'show')
		eval(object + ".visibility = 'hide'");
	}
	object = docRef + id + docStyle;
		if (eval(object + ".visibility") == 'show') {
		eval(object + ".visibility = 'hide'");
		}
		else {
		eval(object + ".visibility = 'show'");
		}
	}
	else if (ns5 == true) {
	for (i=0; i<eval(whichArray+'.length'); i++) {
	object = docRef + eval(whichArray+'[i]') + docStyle;
	if (eval(object + ".display") == 'block')
		eval(object + ".display = 'none'");
	}
	object = docRef + id + docStyle;
		if (eval(object + ".display") == 'block') {
		eval(object + ".display = 'none'");
		}
		else {
		eval(object + ".display = 'block'");
		}
	}
	else {}
}

function hideIt(id,whichArray) {
	if (ie == true) {
		object = docRef + id + docStyle;
		if (eval(object + ".display") == 'block') {
		eval(object + ".display = 'none'");
		}
	}
	else if (ns4 == true) {
		object = docRef + id + docStyle;
		if (eval(object + ".visibility") == 'show') {
		eval(object + ".visibility = 'hide'");
		}
	}
	else if (ns5 == true) {
		object = docRef + id + docStyle;
		if (eval(object + ".display") == 'block') {
		eval(object + ".display = 'none'");
		}
	}
	else {}
}


/*Form Validation*/

function IsNumeric(val) {
        var checkOK = "0123456789";
        var checkStr = val;
        var allValid = true;
        var decPoints = 0;
        var allNum = "";
        for (i = 0;  i < checkStr.length;  i++) {
                ch = checkStr.charAt(i);
                for (j = 0;  j < checkOK.length;  j++)
                        if (ch == checkOK.charAt(j))
                                break;
                if (j == checkOK.length) {
                        allValid = false;
                        break;
                }
                allNum += ch;
        }
        return (allValid);
}

function VF(f, msg){
        if (f.value == ""){
                alert(msg);
                f.focus();
                return (false);
        }
        return(true);
}

function VF2(f, msg){
        if (f.selectedIndex == 0){
                alert(msg);
                f.focus();
                return (false);
        }
        return(true);
}

function validEmail(email) {
	invalidChars = " /:,;~`!#$%^&*()-+={}[]|><?"
	
	if (email == "") {
	return (false);
	}
	
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false;
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
	return (false);
	}
	if (email.indexOf("@",atPos+1) != -1) {
	return (false);
	}
	periodPos = email.indexOf(".",atPos+2)
	if (periodPos == -1) {
	return (false);
	}
	if (periodPos+3 > email.length)	{
	return (false);
	}
	return (true);
}

function FormValidator(theForm){
      	if (!VF(theForm.name, "Please enter your \"First Name\".")) {return (false);}
		if (!VF(theForm.phone, "Please enter your \"Last Name\".")) {return (false);}
		if (!VF(theForm.email, "Please enter your \"Email\".")) {return (false);}
		if (!validEmail(theForm.email.value)) {
			alert("Invalid email Address");
			theForm.email.focus();
			theForm.email.select();
			return (false);
		}
return (true);
}

