// JavaScript Document
function changeImg(name,source) {
  document.getElementById(name).src=source;
}

function showFooter() {
	document.getElementById("bottom").style.display="block";
	document.getElementById("copyright").style.display="block";	
	document.getElementById("njscopy").style.display="none";
}

function resize() {
	var height=document.documentElement.clientHeight; 
	var width=document.documentElement.clientWidth; 
	var navheight = height-138;
	navheight = navheight+"px";
	document.getElementById("nav").style.height=navheight;
	var mainheight = height-178;
	mainheight = mainheight+"px";
	document.getElementById("main").style.height=mainheight;
	var mainwidth = width-190;
	mainwidth = mainwidth+"px";
	document.getElementById("main").style.width=mainwidth;
	window.onresize=resize; 
}

function showhide(show) {
	var i=1;
	for (i=1;i<=7;i++) {
		document.getElementById("m"+i).style.display="none";
	}	
	document.getElementById("m"+show).style.display="block";
	window.location="#a"+show;
}

function gallery(no) {
   if (no>0 && no<totalimg+1) {
   	  if (no>firstpic-1 && no<lastpic+1) {
	  	selectedborder(no);
   		document.getElementById("image").src = 'files/galleries/'+gall+'/b'+no+'.jpg?'+new Date().getTime();
      	imgno = no; 
	  } else if (no==firstpic-1) {
	    window.location = 'media.php?page=gallery&galpage='+(page-1)+'&pic='+(firstpic-1)+'&gallery='+gall;
	  } else if (no==lastpic+1) {
	    window.location = 'media.php?page=gallery&galpage='+(page+1)+'&pic='+(lastpic+1)+'&gallery='+gall;
	  }
   }
}

function selectedborder(no) {
   var i;
   for (i=firstpic;i<=lastpic;i++) {
      thumbno='thumb'+i;
      document.getElementById(thumbno).className='blackcell';
   }
   thumbno='thumb'+no;
   document.getElementById(thumbno).className='greycell';
}

function changepic(source,id) {
   		document.getElementById(id).src = source+'?'+new Date().getTime();
}

function changelink(source,id) {
   		document.getElementById(id).href = source;
}

function adminpic(src) {
	document.write('<img id="image" src="'+src+'.jpg?'+new Date().getTime()+'" alt="Serotone" />');
}

function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
}

function imgload(src,alt,pic) {
	var firstchar=src.substring(1,0);
	if (firstchar=="b") {
		document.write('<img id="image" src="'+src+'.jpg?'+new Date().getTime()+'" class="blackcell" alt="'+alt+'" id="thumb'+pic+'" />');
	} else {
		document.write('<img src="'+src+'.jpg?'+new Date().getTime()+'" class="blackcell" alt="'+alt+'" id="thumb'+pic+'" />');
	}
}