if(($.browser.msie && $.browser.version < 7)) {
	eval("try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {}");
}

function getButtonByLocation(id) {
	var localUrl = window.location.href;
	var retValue = -1;

	$("#"+id+" li a").each(function() {
		if (localUrl.indexOf($(this).attr("href")) > -1) {
			retValue = $("#"+id+" li a").index(this);
		}
	});
	return retValue;
}


/** * document ready */
var countItems;
var countVisibilityItems = 3;
$(document).ready(function() {
	$(".random-list li").hide();
	countItems = $(".random-list li").size();
	showWinner(countItems);
});

function showWinner(countItems) {
	var showItem = Math.ceil(Math.random()*countItems)-1;
	for (var i = 0; i < countVisibilityItems; i++) {
		$(".random-list li:eq("+(showItem)+")").show();
		showItem++;
		showItem = (showItem < countItems) ? showItem : 0;
	}
}

// create a shorthand function so we don't need to put all this in the opener's onclick
function openYouTube(opener, type) {
	var returnValue;
	type = typeof(type) != 'undefined' ? type : 'swf';
	// Safari Mobile doesn't have Flash, so we just let the device use the built-in 
	// YouTube viewer.
	if (/(iPhone|iPod|iPad)/.test(navigator.userAgent)) returnValue = true;

	else returnValue = hs.htmlExpand(opener, { 
		objectType: type, 
		objectWidth: 480, 
		objectHeight: 385, 
		transitions: ['fade'],
		width: 480, 
		//outlineType: 'rounded-white',
		//outlineWhileAnimating: true,
		allowSizeReduction: true,
		// always use this with flash, else the movie will be stopped on close:
		preserveContent: false,
		//wrapperClassName: 'draggable-header no-footer',
		swfOptions: { 
			params: { 
				allowfullscreen: 'true' 
			}
		}, 
		maincontentText: 'You need to upgrade your Flash player' 
	});
	
	return returnValue;
}

//get params to array
function getUrlVars() {
	var result = {};
	var href = window.location.href;
	if (location.hash) {
		// remove hash part from the href location
		href = href.substring(0, (href.length - location.hash.length));
	}
	href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) {
		result[key] = value;
	});
	return result;
}

/** document ready baby
*/
$(document).ready(function() {
	// nakopni-kamose
	if(getUrlVars()['v']) {
		$('iframe#nakopni-kamose').attr('src', $('iframe#nakopni-kamose').attr('src') + 'videos/' + getUrlVars()['v']);
	}
});
