////////// STYLESHEET RELATED SCRIPTS //////////	

// RELINK EXTERNAL CSS ON RESIZE
	if (document.layers) {
		origWidth = innerWidth;
		origHeight = innerHeight;
		} 

	if (document.layers) onResize = reloadPage;	
	
	function reloadPage() {
		if (innerWidth != origWidth || innerHeight != origHeight) {
			location.reload();
			} else {
			}
		}

// ASSIGN CORRECT STYLESHEET

	if (navigator.userAgent.indexOf("Win") != -1) {
		document.write ('<link rel="stylesheet" href="../sfz/resources/css/win.css" type="text/css">') 
		} else {
		document.write ('<link rel="stylesheet" href="../sfz/resources/css/mac.css" type="text/css">')
		}


// STYLE SHEETS BASED ON BROWSER
	if (navigator.userAgent.indexOf("Win") != -1) {       // windows
		if (navigator.appName.indexOf('Microsoft Internet Explorer') != -1) {
			// IE
			document.write ('<link rel="stylesheet" href="../sfz/resources/css/winIE.css" type="text/css">') 
			}
		else {
			//NN
			document.write ('<link rel="stylesheet" href="../sfz/resources/css/winNN.css" type="text/css">') 
			}
			
		} else {     //Mac
			
		if (navigator.appName.indexOf('Microsoft Internet Explorer') != -1) {
			document.write ('<link rel="stylesheet" href="../sfz/resources/css/macIE.css" type="text/css">') 
			// IE
			} else { 
			document.write ('<link rel="stylesheet" href="../sfz/resources/css/macNN.css" type="text/css">') 
			//NN
			}
			
		}







////////// IMAGE SWAPPING SCRIPT //////////

//SIDE HEADS
var bands = "works";
var contact = "discography";
var dist = "productions";
var excl = "purchase";

// TOP SUBLINKS
var gh = "gh";
var newrel = "newrel";
var news = "news";
var store = "store";
var tour = "tour";
var r45 = "45";
var a45 = "a45";
var ep = "ep";
var lp = "lp";
var alp = "alp";
var tshirt = "tshirt";
var misc = "misc";

// necesary

if (document.images) {
	relPath = "../sfz/resources/gifs/interface/"


	imag = new Array();
	
	imag[0] = relPath + "works.gif";
	imag[1] = relPath + "works-o.gif";			
	imag[2] = relPath + "discography.gif";
	imag[3] = relPath + "discography-o.gif";
	imag[4] = relPath + "productions.gif";
	imag[5] = relPath + "productions-o.gif";			
	imag[6] = relPath + "purchase.gif";
	imag[7] = relPath + "purchase-o.gif";			



	imag[8] = relPath + "biography.gif";
	imag[9] = relPath + "biography-o.gif";	
	imag[10] = relPath + "resume.gif";	
	imag[11] = relPath + "resume-o.gif";	
	imag[12] = relPath + "news.gif";
	imag[13] = relPath + "news-o.gif";	
	imag[14] = relPath + "photos.gif";
	imag[15] = relPath + "photos-o.gif";	
	imag[16] = relPath + "press.gif";
	imag[17] = relPath + "press-o.gif";	
	imag[18] = relPath + "contact.gif";
	imag[19] = relPath + "contact-o.gif";



//	imag[20] = relPath + "main-news-d.gif";
//	imag[21] = relPath + "main-store.gif";
//	imag[22] = relPath + "main-store-o.gif";
//	imag[23] = relPath + "main-store-d.gif";
//	imag[24] = relPath + "main-tour.gif";
//	imag[25] = relPath + "main-tour-o.gif";
//	imag[26] = relPath + "main-tour-d";
//
//
//// LEFT
//
//	imag[27] = leftPath + "format45s.gif";
//	imag[28] = leftPath + "format45s-o.gif";
//	imag[29] = leftPath + "formatEPs.gif";
//	imag[30] = leftPath + "formatEPs-o.gif";
//	imag[31] = leftPath + "formatLPs.gif";
//	imag[32] = leftPath + "formatLPs-o.gif";
//	imag[33] = leftPath + "formatTshirt.gif";
//	imag[34] = leftPath + "formatTshirt-o.gif";
//	imag[35] = leftPath + "formatMisc.gif";
//	imag[36] = leftPath + "formatMisc-o.gif";
//	imag[37] = relPath + "browseBack-o.gif";
//	imag[38] = relPath + "browseFor.gif";
//	imag[39] = relPath + "browseFor-o.gif";
//	imag[40] = relPath + "back.gif";
//	imag[41] = relPath + "back-o.gif";	
//	imag[42] = relPath + "story.gif";
//	imag[43] = relPath + "story-o.gif";
//	imag[44] = relPath + "discography.gif";
//	imag[45] = relPath + "discography-o.gif";
//	imag[46] = relPath + "press.gif";
//	imag[47] = relPath + "press-o.gif";
//	imag[48] = relPath + "photos.gif";
//	imag[49] = relPath + "photos-o.gif";
//	imag[60] = relPath + "order.gif";
//	imag[61] = relPath + "order-o.gif";
//	imag[62] = relPath + "order-d.gif";
//	imag[63] = relPath + "check.gif";
//	imag[64] = relPath + "check-o.gif";
//	imag[65] = relPath + "check-d.gif";
//	imag[66] = relPath + "view.gif";
//	imag[67] = relPath + "view-o.gif";
//	imag[68] = relPath + "view-d.gif";	
		


	
	im = new Array();
	for (var i = 0; i < imag.length; i++) {
		im[i] = new Image; im[i].src = imag[i]; 
		}
	}

