// JavaScript Document

function resize_page(){
	var	max_height = 0;
	var	max_height_def = 0;
	var mass_block = new Array ("m-left","m-center","m-right");
	for(var i in mass_block){
		try{
			document.getElementById(mass_block[i]).style.height="auto";
			document.getElementById(mass_block[i]).style.minHeight=10+"px";
			max_height_def = document.getElementById(mass_block[i]).offsetHeight;
			if(max_height_def>max_height){max_height = max_height_def};
			}
		catch(e){}
		}
		try{document.getElementById("mvf-stepcarousel").style.visibility = "hidden";}catch(e){}
//	alert(max_height)
	for(var i in mass_block){
		try{
			document.getElementById(mass_block[i]).style.minHeight = max_height-10+"px";
			document.getElementById("m-body").style.minHeight = max_height+"px";
			}
		catch(e){}
		}
	try{document.getElementById("mvf-stepcarousel").style.visibility = "visible";}catch(e){}
//	alert(max_height);
instal_fon_enhanced();
}

function instal_fon_enhanced(){
	var header_height = $('.modul-header').height();
	var pre_body_Height=$('.content_border_tl').parent().height();
	var for_body_Height=$('.content_border_bl').parent().height();
	var body_height = ($('.content_border-left').height())+pre_body_Height+for_body_Height;
	var footer_height = $('.modul-footer').height();
	/*var copiright_height =$('.modul-copyright')[0].offsetHeight;*/
	$('.enhanced-head_3').css({'height':header_height});
	$('.enhanced-body_3').css({'height':body_height});
	
	var clientHeight = document.documentElement.clientHeight;
	var maxHeight_page = header_height+body_height+footer_height;
	if(clientHeight>maxHeight_page){footer_height=footer_height+(clientHeight-maxHeight_page)}
	
	$('.enhanced-footer_3').css({'height':footer_height});
	$('#bg_enhanced').css({'visibility':'visible'});
	
	//alert("header "+header_height+"\n body "+body_height+"\n footer "+footer_height)
}


var chechHeightBody=0;
//setInterval(function(){triggerRestore()},500);
function triggerRestore(){
	bodyHeight = $('body')[0].offsetHeight;
	if(bodyHeight!=chechHeightBody){chechHeightBody=bodyHeight; restore_resize_element();};
	setTimeout(function(){triggerRestore()},500)
}

var string_Function_restore = "resize_page";
function restore_resize_element(){
	 masFunct = string_Function_restore.split(',');
	 for(i in masFunct){
	 try{eval(masFunct[i]+"();");}catch(e){}
	 }
}


function getSWF(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
		} else {
		return document[movieName];
	}
}


function send_flash(){
if(feedback_b){	getSWF("galery").toFlash_prev("prev");}
}
function send_flash2(){
if(feedback_b){getSWF("galery").toFlash_next("next");}
}
function send_headflash(aa){
if(feedback_b_head){getSWF("headflash").toFlash(aa);}
}


var temp_num_img_header = 0;
function randomize_img(){
if(feedback_b_head){
	var num_img = randomize(0,amount_heder_img-1);
	temp_num_img_header++;
	if(temp_num_img_header>amount_heder_img-1)temp_num_img_header = 0;
	var num_img = temp_num_img_header;
	//var re_time = randomize(10,22)*1000;
	var re_time = time_to_change_head;
	send_headflash(String(num_img));
	setTimeout(function(){randomize_img()},re_time)
}
}
function randomize(mins,maxs){
var aa = Math.floor(Math.random() * (maxs - mins + 1)) + mins;
return(aa)
;}


function test(aa,bb){
obj = document.getElementById(aa);
width = obj.offsetWidth;
height = obj.offsetHeight;
left = obj.offsetLeft;
right= obj.offsetRight;
top=obj.offsetTop;
	alert("width "+width+"\n height "+height+"\n left "+left+"\n top"+top)
}

window.onload = function(){
	jsReady=true;resize_page();triggerRestore();
	//setTimeout(function(){randomize_img()},time_to_change_head)  /*time_to_change_head is not defined*/
	}


window.onresize = function(){resize_page()};

function detail_bookmarksite(title,url){
	if (!url) {url = window.location}
	if (!title) {title = document.title}
	var browser=navigator.userAgent.toLowerCase();
	if (window.sidebar) { // Mozilla, Firefox, Netscape
		window.sidebar.addPanel(title, url,"");
	} else if( window.external) { // IE or chrome
		if (browser.indexOf('chrome')==-1){ // ie
			window.external.AddFavorite( url, title); 
		} else { // chrome
			alert('Please Press CTRL+D (or Command+D for macs) to bookmark this page');
		}
	}
	else if(window.opera && window.print) { // Opera - automatically adds to sidebar if rel=sidebar in the tag
		return true;
	}
	else if (browser.indexOf('konqueror')!=-1) { // Konqueror
		alert('Please press CTRL+B to bookmark this page.');
	}
	else if (browser.indexOf('webkit')!=-1){ // safari
		alert('Please press CTRL+B (or Command+D for macs) to bookmark this page.');
	} else {
		alert('Your browser cannot add bookmarks using this link. Please add this link manually.')
	}
}
