function getWindowSize() {
	var thewidth = 0;
	//Non-IE
	if(typeof(window.innerWidth)=='number') {
		thewidth = window.innerWidth;
	} 
	//IE 6+ in 'standards compliant mode'
	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		thewidth = document.documentElement.clientWidth;
	} 
	//IE 4 compatible
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		thewidth = document.body.clientWidth;
	}
	return thewidth;
}

function positionElements() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById("column02")) return false;
	var screenwidth = 0;
	var thediv = document.getElementById("column02");
	var maindiv = document.getElementById("container");
	switchClass(thediv);
	setWidth(maindiv);
	window.onresize = function() {
		switchClass(thediv);
		setWidth(maindiv);
		resizeFlashCarousel();
	}
}

function setWidth(element){
	screenwidth = getWindowSize();
	if (screenwidth > 880) {
		changeClass(element,"maxWidth");
	}
	else {
		changeClass(element,"minWidth");
	}
}

function switchClass(element) {
	screenwidth = getWindowSize();
	if (screenwidth > 880) {
		changeClass(element,"widthClass");
	}
	else {
		changeClass(element,"widthClassNone");
	}
}

function changeClass(element,value) {
	if (value == "") {
		element.className = "";
	}
	else {
		if (!element.className) {
			element.className = value;
		} 
		else {
//			element.className+= " ";
			element.className= value;
		}
	}
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} 
	else {
		window.onload = function() {
			oldonload();
			func();
			externalLinks();
		}
	}
}

function resizeFlashCarousel(){
	var width = getNewWidth();
	setStyleWidth("banner",width);
	setStyleWidth("flash_carousel_movie",width);
}

function getNewWidth (){
	return getWindowSize() > 880 ? 890 : 680;
}

function setStyleWidth ( id, v ) {
	var e = document.getElementById(id);
	if(!e) return;
	var s = e.style;
	if (document.layers){
		s.width = v;
	}else {
		s.width = v + "px";
	}
}

function externalLinks(){
	var anchorTags = document.getElementsByTagName('a');
	var len = anchorTags.length;
	
	for(var i=0; i<len; i++){
		if("external" == anchorTags[i].getAttribute('rel')){
			anchorTags[i].setAttribute('target','_blank');
		}
	}
}


addLoadEvent(positionElements);