function setNavImage(navItem, newImageURL)
{
    var elem;
    if (elem = $(navItem))
    {
        elem.setAttribute('src', newImageURL);
    }
}

function setNavImageById(navImageId, newImageURL)
{
    var elem;
    if (elem = $(navImageId))
    {
        elem.setAttribute('src', newImageURL);
    }
}

function initRollover(curNodeId, imageNodeId, activeImgUrl, inactiveImgUrl)
{
    $(imageNodeId).onmouseover = function () { setNavImageById(imageNodeId, activeImgUrl); };

    // Don't deactivate the image if its the current page, leave it highlighted
    if (curNodeId != imageNodeId)
    {
        $(imageNodeId).onmouseout = function () { setNavImageById(imageNodeId, inactiveImgUrl); };
    }
}

function initHomepage()
{
	var homepageItems = $$('.homePageImage');
	for(var i = 0, n = homepageItems.length; i < n; i++ ){
		homepageItems[i].onmouseover = function () {
			var extn = this.src.substring(this.src.length - 3);
			this.src = "images/"+this.id+"_on."+extn;
		};
		homepageItems[i].onmouseout = function () {
			var extn = this.src.substring(this.src.length - 3);
			this.src = "images/"+this.id+"_off."+extn;
		};
	}
}

function initStatic()
{
	var staticNavItems = $$('.staticNavImage');
	for(var i = 0, n = staticNavItems.length; i < n; i++ ){
		staticNavItems[i].onmouseover = function () {
			var extn = this.src.substring(this.src.length - 3);
			this.src = "/images/"+this.id+"_on."+extn;
		};
		staticNavItems[i].onmouseout = function () {
			var extn = this.src.substring(this.src.length - 3);
			this.src = "/images/"+this.id+"_off."+extn;
		};
	}
}

function deepImagePath(image)
{
	var imageID = (image.id.substring(6));
	var imagePath = imageID.replace("_","/");
	return imagePath;
}

function initThumbs(folder,firstImage)
{
	var thumbs = $$('.imgThumb');
	for(var i=0, n=thumbs.length;i<n;i++){
		thumbs[i].onmouseover = function(){
			var filename = "../artist_images/"+folder+"/"+(deepImagePath(this)) +".jpg";
			$("mainImage").src = filename;		
		}
	}
}

function createIntName(elem)
{
	name = elem.value;
	var nameParts = name.split(" ");
	$("intName").value = nameParts.join("");
}

function showcv(artist,type)
{
	if(type=='doc'){
		type ="/";
		var extn = ".doc";
		var features = 'scrollbars=yes,width=650,height=550';
	} else if(type=='html') {
		type += "/";
		var extn="_cv.htm";
		var features = 'scrollbars=yes,width=350,height=450';
	} else {
		type ="";
		var extn="_xmlcv.htm";
		var features = 'scrollbars=yes,width=350,height=450';
	}
	
	var path = "/cv/"+type+artist+extn;
	window.open(path,artist,features);
	return false;
}

function showbio(artist,type)
{
	if(type!='html'){
		type ="";
		var extn = "_bio.doc";
		var features = 'scrollbars=yes,width=650,height=550';
	} else {
		var extn="_bio.htm";
		var features = 'scrollbars=yes,width=350,height=450';
	}
	var path = "cv/"+type+"/"+artist+extn;
	window.open(path,artist,features);
	return false;
}

function initLocationsThumbs(folder,firstImage)
{
	var thumbs = $$('.imgThumb');
	for(var i=0, n=thumbs.length;i<n;i++){
		thumbs[i].onmouseover = function(){
			var filename = "images/"+(this.id) +".jpg";
			$("mainImage").src = filename;		
		}
	}
}

var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}