﻿var ie=document.all ? true : false;
var ie5=(document.all && !document.getElementById)? (true):(false);if (ie5){document.getElementById=function (e){return document.all[e];}}

function $(id){return document.getElementById(id);}
function addEvent(eventType,handlerFunc,addToObject){
	var o=(addToObject)?(addToObject):(window);if (o){	
	if (window.attachEvent){o.attachEvent("on"+eventType,handlerFunc);}
	else if (window.addEventListener){o.addEventListener(eventType,handlerFunc,false);}
	}
}

function setHTML(id,str)	{var o=$(id);if(!o)return;o.innerHTML=str;}
function getHTML(id)		{var str="";var o=$(id);if (o)str=o.innerHTML;return str;}
function setFocus(id)		{var o=$(id);if(!o)return;o.focus();}
function setValue(id,str)	{var o=$(id);if(!o)return;o.value=str;}
function autoselect(id,str)	{var o=$(id);if(!o)return;if (!o.length)return;for (var i=0;i<o.length; i++){if (o[i].value==str){o.selectedIndex=i;break;}}}

function getOffsetTop (el){var ot = el.offsetTop;while ( ( el = el.offsetParent ) != null ){	ot += el.offsetTop;	}return ot;}
function getOffsetLeft (el){var ot = el.offsetLeft;while ( ( el = el.offsetParent ) != null ){ot += el.offsetLeft;}return ot;}
function replaceClass(id,str1,str2){
	if (id=="")return;
	var o = $(id);
	if (o){
		o.className = (o.className!="")?(o.className.replace (str1,str2)):(str2);
	}
}
function removeClass(o, str){replaceClass(id,str,"");}
function addClass(o,str){if (!o)return;o.className = o.className + " " + str;}

function playVideo(url){
	var video = window.open("video.asp?url="+url,'video','scalable=yes,status=yes,scrollbars=no,width=600,height=400,top=10,left=10');
}

function resizeFullHeight(oIframe , showOnlyInsideScroll){	
	
	
	if (showOnlyInsideScroll==1){
		// make the conmtent div matching whats left from the window 
		var div = document.createElement("div");
		div.style.visibility = "hidden";
		div.style.width = "1px";
		div.style.height = "1px";		
		div.style.position = "absolute";
		div.style.left= "0px";
		div.style.bottom= "0px";
		div.style.zIndex= "1";		
		document.body.appendChild (div);
			
		var h = getOffsetTop(div ) - getOffsetTop(oIframe) - 20;
		if (h<210)h=210; // fits 1024x768 
		
		// adjust the 		
		$("ContentBoxMiddle").style.height = h+"px";
		
	}	
	
	
	// adjust the iframe to show everything inside without needing inside scroll		
	var h = ie ? oIframe.document.body.scrollHeight : oIframe.contentDocument.body.scrollHeight;
	oIframe.style.height = h + "px";	
	
	
	
}

function setMaxWidth(img,maxWidth){
	if (!img.width)return;
	if (img.width>maxWidth)img.width=maxWidth;
}

addEvent("load",function(){	
	if (location.search.indexOf("debug")>-1){
		var ar = document.getElementsByTagName("input");
		for(var i in ar){			
			if (ar[i].type=="text"){				
				ar[i].value=ar[i].name;
				if (ar[i].name=="email")ar[i].value="test@test.com";
			}
			
		}
	}
	})
