// JavaScript Document
function swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function resize() {
	var height=document.documentElement.clientHeight; 
	var width=document.documentElement.clientWidth; 
	if (height>160) {
		var mainheight=(100/height)*(height-150);
		mainheight = mainheight+"%";
		document.getElementById("content").style.height=mainheight;
		document.getElementById("panel").style.height=mainheight;
	}
	window.onresize=resize; 
}

function date() {
  	var myDate=new Date();
	var day=myDate.getDay();
	var days = new Array();
	days[0] = "Sun";
	days[1] = "Mon";
	days[2] = "Tues";
	days[3] = "Wed";
	days[4] = "Thurs";
	days[5] = "Fri";
	days[6] = "Sat";
	var year=myDate.getYear();
	var date=myDate.getDate();
	var month=myDate.getMonth()+1;
	var message=days[day]+" "+date+"/"+month+"/"+year;
	document.write(message);
}

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) {
	  document.getElementById("backgall").style.display="inline";
	  document.getElementById("forwardgall").style.display="inline";
   	  if (no>firstpic-1 && no<lastpic+1) {
   		document.getElementById("image").src = 'demo/gallery/b'+no+'.jpg';
      	imgno = no; 
	  } else if (no==firstpic-1) {
	    window.location = 'demo.php?page='+(page-1)+'&pic='+(firstpic-1)+'&section=3';
	  } else if (no==lastpic+1) {
	    window.location = 'demo.php?page='+(page+1)+'&pic='+(lastpic+1)+'&section=3';
	  }
   } else if (no==0) {
	   document.getElementById("backgall").style.display="none";
   } else if (no==totalimg+1) {
	   document.getElementById("forwardgall").style.display="none";
   }
}

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