﻿function loadSize(intTgtW, intTgtH)
{

	//find chrome size
	var intWDiff = this.window.outerWidth - this.window.innerWidth;
	var intHDiff = this.window.outerHeight - this.window.innerHeight;
	
	//resize to target + chrome
	var intActualW = intTgtW + intWDiff;
	var intActualH = intTgtH + intHDiff;
	
	this.window.resizeTo(intActualW, intActualH);
	
}

function qs() {
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			qsParm[key] = val;
		}
	}
}

function change_lament(strNewLament){

	var targetPage = strNewLament + ".html";
	var targetFrame = frames['artistcontent'];
	
	targetFrame.location.href = targetPage;
	
}

function fix_iframe_size(){

	
	var targetFrame = parent.frames['artistcontent'];
	var targetFrameContent = targetFrame.document;
	var targetDiv = parent.document.getElementById('essayarea');
	var newHeight = 0;
	var newSHeight = 0;
	var newOHeight = 0;
	
	if (targetFrameContent.height)	{
		newHeight = targetFrameContent.height;
				
	}else if (targetFrameContent.body) {
		if (targetFrameContent.body.scrollHeight) {
			newSHeight = targetFrameContent.body.scrollHeight;
			
		}
		if (targetFrameContent.body.offsetHeight) {
			newOHeight = targetFrameContent.body.offsetHeight;
			
		}
		if (newSHeight && newOHeight){
			newHeight = Math.max(newSHeight, newOHeight);
		}
	} 
	
	if (newHeight) {
		// don't make the div shorter than the original page load size but do make it taller if required. always force a resize anyway so that it shrinks back to normal if it was enlarged previously.
		var finalNewHeight = Math.max((newHeight + 30), 396) + "px";
		targetDiv.style.height = finalNewHeight;	
	}

}

function dayImage(){

	//modulo 3 on day of year
	var oDate = new Date();
	var intTargetImg = (oDate.getDate() % 7);
	var strImageBase = "images/lament_centerimg";
	var oTargetImg = document.getElementById('centerimg');
		
	//if result is 1 or 2, change image
	//if result 0, do nothing
	if (intTargetImg) {
	
		oTargetImg.src = strImageBase + intTargetImg + ".jpg";
		
	}
	
}

function dayImageNew(){

	//modulo 7 on day of year
	var oDate = new Date();
	var intTargetImg = (oDate.getDate() % 7);
	var strImageStringStart = "<img id=\"centerimg\" src=\"images/lament_centerimg"
	var strImageStringEnd = ".jpg\" alt=\"\" name=\"centerimg\" height=\"288\" width=\"288\" border=\"0\" />"
	var strImageIndex = "";
		
	//if result is non-zero, change image index
	if (intTargetImg) {

		var strImageIndex = intTargetImg;	
		
	}
	
	document.write(strImageStringStart + strImageIndex + strImageStringEnd);
	
}

function change_text(strNewText){

	var targetPage = strNewText + "_text.html";
	var targetFrame = frames['artistcontent'];
	
	targetFrame.location.href = targetPage;
	
}

function correctedTopLocation(){
	var strAgent = navigator.userAgent;
	var intIndex = strAgent.indexOf("Firefox");
	
	if (intIndex != -1){
		//firefox, correct by 19px up
		return 198;
		
	}else{
		//not firefox, use standard location
		return 217;
	}
}

function correctedHeight(){
	var strAgent = navigator.userAgent;
	var intIndex = strAgent.indexOf("Firefox");
	
	if (intIndex != -1){
		//firefox, correct by 19px taller
		return 292;
		
	}else{
		//not firefox, use standard height
		return 273;
	}
}
	
