var artists = new Array();
var artistsText = new Array();

// Artist list in initArtists.js

function randomArtist(){
	pageID=Math.round(Math.random()*(artists.length-1));
	//location="artists.html?pageID=0";
	location="artists.html?pageID="+pageID;
}

function artistNav(active,sectionPage){
var navString = "";
	for (i=0;i<artists.length;i++){
		if (i==active) {
			selected="<span style='color:white;font-weight:bold;'>";
			selectedEnd="</span>";
			selectedBox="style='background-color:orange'";
			onmouseout="";}
		else {
			selected="";
			selectedEnd="";
			selectedBox="";
			onmouseout="this.parentNode.parentNode.firstChild.firstChild.style.backgroundColor=\"\";"}
		navString=navString+"<tr><td style='padding-right:4px'><div class='box' "+selectedBox+"><!-- --></div></td><td><a onfocus='this.blur()' href='"+sectionPage+".html?pageID="+i+"' onmouseover='this.parentNode.parentNode.firstChild.firstChild.style.backgroundColor=\"orange\";this.firstChild.className=\"white\"' onmouseout='"+onmouseout+"this.firstChild.className=\"gray\"'><span class='gray'>"+selected+artists[i]+selectedEnd+"</span></a></td></tr><tr><td colspan='2' class='artistNavHeight'></td></tr>"
	}
	document.getElementById('artistList').innerHTML="<table cellpadding='0' cellspacing='0' class='artistNavCol'>"+navString+"</table>";
}

function showImages(){
	document.getElementById('mainImage').src=jsUrl+"/1.jpg";
	document.getElementById('img1').src=jsUrl+"/1small.jpg";
	document.getElementById('img2').src=jsUrl+"/2small.jpg";
	document.getElementById('img3').src=jsUrl+"/3small.jpg";
	document.getElementById('img4').src=jsUrl+"/4small.jpg";

}

function writeText(artistID){
	document.getElementById('artistName').innerHTML=artists[artistID];
	document.getElementById('artistBio').innerHTML=artistBio;
	document.getElementById('artistCV').innerHTML=artistCV;
	document.getElementById('imgText').innerHTML=imgText1;
	document.getElementById('img1_text').innerHTML=imgText1;
	document.getElementById('img2_text').innerHTML=imgText2;
	document.getElementById('img3_text').innerHTML=imgText3;
	document.getElementById('img4_text').innerHTML=imgText4;
}


function writeMenu(){

	var menuString='<A HREF="index.html"><img onfocus="this.blur()"src="images/showroom-off.gif" border="0" onmouseover="this.src=\'images/showroom-on.gif\'" onmouseout="this.src=\'images/showroom-off.gif\'"></A><a href="gallery.html?pageID=0"><img onfocus="this.blur()"src="images/gallery-off.gif" border="0" onmouseover="this.src=\'images/gallery-on.gif\'" onmouseout="this.src=\'images/gallery-off.gif\'"></a><a href="#" onclick="randomArtist();return false;"><img onfocus="this.blur()"src="images/artists-off.gif" border="0" onmouseover="this.src=\'images/artists-on.gif\'" onmouseout="this.src=\'images/artists-off.gif\'"></a><a href="sofa.html?pageID=0"><img onfocus="this.blur()"src="images/sofa-off.gif" border="0" onmouseover="this.src=\'images/sofa-on.gif\'" onmouseout="this.src=\'images/sofa-off.gif\'"></a><A href="contact.html"><img onfocus="this.blur()" src="images/contact-off.gif" border="0" onmouseover="this.src=\'images/contact-on.gif\'" onmouseout="this.src=\'images/contact-off.gif\'"></A>';
	document.getElementById('navPlace').innerHTML=menuString;
}

/*Trim function for validation of text fields*/
function trim(value) {
   var temp = value;
   temp = temp.replace(/^\s*/, ''); // remove leading spaces
   temp = temp.replace(/\s*$/, ''); // remove trailing spaces
   return temp;
}

/*Check if valid email string*/
function isValidEmail(str) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    return re.test(str);
}

/*Open window with artist CV for printing*/
function openPrintWindow(){
var winLeft = (screen.width-600)/2;
	posLeft="left="+winLeft;
var winTop = (screen.height-550)/2;
	posTop="top="+winTop;
	window.open("popupCV.html","","status=no,width=600,height=550,resizable=yes,scrollbars=yes,location=no,"+posTop+","+posLeft);
}