// JavaScript Document

var previous_width = 1600

var body_css = ''

var image = ''

function init_page(img){
	
	image = img

	

	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
		}
		else if(navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
		}
		else {
		winW = window.innerWidth;
		}
	}
	
	//////// Calculate the size
	
	if(winW < 1025){  
		var width = 1024
	}
	else if(winW > 1024 && winW < 1400){
		var width = 1200
	}
	else{
		var width = 1600
	}
	
	//////// Loop through the elements
	
	var ele = $$('.line')
	for(i=0; i < ele.length; i++){
		ele[i].removeClassName('w'+previous_width);
		ele[i].addClassName('w'+width);
		
	}

	if (!image) { image='homepage_w'+width; }

	if($('bg_wrapper2') !== null){
	
		$('bg_wrapper2').removeClassName(image+'_w'+previous_width);
		$('bg_wrapper2').addClassName(image+'_w'+width);
	
	}
	else{
		$('body').removeClassName(image+'_w'+previous_width);
		$('body').addClassName(image+'_w'+width);
	}
	
	
	
	/////// Set the old width to be the current width
	previous_width = width
	
}

var currwidth
var currheight
window.onresize = function(){
	if(currwidth != document.documentElement.clientWidth)
	{
		init_page(image)	
	}
	currwidth = document.documentElement.clientWidth;
	
	if(currheight != document.documentElement.clientHeight)
	{
		set_wrapper_div()
	}
	
}

function set_wrapper_div(){
	currheight = window.outerHeight;
	$('bg_wrapper2').style.height = currheight + 'px'
	
}

function choose_body(){
	

	// Detect browser
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
		}
	}
	
	//////// Calculate the size
	
	if(winW < 1025){  
		var width = 1024
	}
	else if(winW > 1024 && winW < 1440){
		var width = 1200
	}
	else{
		var width = 1600
	}
	
	$('body').addClassName(body_css+"_w"+width);
	
}


