function Go(url) {
  //parent.opener.window.location.href = url;
  window.location.href = url;
}

function AddFav(){
	window.external.AddFavorite('http://www.autoweb.cz','Auta, tuning, videa - vše o autech');
}

function setContentHeight(contents){
	var extreme = 0;
	var infos = new Array();

	// je tato funkce podporovana
	if (document.getElementById){
		for (var i in contents){
			if (objId == document.getElementById(contents[i])){
				infos[i] = findPosY(objId);
				if (extreme < (infos[i] + objId.offsetHeight)){
					extreme = (infos[i] + objId.offsetHeight);
				}
			}
		}

		for (var j in contents){
			if (objId == document.getElementById(contents[j])){
				objId.style.height = (extreme - infos[j]);
			}
		}
	}
}


function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}

	}else if (obj.x){
		curleft += obj.x;
	}

	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}

	}else if (obj.y){
		curtop += obj.y;
	}

	return curtop;
}

//
// [DEBUG]
//alert('global.js loaded.');

function showOverdiv(id, text) {
	var div = document.getElementById(id);
	if (!div) return false;

	var x, y, scroll;
	if (self.innerHeight) {
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) {
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	if (self.pageYOffset) {
		scroll = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop) {
		scroll = document.documentElement.scrollTop;
	}
	else if (document.body) {
		scroll = document.body.scrollTop;
	}

	if (text) div.innerHTML = text;
	div.style.display = 'block';
	div.style.top = (scroll + ((y - div.offsetHeight) / 2));
	div.style.left = ((x - div.offsetWidth) / 2);
}

function hideOverdiv(id) {
	var div = document.getElementById(id);
	if (!div) return false;

	div.style.display = 'none';

}

function openVideo(nm,q) {
	if (q==1) {
		var el = document.getElementById('video'+nm+'l');
		el.style.display = 'none';
	}
	
	if (q==0) {	
		var el = document.getElementById('video'+nm+'h');
		el.style.display = 'none';
	}
	
	var el = document.getElementById('video'+nm+ (q==1?'h':'l'));
	el.style.display = el.style.display=='none' ? 'block':'none';
}

function homeVideo(url, id, small) {
	/*
	if (readCookie('homePageVideo'+id)!=1) {
		var ass = 'true';
		var as = 1;
	*/
		/*var d = new Date();
		var h = d.getHours();
		var c = 1/24 * (24-h+5);*/
	/*
		createCookie('homePageVideo'+id,1,90);	
	} else {
		var ass = 'false';
		var as = 0;		
	}
	*/

		var ass = 'false';
		var as = 0;		
		
	if (small==true) {
		var w = 188;
		var h = 151; 
	} else {
		var w = 230;
		var h = 174;		
	}
	
	document.write('<object id="HomeMediaPlayer" style="z-index:auto;" width="'+w+'" height="'+h+'" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"'+
		'standby="Nahrávám video..." type="application/x-oleobject">'+
			'<param name="FileName" value="'+url+'" />'+
			'<param name="autostart" value="'+ass+'" />'+
			'<param name="ShowControls" value="true" />'+
			'<param name="ShowStatusBar" value="false" />'+
			'<param name="ShowDisplay" value="false" />'+
			'<param name="uiMode" value="full" />'+
			'<PARAM NAME="ShowCaptioning" VALUE="0" />'+
			'<PARAM NAME="BufferingTime" VALUE="30" />'+
			'<embed type="application/x-mplayer2" src="'+url+'" name="MediaPlayer"'+
				'width="'+w+'" height="'+(h+0)+'" ShowCaptioning="0" style="z-index:auto;" ShowControls="1" ShowStatusBar="0" ShowDisplay="0" autostart="'+as+'" uiMode="full"></embed>'+
		'</object>'
	);
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}



