//the preparefilmLinks function is an altered version of one in "DOM Scripting", ISBN:1590595335
window.onload = init;

function init(){
	replacepop();
	//replacebuttons
}
function replacerndimg(){
	var imgArray = new Array();
	var imgArray2 = new Array();
	var images=document.images;
	
	var currentdate = new Date();
	var core =currentdate.getSeconds();
	var core2=currentdate.getSeconds();
	
	for (x in images){
		if (images[x].className=="replace fullimage"){
			imgArray[0] = 'big_femail_violinis.jpg';
			imgArray[1] = 'big_jazz.jpg';
			imgArray[2] = 'big_recorder.jpg';
			imgArray[3] = 'big_trombone.jpg';
			imgArray[4] = 'big_trumpet.jpg';
			imgArray[5] = 'big_violinist.jpg';
			imgArray[5] = 'big_violinist.jpg';
			imgArray[6] = 'big_brass.jpg';
			ran = 60/imgArray.length;
			core = Math.floor(core/ran);
			images[x].src="images/common/home/"+imgArray[core];
		}else if(images[x].className=="replace thinimage"){
			imgArray2[0] = 'small_drummer.jpg';
			imgArray2[1] = 'small_flute.jpg';
			imgArray2[2] = 'small_guitar.jpg';
			imgArray2[3] = 'small_singing.jpg';
			imgArray2[4] = 'small_violinist.jpg';
			ran2 = 60/imgArray2.length;//array length
			core2 = Math.floor(core2/ran2);
			images[x].src="images/common/home/"+imgArray2[core2];
		}
	}
}
function replacerndimgevents(){
	var imgArray = new Array();
	var imgArray2 = new Array();
	var images=document.images;
	
	var currentdate = new Date();
	var core =currentdate.getSeconds();
	var core2=currentdate.getSeconds();
	
	for (x in images){
		if (images[x].className=="calendarBanner"){
			imgArray[0] = 'cal1.jpg';
			imgArray[1] = 'cal2.jpg';
			imgArray[2] = 'cal3.jpg';
			imgArray[3] = 'cal4.jpg';
			imgArray[4] = 'cal5.jpg';
			imgArray[5] = 'cal6.jpg';
			imgArray[6] = 'cal7.jpg';
			imgArray[7] = 'cal8.jpg';
			imgArray[8] = 'cal9.jpg';
			imgArray[9] = 'cal10.jpg';
			ran = 60/imgArray.length;
			core = Math.floor(core/ran);
			images[x].src="images/"+imgArray[core];
		}
	}
}
/*******************admin delete and save functions*******************/
function adbutton (storyid, dmode, smode){
		document.getElementById("saved").value = storyid;
		document.getElementById("mode").value = dmode;
		document.getElementById("smode").value = smode;
		if (document.getElementById("deleted")){
			document.getElementById("deleted").value = "";
		}
}
function delbutton (delid, storyid, dmode, smode){
		document.getElementById("deleted").value = delid;
		document.getElementById("saved").value = storyid;
		document.getElementById("mode").value = dmode;
		document.getElementById("smode").value = smode;
}

/**************************************************************/
function check(storyid){

	if (document.getElementById("check"+storyid).className =="delvisible"){
		document.getElementById("check"+storyid).className = "hidden";
	}else{
		document.getElementById("check"+storyid).className = "delvisible";
	}
}
/******************************************************************/

function replacesearch() {
	/*check browser capabilities*/
	if (!document.getElementsByTagName) return false;

	if (document.getElementById("searchlink")){
		var links = document.getElementById("searchlink");
				links.onclick =function() {
			var val=document.getElementById("search").value;
			var linkshref = links.getAttribute("href");
			links.href= linkshref+"?search="+val;
		}

	}
}
/********************************************************************/
function newwin(winfile,winname,attribs) {
newwindow=window.open(winfile,winname,attribs);
if (window.focus) {newwindow.focus()}
}
function replacepop() {
	
	/*check browser capabilities*/
	if (!document.getElementsByTagName) return false;
		var links = document.getElementsByTagName("a");
		for (x in links){
			if (links[x].className=="popup" || links[x].className=="popup tablelinks"){
				var vurl = links[x].href;
				links[x].setAttribute("onclick","newwin('"+vurl+"','newwindow','location=yes,status=yes,scrollbars=yes,resizable=yes,width=600,height=600,top=200,left=10');return false;");
			}/*else{
				break;
			}*/
		}
}

function changeheight (){
	if (document.getElementById('brown')) {
		var lheight = document.getElementById('col2');
		var cheight = document.getElementById('brown');
		var diff =  (lheight.offsetHeight - cheight.offsetHeight);
		if (diff > 0) {
			var copyheight = document.getElementById('brown');
			copyheight.style.height = (copyheight.offsetHeight + diff - 97) + 'px';
			copyheight.style.width = 443 + 'px';
		}
		
		diff = (cheight.offsetHeight - lheight.offsetHeight);

		if (diff > 0) {

			var navheight = document.getElementById('col2');
			navheight.style.height = (navheight.offsetHeight + diff -4) + 'px';
			
		}
	}
}

function changeheightie (){
	if (document.getElementById('brown')) {
		var lheight = document.getElementById('col2');
		var cheight = document.getElementById('brown');
		var diff =  (lheight.offsetHeight - cheight.offsetHeight);
		if (diff > 0) {
			var copyheight = document.getElementById('brown');
			copyheight.style.height = (copyheight.offsetHeight + diff - 114) + 'px';
			copyheight.style.width = 443 + 'px';
		}
		
		diff = (cheight.offsetHeight - lheight.offsetHeight);

		if (diff > 0) {

			var navheight = document.getElementById('col2');
			navheight.style.height = (navheight.offsetHeight + diff -4) + 'px';
			
		}
	}
}

function changeheightie7 (){
	if (document.getElementById('brown')) {
		var lheight = document.getElementById('col2');
		var cheight = document.getElementById('brown');
		var diff =  (lheight.offsetHeight - cheight.offsetHeight);
		if (diff > 0) {
			var copyheight = document.getElementById('brown');
			copyheight.style.height = (copyheight.offsetHeight + diff - 114) + 'px';
			copyheight.style.width = 443 + 'px';
		}
		
		diff = (cheight.offsetHeight - lheight.offsetHeight);

		if (diff > 0) {

			var navheight = document.getElementById('col2');
			navheight.style.height = (navheight.offsetHeight + diff -4) + 'px';
			
		}
	}
}