
// By Gianmarco Panfili {gianet2000@hotmail.com}


//  Preload images
function imagesPreload(){
	var  imagesArray=new Array('biography-off','biography-over','dandp-off','dandp-over','commissions-off','commissions-over','exhibitions-off','exhibitions-over','pressroom-off','pressroom-over','contact-off','contact-over','buzsaki-1-off','buzsaki-1-over','introduction-dots','biography-dots','dandp-dots','commissions-dots','exhibitions-dots','pressroom-dots','contact-dots','gallery-introduction','gallery-biography','gallery-biography-commissions','gallery-biography-dandp','gallery-biography-exhibitions','gallery-biography-pressroom','gallery-biography-contact','gallery-commissions','gallery-commissions-contact','gallery-commissions-dandp','gallery-commissions-exhibitions','gallery-commissions-pressroom','gallery-contact','gallery-contact-pressroom','gallery-dandp','gallery-dandp-contact','gallery-dandp-exhibitions','gallery-dandp-pressroom','gallery-exhibitions','gallery-exhibitions-contact','gallery-exhibitions-pressroom','gallery-pressroom');
	for(i = 0; i < imagesArray.length; i++){
  	newImage=new Image();
  	newImage.src="img/" + imagesArray[i] + ".gif";
   	}
}


// images rollover
function imagesRollover(img,state){
	img.src=state;
}


// gallery rolloverOn
function changeGalleryOn(section){
	if (document.layers){document.gallery.src= section + ".gif";}
	else{document.getElementById('gallery').src= section + ".gif";}
}


// gallery rolloverOut
function changeGalleryOut(section){
	if (document.layers){document.gallery.src= section + ".gif";}
	else{document.getElementById('gallery').src= section + ".gif";}
}


// Change font size
function textSize(x){
	if (document.layers){alert('Sorry, your browser is not enabled for this functionality. Click on the question mark image to download a newer version.')}
	else{
		if(x==0){
			srcString = new String(document.getElementById('datamain').src);
			splitSrcString = srcString.split("-");
			document.getElementById('datamain').src=splitSrcString[0]+"-0.html";
	
			document.getElementById('mainArea').style.fontSize="10px";
			document.getElementById('descriptionArea').style.fontSize="10px";
			if(document.getElementById('contentFormat')){document.getElementById('contentFormat').style.fontSize="10px";}
			if(document.getElementById('contentFormatRight')){document.getElementById('contentFormatRight').style.fontSize="10px";}
			if(document.getElementById('contentFormatCell')){document.getElementById('contentFormatCell').style.fontSize="10px";}
		}
		if(x==1){
			srcString = new String(document.getElementById('datamain').src);
			splitSrcString = srcString.split("-");
			document.getElementById('datamain').src=splitSrcString[0]+"-1.html";

			document.getElementById('mainArea').style.fontSize="12px";
			document.getElementById('descriptionArea').style.fontSize="12px";
			if(document.getElementById('contentFormat')){document.getElementById('contentFormat').style.fontSize="12px";}
			if(document.getElementById('contentFormatRight')){document.getElementById('contentFormatRight').style.fontSize="12px";}
			if(document.getElementById('contentFormatCell')){document.getElementById('contentFormatCell').style.fontSize="12px";}
		}
	}
}


// Check font size when loading the page
function checkSize(){
	if (document.layers){}
	else{
		locationString = new String(document.location);
		locationSplitString = locationString.split("?");
		if(locationSplitString[1]=="T"){textSize(1);}
		else{textSize(0);}
	}
}


// Changing page passing font size
function changePage(page){
	if (document.layers){
		
		if(page=="contact")
			{document.location = page + ".php";}
		else{document.location = page + ".html";}
		}
	else{

		if(page=="contact"){
			if(document.getElementById('mainArea').style.fontSize == "12px"){document.location = page + ".php?T"}
			else{document.location = page + ".php";}
		} else {
			if(document.getElementById('mainArea').style.fontSize == "12px"){document.location = page + ".html?T"}
			else{document.location = page + ".html";}
		}
	}
}


// Check font size when loading the page (content)
function checkSizeContent(){
		locationString1 = new String(document.location);
		locationSplitString1 = locationString1.split("?");
		if(locationSplitString1[1]=="T"){document.src= "contentcommissions-1.html";}
		else{document.src= "contentcommissions-0.html";}

}


// Pop up window

function openExhibition(work){
if(work=="copyright")
	{
	window.open("copyright.html","copyright","location=yes,menubar=no,resizable=yes,scrollbars=no,status=no,titlebar=no,toolbar=no,width=500,height=350")
	}
else{
	var page = "workpage.html?" + work;
	window.open(page,"workPage","location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,width=800,height=660")
	}
}

function checkExhibition(){
		locationString = new String(document.location);
		locationSplitString = locationString.split("?");
		document.getElementById('exhibitionImage').src = "../img/works/" + locationSplitString[1] + "-c.gif";
}

// Changing work description
function changeWorkDescription(description){
	if (document.layers){}
	else{
		document.getElementById('workDescription').innerHTML=description;
		}
}

// Add to favorites
var bookmarkurl="http://www.buzsaki.com"
var bookmarktitle= document.title;
function addbookmark(){
	if (document.all)
	window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

// Chacking the image in work page

function checkImage(){
var imageCheked = document.getElementById('exhibitionImage').src;
imageChekedPart = imageCheked.split("/img/works/");

if(imageChekedPart[1]=="exhibition101-c.gif"){document.getElementById('exhibition101Div').style.visibility="visible";}
if(imageChekedPart[1]=="exhibition102-c.gif"){document.getElementById('exhibition102Div').style.visibility="visible";}
if(imageChekedPart[1]=="exhibition103-c.gif"){document.getElementById('exhibition103Div').style.visibility="visible";}

if(imageChekedPart[1]=="exhibition74-c.gif"){document.getElementById('exhibition74Div').style.visibility="visible";}

if(imageChekedPart[1]=="exhibition21-c.gif"){document.getElementById('exhibition21Div').style.visibility="visible";}

}

function changeWorkImage(changed){
	document.getElementById('exhibitionImage').src=changed;
}



// scrolling
// specify speed of scroll (greater=faster)
var speed=4

iens6=document.all||document.getElementById
ns4=document.layers

function movedown(){
if (window.moveupvar) clearTimeout(moveupvar)
if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100))
crossobj.style.top=parseInt(crossobj.style.top)-speed
else if (ns4&&crossobj.top>=(contentheight*(-1)+100))
crossobj.top-=speed
movedownvar=setTimeout("movedown()",100)
}

function moveup(){
if (window.movedownvar) clearTimeout(movedownvar)
if (iens6&&parseInt(crossobj.style.top)<=0)
crossobj.style.top=parseInt(crossobj.style.top)+speed
else if (ns4&&crossobj.top<=0)
crossobj.top+=speed
moveupvar=setTimeout("moveup()",100)
}

function stopscroll(){
if (window.moveupvar) clearTimeout(moveupvar)
if (window.movedownvar) clearTimeout(movedownvar)
}

function movetop(){
stopscroll()
if (iens6)
crossobj.style.top=0
else if (ns4)
crossobj.top=0
}

function getcontent_height(){
if (iens6)
contentheight=crossobj.offsetHeight
else if (ns4)
document.nscontainer.document.nscontent.visibility="show"
}

