// JavaScript Document

var previous_width = 1600

var body_css = ''

var image = ''

function init(img){
	
	image = img
	
	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 < 1200){
		var width = 1200
	}
	else{
		var width = 1600
	}
	
	//////// Loop through the elements
	
	var ele = $$('.icon_trans_line')
	for(i=0; i < ele.length; i++){
		ele[i].removeClassName('w'+previous_width);
		ele[i].addClassName('w'+width);
		
	}
	if($('bg_wrapper2') !== null){
	
		$('bg_wrapper2').removeClassName(image+'_w'+previous_width);
		$('bg_wrapper2').addClassName(image+'_w'+width);
	
	}
	else{
		$('body').removeClassName(body_css+'_w'+previous_width);
		$('body').removeClassName(body_css+'_w'+previous_width);
		$('body').addClassName(body_css+'_w'+width);
	}
	
	
	/////// Set the old width to be the current width
	previous_width = width
	
}

var currwidth
window.onresize = function(){
	if(currwidth != document.documentElement.clientWidth)
	{
		init(image)	
	}
	currwidth = document.documentElement.clientWidth;
}

function choose_body(){
	
	// Create an array of the styles
	var body_css_array = new Array("homepage_bg1","homepage_bg2","homepage_bg3","homepage_bg4");
	
	// Pick a random one
	var ran_number = Math.floor(Math.random()*body_css_array.length);
	body_css = body_css_array[ran_number]
	
	// 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 < 1200){
		var width = 1200
	}
	else{
		var width = 1600
	}
	
	$('body').addClassName(body_css+"_w"+width);
	
}