function swapImage(imgName, num) {
	if (document.images && imgName) {
		imgName.src = im[num].src;	
		}
	return;	
	}




//	FIND DOM
var isDHTML = 0; var isLayers = 0; var isAll = 0; var isID = 0;

if (document.getElementById) {isID = 1; isDHTML = 1;} 
else { if (document.all) {isAll = 1; isDHTML = 1;}
else { 	browserVersion = parseInt(navigator.appVersion);
if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
}}


function findDom(objectID) {
		withStyle = '1' // I added this to force the with style....
		if (withStyle == 1) {
				if (isID) { return (document.getElementById(objectID).style); }
				else { if (isAll) { return (document.all[objectID].style); }
				else { if (isLayers) { return (document.layers[objectID]);}
				};}
			} else {
				if (isID) { return (document.getElementById(objectID)) ; }
				else { if (isAll) { return (document.all[objectID]); }
				else {if (isLayers) { return (document.layers[objectID]);  }
				};}
			}
	}

////// NAVIGATION SUBLINKS //////////


// TOGGLES VISIBILITY OF CORRECT IDs
function  showMenu () {

	theDiv = new Array();
	theDiv[0] = "disc";
	theDiv[1] = "select";			

	for (i=0; i<2; i++) {

		var dom = findDom(theDiv[i]);
		state = dom.visibility

//alert (dom)		
		if (state == 'hidden' || state == 'hide') { 
			dom.visibility = 'visible';	return false
			 } else { 
			 if (state == 'visible' || state == 'show') {
				dom.visibility = 'hidden'; return false
				}
			}
		
		}
		
	}



// TOGGLES VISIBILITY OF CORRECT IDs
function  hideDiv (theMenu) {
	theDiv = "birthday";
//alert (theDiv)
	
	var dom = findDom(theDiv);
	state = dom.visibility

	if (state == 'hidden' || state == 'hide') { 
		dom.visibility = 'visible';	return false
		 } else { 
		 if (state == 'visible' || state == 'show') {
		 	dom.visibility = 'hidden'; return false
		 	}
		}
		
	}











// VIEW BIGGER PICTURE POPUP FOR PHOTO GALLERY
function photoOpen(fileName, width, height, altText) {
	thePhoto = "../gh/content/photos/" + fileName 
	size="scrollbars=no,status=no,width="+width+",height="+height
		
	newWin = window.open ('', 'newWin', size)
	newWin.document.write("<html><head><title>" + altText + "<\/title><script type='text/javascript'>X = 0; Y = 0; self.moveTo(X,Y);<\/script><\/head>")
	newWin.document.write("<body bgcolor='#ffffff'><div style='position:absolute; left:0px; top:0px;'><a href=\"JAVASCRIPT:window.close()\"><img width='" + width + "' height='" +  height + "' border=0 src='" + thePhoto + "' alt='" + altText + "'><\/a><\/body><\/html>")
	}			



//CHECK VALIDITY OF EMAIL ADDRESS
function checkEmail(emu) {

	var eAdd = emu.email.value
	var inValChar = "/:,;";
	var reqChar = eAdd.indexOf("@",1);
	
	// If line is blank
	if (eAdd == "") {
		alert("The email address field can not be left blank.");
//				document.emu.email.focus(); document.emu.email.select();			
		sendFlag="empty"; return false;
		} else {
		sendFlag="OK";
		}
	
	// check for invalid characters
	for (i = 0; i<inValChar.length; i++) {
		badChar = inValChar.charAt(i);

		if (eAdd.indexOf(badChar,0) > -1) {
			sendFlag = "inval";
			}  else {
			sendFlag="OK";
			}
		}
		
	// Make sure it has a "@" sign
	if (reqChar == -1) {
		sendFlag = "inval";
		} else {
		sendFlag="OK";
		}
		
	
	//If line doesn't contain a valid email address
	if (sendFlag == "inval") {
		alert("Please enter a valid email address.")
//				document.emu.email.focus(); document.emu.email.select();
		sendFlag="deny"; return false;
		} else {
		sendFlag="OK";
		}	
		


	if (sendFlag == "OK")	{
		emailString = "&email=" + eAdd
		returnString = "&return=" + emu.returnPage.value	
		typeString = "&type=" + emu.type.value

		dataToSend = "../../../../../cgi-bin/ghOM.cgi?" + emailString + returnString + typeString
	
		re = /\s/g;								// Sets the matching pattern to find all spaces
		theURL=dataToSend.replace(re, "%20");	// Replaces all spaces with the hex equiv.
	
		location.href = theURL;

		return false;
		}
	}			
	



function downPic (thePic) {
	
	var thePath = "<html><head><title>Photo of Erik Lindgren</title></head><body bgcolor='#ffffff'><div style='position:absolute; top:0px; left:0px; text-align:center;'><img src='content/photos/EL-" + thePic + ".jpg' alt='Photo of Erik Lindgren' style='margin-bottom:10px;'><div style='position:absolute; top:10px; left:10px; z-index:10; font-family:helvetica,arail,san-serif; font-size:10px; font-weight:bold; color:#fff; background-color:#000; padding:5px;'>Control-click or right-click to download the photo. Larger photos will be cut off by the window size. (This text is not on the photo.)</span></div></body></html>";
	
	
	newWin = window.open ('', 'newWin', 'scrollbars=no,status=yes,width=800,height=600');
	newWin.document.write (thePath);
	newWin.window.status = "Control-click or right-click to download the photo."


	
	}






