var docWidth, docHeight;

$(document).ready(function(){
	resizeMainHeader();
	animatemenu();
});

$(window).resize(function(){
	resizeMainHeader();							
});

function resizeMainHeader(){
	getPageSize();
	var newsHeight=$(".contmain").height();
	var headerHeight=docHeight-newsHeight-150;
	risizeHeader(headerHeight);
	var news=$(".menu").width()+$(".logo").width()-30;  // fix news line
	$("#contmain").width(news);   // fix news line
	$(".contmain").width(news);  // fix news line
}


function risizeHeader(height){
	if (height<320){height=320} // min-heigt
	if (height>700) {height=700} //max-height
	$("#header").height(height)	;
	$(".over").height(height);
	$(".overhover").height(height);
	$(".flashdiv").height(height);
	//max-min width
	if (docWidth<990){
		$("#header").width(990);
		$(".flashdiv").width(990);
		$(".over").width(920);	
		$(".menu table").width("98%");		
	} else {		
		$("#header").width("100%");
		$(".flashdiv").width("100%");
		$(".over").width(docWidth-70);
		$(".menu table").width("100%");	
	}
}


function animatemenu() {
	 $(".menu a").mouseover(function(){
      $(this).addClass("active");
    }).mouseout(function(){
      $(this).removeClass("active");
    });
}

// get page size
function  getPageSize(){
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
		xScroll = document.documentElement.scrollWidth;
		yScroll = document.documentElement.scrollHeight;
	} else { // Explorer Mac...would also work in Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) { // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	docWidth=windowWidth;
	docHeight=windowHeight;
	//return [pageWidth,pageHeight,windowWidth,windowHeight];
}
