var backupBackground = "";

function hiOn(obj) {
    backupBackground = obj.style.backgroundColor;
    //backupBackgroundPosition = obj.style.backgroundPosition;
    //obj.style.backgroundRepeat = 'repeat';
    obj.style.backgroundColor = "rgba(0,0,0,.2)";
}

function hiOff(obj) {
    obj.style.backgroundColor = backupBackground;
}

function roll(id) {
    $('#'+id).slideToggle(1000);
}

function revealForm(id, sender) {
    $(sender).hide(300);
    $('#'+id).slideToggle(300);
}

function smallimage(pix) {
    var wPix=pix.width;
    var hPix=pix.height;
    var maxW = 870;
    var maxH = 700; 
    if (wPix > hPix && wPix > maxW) 
    {
        f=1-((wPix - maxW) / wPix);
        pix.width=Math.floor(wPix * f);
        pix.height=Math.floor(hPix * f);
    }
    else if (hPix > wPix && hPix > maxH) 
    {
        f=1-((hPix - maxH) / hPix);
        pix.width=Math.floor(wPix * f);
        pix.height=Math.floor(hPix * f);
    }
}

var blur = false;
var pageTitleDefault;

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
        if (oldonload) {
            oldonload();
        }
            func();
        }
    }
}

function onBlur() {
    blur = true;
}

function onFocus(){
    blur = false;
    document.title = pageTitleDefault;
}

pageTitleDefault = document.title; 

if (/*@cc_on!@*/false) { // check for Internet Explorer
    document.onfocusin = onFocus;
    document.onfocusout = onBlur;
} else {
    window.onfocus = onFocus;
    window.onblur = onBlur;
}

jQuery(document).ready(function($){
	// youtube bannery
	$('.youtube-banner','#content').click(function(){
		var videoId = $(this).attr('vidid');
		$(this).replaceWith('<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/'+videoId+'?fs=1&amp;hl=cs_CZ&amp;color1=0x3a3a3a&amp;color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+videoId+'?fs=1&amp;hl=cs_CZ&autoplay=1&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>');
	});
	// vimeo bannery
	$('.vimeo-banner','#content').click(function(){
		var videoId = $(this).attr('vidid');
		$(this).replaceWith('<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+videoId+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id='+videoId+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>');
	});
	
	$('input[type=text],input[type=password],textarea').focusin(function(){
		$(this).addClass('aura');
	});
	$('input[type=text],input[type=password],textarea').focusout(function() {
		$(this).removeClass('aura');
	});
});
