// JavaScript Document

function handleFeedBack(){
	feedback();
}

function handleMailThisPage(){
	mailThisPage();
}


previousOnloadFunction = window.onload;
window.onload = function(){
	
	if(typeof(previousOnloadFunction) == 'function') previousOnloadFunction();
	
	try{
	// event handlers
	document.getElementById('feedbackLink').onclick = function(){ handleFeedBack(); return false;}
	document.getElementById('mailThisPageLink').onclick = function(){ handleMailThisPage(); return false; }
	}catch(e){};
	
}


/*
	MAIL THIS PAGE
*/
var mailThisPageWrapper;
function mailThisPage(){
	if(!mailThisPageWrapper){
		var html = '';
		
		mailThisPageWrapper = document.createElement('div');
		mailThisPageWrapper.className = 'mailThisPageWrapper';
		mailThisPageWrapper.style.height = '0px';
		mailThisPageWrapper.style.width = '0px';
		document.getElementsByTagName('body')[0].appendChild(mailThisPageWrapper);
		
		
		// position of wrapper
		var xPos = document.body.clientWidth;
			xPos = parseInt((xPos / 2) - 200);
		mailThisPageWrapper.style.left = xPos + 'px';

		html += '<h2>Mail this page <a href="javascript:closeMailThisPage()"><img src="/data/closePopup.gif" /></a></h2>';
		html += '<iframe src="/mailThisPage.cfm?" frameborder="0"></iframe>';
		
		mailThisPageWrapper.innerHTML = html;
		
		mailThisPage();
	}else{
		
		var height = mailThisPageWrapper.style.height;
			height = parseInt(height.replace('px', ''));
			height = height + 9;
		var width = mailThisPageWrapper.style.width;
			width = parseInt(width.replace('px', ''));
			width = width + 12;
		
		mailThisPageWrapper.style.height =  height + 'px';
		mailThisPageWrapper.style.width =  width + 'px';
		
		if(height < 300){
			setTimeout('mailThisPage()', 0);
		}
		
	}
	
}


function closeMailThisPage(){
	document.getElementsByTagName('body')[0].removeChild(mailThisPageWrapper);
	mailThisPageWrapper = null;
}
/*
	// MAIL THIS PAGE
*/



/*
	FEEDBACK
*/
var feedbackWrapper;
function feedback(){
	if(!feedbackWrapper){
		var html = '';

		feedbackWrapper = document.createElement('div');
		feedbackWrapper.className = 'feedbackWrapper';
		feedbackWrapper.style.height = '0px';
		feedbackWrapper.style.width = '0px';
		document.getElementsByTagName('body')[0].appendChild(feedbackWrapper);
		
		
		// position of wrapper
		var xPos = document.body.clientWidth;
			xPos = parseInt((xPos / 2) - 300);
		feedbackWrapper.style.left = xPos + 'px';

		html += '<h2>Feedback <a href="javascript:closeFeedBack()"><img src="/data/closePopup.gif" /></a></h2>';
		html += '<iframe src="/feedback.cfm" frameborder="0"></iframe>';
		
		feedbackWrapper.innerHTML = html;
		
		feedback();
	}else{
		
		var height = feedbackWrapper.style.height;
			height = parseInt(height.replace('px', ''));
			height = height + 8;
		var width = feedbackWrapper.style.width;
			width = parseInt(width.replace('px', ''));
			width = width + 12;
		
		feedbackWrapper.style.height =  height + 'px';
		feedbackWrapper.style.width =  width + 'px';
		
		if(height < 400){
			setTimeout('feedback()', 0);
		}
		
	}
	
}


function closeFeedBack(){
	document.getElementsByTagName('body')[0].removeChild(feedbackWrapper);
	feedbackWrapper = null;
}
/*
	// FEEDBACK
*/





