/**
* DEFINE DEFAULT VARIABLES
*
*/
var dom_ready = false;
var klub_bar_loaded = false;
var load_banners_onstart = true;
var slided_out;
var show_banners=false;
var IS_FLASH_SHOWN = true;
var banner_flashvar = ''; // holder for banner flashvar which we sent to player

var reload_page_on_log_out = false;
var after_login_function = "";		// procced this function after successful login
var	global_show_comments_page = 1;
var	global_show_comments_order = "asc";
var global_show_comments_type = "article";
var global_show_comments_id   = false;
var global_show_comments_ajax = true;
var banner_flashvar = ''; // holder for banner flashvar which we sent to player

if(typeof(project) == "undefined") {
	var project = '';
}

var videoList_div = new Array();
var videoList_img = new Array();

/**
*   Event loads when DOM is ready
*   This functions will fire right after HTML DOM is ready (before pictures load)
*/
window.addEvent('domready', function()
{
/**
 * SET VARIABLES
 */
dom_ready = true;

/**
 *  PRELOAD FOLLOWING IMAGES:
*/
preload_images = new Array(
        "/static/shared/img/icons/ajax.gif"
        /*"/static/shared/img/icons/ico_home_page_ff_on.gif",
        "/static/shared/img/icons/ico_home_page_ie_on.gif",
        "/static/shared/img/icons/ico_home_page_netscape_on.gif",
        "/static/shared/img/icons/ico_home_page_opera_on.gif",
        "/static/shared/img/icons/ico_home_page_safari_on.gif",
        "/static/shared/img/icons/ico_home_page_ff_off.gif",
        "/static/shared/img/icons/ico_home_page_ie_off.gif",
        "/static/shared/img/icons/ico_home_page_netscape_off.gif",
        "/static/shared/img/icons/ico_home_page_opera_off.gif",
        "/static/shared/img/icons/ico_home_page_safari_off.gif"*/
);

preload_images.each ( function(el_url) {
        var tmp_image = new Image();
        tmp_image.src = el_url;
});

// fills in the username or registration link
reload_user_info();

});

//  Opens links '.external-link' in new tab/window
jQuery("a.external-link").live( 'click', function(){
		window.open( jQuery(this).attr('href') );
		return false;
});

/**
*  ########################################################################################
*  ############################  FUNCTIONS BELOW THIS LINE  ###############################
*  ########################################################################################
*/

function iframes_resize(el)
{
        if (el.contentDocument && el.contentDocument.body.offsetHeight) 
        {
                // W3C DOM (and Mozilla) syntax
                el.height = el.contentDocument.body.offsetHeight;
        } 
        else if (el.Document ) 
        {
                el.Document.body.onload = new function() {
                        if (el.Document.body.scrollHeight)
                        {
                                el.height = el.Document.body.scrollHeight;
                        }
                }
        }
}

function include_css(file)  	 
{ 	 
if (document.createElement && document.getElementsByTagName) { 	 
var d_head = document.getElementsByTagName('head')[0]; 	 
 
var d_script = document.createElement('link'); 	 
d_script.setAttribute('type', 'text/css'); 	 
d_script.setAttribute('rel', 'stylesheet'); 	 
d_script.setAttribute('href', file); 	 
 
d_head.appendChild(d_script); 	 
} 	 
}

/**
 * Return cookie name
 */
function getCookieName(name)
{
	return project + '_auth_' + name;
}

/**
* Reloads user info with either username or registration link
* @author Matej Balantič <matej@balantic.si>
* @author Tomas Korcak <tomas.korcak@cet21.cz>
*/
function reload_user_info()
{
	// Forum part
	if ($('forum_enable_answer')) {
		$('forum_enable_answer').setStyle('display', Cookie.get('forum_user') ? '' : 'none');
	}
}

/**
* Make ajax request and call callback function on success
* 
* @param string url
* @param function callback
* @param object scope
* @param bool enableCache
* @return void
*/
function ajaxCall(url, callback, scope, enableCache)
{
// Disable request caching
if (enableCache !== true) {
        var ts = +new Date();
        // try replacing _= if it is there
        var ret = url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
        // if nothing was replaced, add timestamp to the end
        url = ret + ((ret == url) ? (url.match(/\?/) ? "&" : "?") + "_=" + ts : "");
}

new Ajax(url, {
         method: 'get'
        ,encoding: 'utf-8'
        ,onComplete: function(response) {
                // Call callback user function
                if (typeof callback == 'function') {
                        // Execute with scope
                        var scope = scope || this || document;
                        callback.call(scope);
                }
    }
}).request();
}

/**
* Logouts user account and refreshes page if needed
* 
* @return void
*/
function doLogout()
{
// Do logout and call reload_user_info when finished
ajaxCall('/lbin/jyxo_reg.php?what=logout', function() {
        if (location.href.match(/\/(registrace|profil)/))
                location.href = '/';

        // Refresh page after user logout??
        if (reload_page_on_log_out == true){
            location.reload(true);
        }
        
        JyxoCrossDomain.logout(this.href);
        reload_user_info();
});
}

function open_close_subform(div_id,div_head)
{
var div_name = $(div_id);
if(div_name)  {
        if (div_name.style.display == "block") {
                if (div_id == 'video_content') {
                        try {
                                $('flvvideo').innerHTML = ""; //remove flvvideo
                        } catch(e) {
                                null;
                        }
                }
                div_name.style.display = "none";
                $(div_head).className = "head";
                
        } else {
                div_name.style.display = "block";
                $(div_head).className = "headopen";
                if (div_id == 'video_content') {
                        video_player_setup(); //reopen flvvideo
                }
        }
}	
}


/**
 * Sends AJAX request to $script_name and updates $div_name with results.
 * Animates $div_name while waiting for AJAX response
 * @param div_name Name of the div to write in
 * @param script_name name of the script to execute
 * @param callbackFn Calback function executed after successful request
 * @param callbackFnScope Scope in which callback function will be executed
 * @author Anže Robida
 * @author Matej Balantič <matej@balantic.si> (ajax-loader animation)
 * @author Tomáš Korčák, CET21, spol. s r.o. (callback function and scope)
 */
function returnContent(div_name,script_name,media_title,media_id,callbackFn,callbackFnScope) {

// hide flash
flash_show(false, $(div_name));

slided_out = false;

// create hover layer
var hover_layer = new Element("div")
        .setStyle('position', 'absolute')
        .setStyles($(div_name).getCoordinates())
        .injectInside(document.body)
        .setOpacity(0.3)
        .setStyles({
                        'background-color':'black',
                        'position': 'absolute',
                        'z-index': '5'
                });


if (div_name == 'vsection_content_margin')
{
        hover_layer.setStyles({
                        'margin-left': '10px'
                });
}

// create ajax loader
var ajax_load = new Element("img")
ajax_load.src = '/static/shared/img/icons/ajax.gif';
move_top  =   ($(div_name).getPosition()['y'] + $(div_name).getSize()['size']['y']/2) - (ajax_load.height/2);
move_left =   ($(div_name).getPosition()['x'] + $(div_name).getSize()['size']['x']/2) - (ajax_load.width/2);
ajax_load.setStyles({
                "position": 	'absolute',
                "top": 		 	move_top,
                "left":			move_left,
                "z-index": 		'10'
        }).injectInside(document.body);

// call ajax script
new Ajax(script_name, {
        method: 'get',
        encoding: 'UTF-8',
        onComplete: function(response)
        {
                $(div_name).innerHTML = response;

                if (div_name == 'videosection' || div_name == 'video_section_main_video') {
                        //put # tag into location
                        var url_temp = window.location.href; //parse fixed location
                        url_temp = url_temp.substring(0,url_temp.indexOf('#')); 
                        var media_id = script_name; //parse media_id
                        media_id = media_id.substring(media_id.indexOf('media_id=')+9);
                        media_id = parseInt(media_id.substring(0,media_id.indexOf('section_id')-1));
                        window.location = url_temp + '#media_id=' + media_id;

                        $('video_main_box').setStyle("visibility",'visible');
                }

                //if video page
                if (div_name == 'videosection' || div_name == 'video_section_main_video' || div_name == 'embed_flvvideo') {
                        //replace title of the window - for ajax calls
                        if (div_name != 'embed_flvvideo') {
                                var explodestring = document.title;
                                explodestring = explodestring.split('-');
                                explodestring = explodestring[explodestring.length-1];
                                explodestring = explodestring.split('#');
                                explodestring = explodestring[0];
                                if (media_title) {
                                        document.title = media_title + ' - ' + explodestring.trim();
                                }
                        }
                        else
                        {
                                autostart = true; // we automaticaly start video if requested through ajax in article
                        }
                }
                
                //change style of active media
                if (media_id) {
                        try {
                                //remove background of non-active media
                                $ES('.small_video').each ( function(el) 
                                {
                                        el.setStyles({background: ''});			  
                                });
                                
                                $("media_id_"+media_id).setStyles({background: 'url(/static/'+app_lang+'/main/img/backgrounds/back_video.gif) repeat-y'});
                                
                        } catch(e) {
                                null;
                        }
                        
                }

                // show flash back
                flash_show(true, $(div_name));

                // destroy ajax loader & div layer
                hover_layer.remove();

                ajax_load.remove();

                // if CZ photogalery page
                if (div_name == 'cz_photo_gallery_list_detail') {
      //setTimeout('cz_photogallery_list_ajax_refresh()', 500);
      cz_photogallery_list_ajax_refresh();
      gal_init();
    }
    
    if (script_name.indexOf("ajax_chart_vote.php?id=") != -1)
        ajaxLoadCentralChartDetail();
    if (script_name.indexOf("ajax_chart_detail.php?id=") != -1)
        ajaxLoadRightChartVote();


		// Call callback user function
		if (typeof callbackFn == 'function') {
			// Execute with scope
			var scope = callbackFnScope || this || document;
			callbackFn.call(scope);
		}


        },
        // do eval scripts inside the AJAX response
        evalScripts: true
}).request();
} 

function do_slide() {

if (!slided_out)
{
        setTimeout(do_slide,300);
        return true;
}
mySlide.slideIn();
}

/**
* REGISTRATION FUNCTIONS
*/

function close_banner() {}
function open_banner() {}
function pre_fullscreen() {
if (typeof(reload_tmout) != 'undefined')
{
        if (reload_tmout != null)
        {
                clearTimeout(reload_tmout);
        }
}
}

function post_fullscreen() {}

function login_show()
{
	if (klub_bar_loaded == true) {
		jQuery('#crLogin').trigger('click');
		return false;
	} else {
		close_banner();
		mbox_open(500, 500);
		pre_fullscreen();

		step_1_help = new Array("main_help");
		active_step = 1;
		help_displayed = 0;

		new Ajax('/bin/registration2/login.php', {
			 method: 'get',
			 encoding: 'utf-8',
			 update: $('MBOX_window'),
			 evalScripts: true
		}).request();
	}
}


function register_show()
{
	if (klub_bar_loaded == true) {
		jQuery('#crRegister').trigger('click');
		return false;
	} else {
		window.location = 'http://tv.nova.cz/registrace';
		return false;
		/*close_banner();
		mbox_open(500, 500);
		pre_fullscreen();

		// help boxes in step 1
		step_1_help = new Array("username_help", "password_help", "email_help", "main_help");

		// url of script for ajax purposes
		registration_script_url = '/bin/registration2/';

		// how many steps are there
		all_steps = 3;
		active_step = 1;

		// help box visibility status
		help_displayed = false;

		password_renewal = false;

		load_settings();

		url = '/bin/registration2/' + '?action=display' + '&what=1' + '&return=' + location.href;
		new Ajax(url, {
			 method: 'get',
			 encoding: 'utf-8',
			 update: $('MBOX_window'),
			 onComplete: register_show_complete,
			 evalScripts: true
			}).request();*/
	}
}


function register_show_complete( result )
{
active_step = $('active_step').value;

// get HTML code of ajax loader
ajax_loader     = $('ajax_loader_div').innerHTML;
ajax_loader_big = $('ajax_loader_big_div').innerHTML;

build_indicators( $('active_step').value );
}


function load_settings()
{
new Ajax('/bin/registration2/' + '?action=javascript' + '&what=register', {
     method: 'get',
     encoding: 'utf-8',
     onComplete: load_settings_complete
    }).request();
}


function load_settings_complete( result )
{
eval( result );
}

/*
* Function send article
* @param div_name Name of the div to write in
* @param script_name name of the script to execute
* @param text_ok text if article was sent
* @param text_error text if there goes something wrong
*
*/
function articleSend(div_name,script_name,text_ok, text_error,form_id) {

if(script_name.indexOf('?')>0){script_name+="&title="+encodeURI(document.title);}else{script_name+="?title="+encodeURI(document.title);}
new Ajax(script_name, {
        method: 'post',
        encoding: 'utf-8',
        postBody: document.article_send,
        onComplete: function(response) {
                if (response == 'OK') {
                         $(div_name).innerHTML = text_ok;
                         setTimeout("showSendArticleForm('"+form_id+"')",1300);
                         
                } else {
                        $(div_name).innerHTML = text_error;
                }
        }
}).request();
}

/**
* This function execute PHP file, which write into database rating for current video creator
*/
function ajax_put_video_creator_vote(id, vote) {

var url = '/bin/ajax_video_creator_vote.php?id='+id+'&rate=' + vote;

new Ajax(url, {
        method: 'get'
}).request();
}
/**
* This function execute PHP file, which write into database rating for current article
*/
function ajax_put_vote(article_id, vote) {

var url = '/bin/ajax_article_vote.php?article_id=' + article_id + '&rate=' + vote;

new Ajax(url, {
        method: 'get'
}).request();
}

/**
* This function execute PHP file, which write into database rating for current media
*/
function ajax_put_media_vote(article_id, vote) {

var url = '/bin/ajax_media_vote.php?media_id=' + article_id + '&rate=' + vote;
var result; 
new Ajax(url, {
        method: 'get',
        onComplete: function(response){
                result = response;                        
                result=result.split("~");
                
                if (result.length > 1 && result[1] !='') {
                        $('article_vote_container').style.display = 'block';
                        $('article_vote_container').innerHTML = "<img src='" + result[1] + "' id='vote_stars'/>";
                }
                else {
                        $('article_vote_container_err').style.display = 'block';
                }
        }
}).request();
return "a"+result;
}

/**
* Function sends content of form to email via ajax
*/


function ajax_write_us(text_wait, text_saved, text_pwd, text_bnd, text_pnd, text_err, text_act, text_sent) {

var url = '/lbin/ajax_write_us.php';

//write "wait" message
span_comment_msg_1 = $('span_comment_msg');
if (!span_comment_msg_1)
        return false;
span_comment_msg_1.innerHTML = text_wait;

new Ajax(url, {
        method: 'post',
        postBody: document.comment_send,
        onComplete: function(response) {

                var result_1 = response.replace(/^\s+|\s+$/g, "");
                if (result_1 == 'SUCCESS') {
                        $('comments_form').innerHTML = '<div style="text-align: center;">Vaše zpráva byla úspěšně odeslána. Děkujeme.</div>';
                }
                if (result_1 == 'NO_TEXT') {
                        span_comment_msg_1.innerHTML = "Zadejte prosím text zprávy.";
                }
                if (result_1 == 'F_WORDS') {
                        span_comment_msg_1.innerHTML = "Text obsahuje neslušná slova.";
                }
                if (result_1 == 'MAIL_ERROR') {
                        span_comment_msg_1.innerHTML = "Zprávu se bohužel nepovedlo odeslat.";
                }
                if (result_1 == 'WRONG_EMAIL') {
                        span_comment_msg_1.innerHTML = "Zadejte platnou emailovou adresu.";
                }
                if (result_1 == 'CAPTCHA_ERROR') {
                        span_comment_msg_1.innerHTML = "Chybný kontrolní kód.";
                }
                if (result_1 == 'LADICI') {
                        span_comment_msg_1.innerHTML = "ladime";
                }
        }
}).request();


}


/**
* Function sends comment on article to server
*/
function ajax_comment_send(type, text_wait, text_saved, text_pwd, text_bnd, text_pnd, text_err, text_act, text_sent,text_invalid_captcha,text_empty_username, text_dirty) {
var url = '/lbin/ajax_comments_save_'+type+'.php';

if ($('comment_txt').value == '')
        return false;

//write "wait" message
span_comment_msg_1 = $('span_comment_msg');
if (!span_comment_msg_1)
        return false;
span_comment_msg_1.innerHTML = text_wait;

new Ajax(url, {
        method: 'post',
        postBody: document.comment_send,
        onComplete: function(response) {
                var result_1 = response;
                //comment not saved
                if (result_1 == "CAP" || result_1 == 'CAPTCHA_ERR') {				
                        if(typeof window.cleancommentform == 'function')	
                        {
                                cleancommentform(true)	
                        }		
                        span_comment_msg_1.innerHTML = text_invalid_captcha;
                }
                //comment not saved
                if (result_1 == 'USER_ERR') {				
                        span_comment_msg_1.innerHTML = text_empty_username;

                }			
                //comment saved
                if (result_1 == 'SUCCESS') {
                        if(typeof window.cleancommentform == 'function')	
                        {
                                cleancommentform()	
                        }	
                        span_comment_msg_1.innerHTML = text_saved;
                        show_comments();
                }

                //user banned temp
                if (result_1 == 'BND')
                        span_comment_msg_1.innerHTML = text_bnd;


                //password inavlid
                if (response == 'PWD')
                        span_comment_msg_1.innerHTML = text_pwd;

                //comment already sent
                if (response == 'OK')
                        span_comment_msg_1.innerHTML = text_sent;

                //user banned
                if (response == 'PND')
                        span_comment_msg_1.innerHTML = text_pnd;

                //common error
                if (response == 'ERR')
                        span_comment_msg_1.innerHTML = text_err;

                //user is not activated
                if (response == 'ACT')
                        span_comment_msg_1.innerHTML = text_act;
                
    			//dirty words error
    			if (response == 'DIRTY')
    				span_comment_msg_1.innerHTML = text_dirty;
        }
}).request();
}

function show_comments(type, id, page, order) {
if (!global_show_comments_ajax && page) {
        var params = new Array;
        params['page'] = page;
        params['p_all_items'] = '';
        document.location.href = modify_url(document.location.href, params, null, 'comments');
        return;
}

// updating after user post
if (typeof(id) === "undefined")
{
        type	= global_show_comments_type;
        id 		= global_show_comments_id;
        order 	= global_show_comments_order;
        if (order == "desc" || order == "DESC")
                page = 1;
        else
                page = "last";
}

        
global_show_comments_type = type;
global_show_comments_id   = id;	
global_show_comments_page = page;
global_show_comments_order = order;


var url = '/bin/ajax_comments.php?type='+type+'&id=' + id + '&page=' + page + '&order=' + order + '&max_number=10';

new Ajax(url, {
        method: 'get',
        onComplete: function(resp) {
                new_div = new Element('div')
                .setHTML(resp);

                $('comments').replaceWith(new_div);

        }
}).request();

}
/*
* This Function is used for show all comments without Paging
*/
function show_all_comments(type, id, max_number, order) {
// updating after user post
if (typeof(id) === "undefined")
{
        type	= global_show_comments_type;
        id 		= global_show_comments_id;
        order 	= global_show_comments_order;
        if (order == "desc" || order == "DESC")
                page = 1;
        else
                page = "last";
}

global_show_comments_type = type;
global_show_comments_id   = id;	
global_show_comments_max_number = max_number;
global_show_comments_order = order;

var url = '/bin/ajax_show_all_comments.php?type='+type+'&id=' + id + '&page=1&order=' + order + '&max_number='+max_number;
new Ajax(url, {
        method: 'get',
        onComplete: function(resp) {
                new_div = new Element('div')
                .setHTML(resp);

                $('comments').replaceWith(new_div);

        }
}).request();

}

function homepage_img_change(browser) {
$ES('.homepage_button').each ( function (el) {
        curr_browser = el.id.split("_")[1];
        el.src = '/static/shared/img/icons/ico_home_page_'+curr_browser+'_on.gif';
});
if (!browser)
        browser = selected_browser;

$("image_"+browser).src = '/static/shared/img/icons/ico_home_page_'+browser+'_off.gif';

}

function homepage_browser(browser_name)
{
new Ajax('/bin/homepage.php?browser='+browser_name, {
        method: 'get',
        encoding: 'utf-8',
        update: $('MBOX_window'),
        onComplete: function () { homepage_insert(browser_name); }
}).request();

}

function homepage_get_browser()
{
if (window.ie)
        return "ie";
if (window.gecko)
        return "ff";
if (window.webkit)
        return "safari";
if (window.opera)
        return "opera";

}
//insert text into MBOX
function homepage_insert(browser_name)
{
if (browser_name=="firefox") browser_name="ff";
if (browser_name=="explorer") browser_name="ie";

selected_browser = browser_name;
homepage_img_change(browser_name);
}

function bookmark_show(siteURL)
{


if (window.ie)
{

        var html_body = document.getElementsByTagName('body').item(0);
        var homepage_link = document.createElement('a');
        html_body.appendChild(homepage_link);
        homepage_link.style.display = 'none';

        homepage_link.style.behavior='url(#default#homepage)';
        homepage_link.setHomePage(siteURL);

}
else
{
        // hide for now - not translated yet
        mbox_open(450,200);
        if (window.gecko)
        {
                homepage_browser('firefox');
        }
        else if (window.webkit || window.webkit419 || window.webkit420)
        {
                homepage_browser('safari');
        }
        else if (window.opera == 'Opera')
        {
                homepage_browser('opera');
        }
/*		else if (browser_name == 'Netscape')
        {
                homepage_browser('netscape');
        }*/
        else {
                homepage_browser('explorer');
        }
}

}


/* Opens MBOX on the webpage
@author Matej Balantič <matej@balantic.si>
*/
function mbox_open(MBOX_WIDTH,MBOX_HEIGHT,IS_DRAGGABLE)
{
flash_show(false);

if ( typeof(IS_DRAGGABLE) == "undefined" )
        IS_DRAGGABLE = true;

// create holders if there isn't any
mbox_create_holders( IS_DRAGGABLE );

left_s = window.getWidth()/2 - MBOX_WIDTH/2;
top_s = window.getScrollTop() +(jQuery(window).height() - MBOX_HEIGHT)/2;

// push down if it is still above content
if (top_s < 180)
        top_s = 180;

$("MBOX_window").setStyles('left:'+left_s+'px; top: '+top_s+'px; display:block;');
$("MBOX_dragger").setStyles('left:'+left_s+'px; top: '+top_s+'px; display:block;');

$("MBOX_overlay").setStyles('display:block;');

$("MBOX_overlay").setStyles({"height": window.getScrollHeight()+'px', "width": window.getScrollWidth()+'px'});
$("MBOX_window").setStyles({"width": MBOX_WIDTH+'px'});
$("MBOX_dragger").setStyles({"width": MBOX_WIDTH+'px'});



new Fx.Style('MBOX_overlay', 'opacity',{duration: 400, transition: Fx.Transitions.sineInOut}).start(0,0.6);
new Fx.Style('MBOX_window',  'opacity',{duration: 250, transition: Fx.Transitions.sineInOut, onComplete:function(){  } }).start(0,1);
}


/* closes mbox
@author Matej Balantič <matej@balantic.si>
*/
function mbox_close()
{

new Fx.Style('MBOX_overlay', 'opacity',{duration: 400, transition: Fx.Transitions.sineInOut, onComplete:function(){ $("MBOX_overlay").setStyles('display:none;'); }}).start(0.6,0);
new Fx.Style('MBOX_window',  'opacity',{duration: 250, transition: Fx.Transitions.sineInOut, onComplete:function(  )
            {
                $("MBOX_window").setStyles('display:none;');
                $("MBOX_window").innerHTML = '';
                flash_show(true);

            } }).start(1,0);
$("MBOX_dragger").setStyles({"display": 'none'});
//window.location = window.location;
	if (typeof doNotReloadAfterLogin == "boolean") {
		if (!doNotReloadAfterLogin) {
			window.location = window.location;
		}
	} else {
		window.location = window.location;
	}

}
/**
* Shows / hides all FLASH & IFRAME objects on the page
* @param bool $display True when showing, false when hiding
* @author Matej Balantič <matej@balantic.si>
*/
function flash_show(display, div_name)
{
if (display)
{
        stats = 'visible';
        IS_FLASH_SHOWN = true;
}
else
{
        stats = 'hidden';
        IS_FLASH_SHOWN = false;
}

if (window.ie)
        flash_container = 'object';
else
        flash_container = 'embed';

// don't set style with mootools; doesn't work in IE6	
$ES(flash_container,div_name).each ( function (el) {
        el.style.visibility = stats;
});

$ES('iframe', div_name).each ( function (el) {
        el.style.visibility = stats;
});
}
/* makes mbox draggable & creates mbox holders
@author Matej
*/
function mbox_create_holders( is_draggable )
{
if ($('MBOX_overlay'))
{
        $("MBOX_overlay").remove();
        $("MBOX_dragger").remove();
        $("MBOX_window").remove();
}

include_css('/static/shared/css/mbox.css');
// CREATE MBOX HOLDERS

var mbox_overlay = new Element('div', {
        'id' : 'MBOX_overlay'
})
.injectInside(document.body);

var mbox_dragger = new Element('div', {
        'id': 'MBOX_dragger'
})
.injectInside(document.body);

var mbox_window = new Element('div', {
        'id': 'MBOX_window'
})
.injectInside(document.body);

var mbox_window_loading = new Element('div', {
        'id': 'MBOX_loading'
})
.injectInside(mbox_window);

var mbox_window_loading_img = new Element('img', {
        'src': "/static/shared/img/ajax-loader-white.gif",
        'alt': 'Loading'
})
.injectInside(mbox_window_loading);

// CREATE DROP
if ( is_draggable ) {
        var main_content = $('left');

        mbox_dragger.addEvent('mousedown', function(e) {
                e = new Event(e).stop();
                mbox_window.setStyles({
                        'opacity':0.7
                });
                drag = mbox_window.makeDraggable({
                        container: main_content
                }); // this returns the dragged element
                drag.start(e); // start the event manual
        });

        mbox_window.addEvent('emptydrop', function() 
        {
                mbox_dragger.setStyles({
                        'left': this.getCoordinates().left,
                        'top': this.getCoordinates().top
                });
                mbox_window.setStyles({'opacity':1});
                drag.detach();
        });
}
}

/*
*  * Image pool function - auto change images
*     @author Matej
*/
function image_change(div_name, image_array, current_img)
{
var container = $(div_name);
var all_imgs = image_array.length;

if (all_imgs <= 1)
        return true;

container.empty();
myImg = new Element("img", {
        src: image_array[current_img]['url'],
        alt: image_array[current_img]['title'],
        title: image_array[current_img]['title']
})
.setStyle("border", 0)
.setStyle("opacity", 0)
.injectInside(container);

myFx = new Fx.Style(myImg, 'opacity' , { duration: 500 }).start(0,1);

current_img = current_img+1;
if (current_img>=all_imgs)
{
        current_img = 0;
}

return current_img;
}

//special back functionallty
function back_mod() {

if (document.referrer != '')
{
        var host = location.href.split('/');
        if (document.referrer.match(host[2])) //here shold be part of domain, where should be in use normal history
        {
                history.go(-1);	
        } else {
                //fake history to current front page
                location.href = 'http://' + host[2] + '/bin/front.php?section_id='+section_id; 
        }
}
}
//ajax function for voting
function poll_vote(formx,voteResponse,answerx,tnx_div) {

document.getElementById(voteResponse).style.visibility = 'hidden';

if (typeof(tnx_div) == 'undefined')
        tnx_div = 'tnx_for_vote';

formx.answer_id.value = answerx;

formx.send ({
        encoding: 'UTF-8',
        onComplete: function(response)
        {
                document.getElementById(voteResponse).innerHTML = response;
                document.getElementById(voteResponse).style.visibility = 'visible';
                
                //if (voteResponse[response] != 'undefined')
                //{
                //	formx.getElements("div[rel=" + tnx_div + "]")[0].setHTML(voteResponse[response]);
                //}
        }
});
}

/*
Function change fotn size of defined object, with requested factor, not exceed limited size
*/

function change_font_size(obj, fact, limit) {
var currentFontSize = obj.style.fontSize;
var currentFontSizeNum = parseFloat(currentFontSize);
var newFontSize = currentFontSizeNum*fact;
if ((fact<1) && (newFontSize<limit)) newFontSize = limit;  
if ((fact>1) && (newFontSize>limit)) newFontSize = limit;  
obj.style.fontSize = newFontSize+"px";





}
/*
Function change font size for article
*/

function change_font_size1(type) {

var resize = 0;

//limit increse to 1
if (type == 'increase' && default_font_size == 4) {
        return false;
}


//limit decrese to 0
if (type == 'decrease' && default_font_size == 0) {


        return false;	
}

//set changes
if (type == 'decrease') {
        default_font_size = parseInt(default_font_size) - 1;
        resize = -2;
} else if (type == 'increase') {
        default_font_size = parseInt(default_font_size) + 1;
        resize = 2;
} else if (type == 'default') {
        resize = (1 - default_font_size) * 2;
        default_font_size = 1; 
} else
        resize = (default_font_size-1) * 2; 
        
//do resize
$ES('h1,h2,h3.source1,p,div.summary','article').each ( function (el) {
        temp_size = parseInt(el.getStyle('fontSize')) + resize;
        el.style.fontSize = temp_size+'px';
});

//disable buttons
if (default_font_size == 4) {
        $('increase').innerHTML = '<img src="/static/slo/main/img/backgrounds/zoom_in_font_size.gif" alt="Povečaj pisavo" title="Povečaj pisavo" />';
        $('decrease').innerHTML = '<a href="" onclick="change_font_size1(\'decrease\'); return false;" alt="Zmanjšaj pisavo" title="Zmanjšaj pisavo">&nbsp;</a>';
        $('default').innerHTML = '<a href="" onclick="change_font_size1(\'default\'); return false;" alt="Privzeta velikost besedila" title="Privzeta velikost besedila">&nbsp;</a>';
} else if (default_font_size == 0) {
        $('increase').innerHTML = '<a href="" onclick="change_font_size1(\'increase\'); return false;" alt="Povečaj pisavo" title="Povečaj pisavo">&nbsp;</a>';
        $('decrease').innerHTML = '<img src="/static/slo/main/img/backgrounds/zoom_out_font_size.gif" alt="Zmanjšaj pisavo" title="Zmanjšaj pisavo"/>';
        $('default').innerHTML = '<a href="" onclick="change_font_size1(\'default\'); return false;" alt="Privzeta velikost besedila" title="Privzeta velikost besedila">&nbsp;</a>';
} else if (default_font_size == 1) {
        $('increase').innerHTML = '<a href="" onclick="change_font_size1(\'increase\'); return false;" alt="Povečaj pisavo" title="Povečaj pisavo">&nbsp;</a>';
        $('decrease').innerHTML = '<a href="" onclick="change_font_size1(\'decrease\'); return false;" alt="Zmanjšaj pisavo" title="Zmanjšaj pisavo">&nbsp;</a>';
        $('default').innerHTML = '<img src="/static/slo/main/img/backgrounds/reset_font_size.gif" alt="Privzeta velikost besedila" title="Privzeta velikost besedila" />';





} else {
        $('increase').innerHTML = '<a href="" onclick="change_font_size1(\'increase\'); return false;" alt="Povečaj pisavo" title="Povečaj pisavo">&nbsp;</a>';
        $('decrease').innerHTML = '<a href="" onclick="change_font_size1(\'decrease\'); return false;" alt="Zmanjšaj pisavo" title="Zmanjšaj pisavo">&nbsp;</a>';
        $('default').innerHTML = '<a href="" onclick="change_font_size1(\'default\'); return false;" alt="Privzeta velikost besedila" title="Privzeta velikost besedila">&nbsp;</a>';

}

//sets cookie
var myCookieSize = Cookie.set('default_font_size', default_font_size);

}

// replace all videos but active with thumbnails
function videoList_forceThumbnails(active) {
for (i = 0; i < videoList_div.length; i++) {
        if (videoList_div[i] != active) {
                $(videoList_div[i]).innerHTML = videoList_img[i];
        }
}
}

function printpr() {
window.print();
return false;
}

function chart_login(box,number) {
login_show();
$('MBOX_window').onclose = function() {
        if (box == 1) {
                returnContent('cz_box_right_chart_vote','/lbin/ajax_chart_vote.php?id='+number);
        } else {
                returnContent('cz_box_central_chart_detail','/lbin/ajax_chart_detail.php?id='+number);
        }
}
}

function showVideoInLightbox(mediaID, microsite, width, height, movie_config, movie_path, movie_color) {
// default values
if (typeof(mediaID) == "undefined") {
return;
}
if (typeof(microsite) == "undefined") {
microsite = "23000";
}
if (typeof(width) == "undefined") {
width = 608;
}
if (typeof(height) == "undefined") {
height = 342;
}
if (typeof(movie_config) == "undefined") {
movie_config = "http://tn.nova.cz/bin/player/config.php?site_id=23000";
}
if (typeof(movie_path) == "undefined") {
movie_path = "http://archiv.nova.cz/static/cz/shared/app/MediaCenter_Catchup.swf";
}
if (typeof(movie_color) == "undefined") {
movie_color = "#086B85";
}
close_banner();
mbox_open(width, height+55);
pre_fullscreen();
$('MBOX_window').innerHTML = '<div style="background: #1a1a1a url(/static/cz/microsites/default/img/lb_player_close.gif) right center no-repeat; text-align: right;"><a href="#" onclick="javascript: mbox_close(); return false;" style="padding-right: 22px; color: #079fc6;">zavřít</a></div><div id="MBOX_video"> </div>';
media_id = mediaID;
player_referer = microsite;
load_banners_onstart = false;
_text_flash_no = "<div class=\"notice\"><span class=\"red\">$$NO_FLASH_4$$</span><br /><div class=\"gray\">$$NO_FLASH_2$$ <a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&amp;promoid=BIOW\" target=\"_blank\">$$NO_FLASH_3$$</a>.</div>";
player_width = width;
player_height = height;
config_file = movie_config;
//playlist_file = '';
media_center_swf = movie_path;
player_color = movie_color;
player_h264 = true;

if (window.location.href.indexOf("#video") != -1) {
        autostart = true;
} else {
        autostart = false;
}
autostart = true;
video_div = "MBOX_video";
videoList_forceThumbnails(video_div);
video_player_setup();
}

/*
Function submit form press enter
*/
function submitEnter(form,e,fnc){
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  else return true;
  
  var inputs = $ES('input[type=text],input[type=password]', form); 
  if(keycode == 13){  
    for(var i=0; i<inputs.length ; i++) {
      if(!inputs[i].value.length) {
        inputs[i].focus();
        return false;
      }
    }
    if (fnc) return fnc();
    else $(form).submit();
  }
  return true;
}

function modify_url(url, new_prms, old_prms_regex_test, anchor) {
   // strip anchor	
   var re = /^(\S+)#(\S+)$/i;
   var matches = url.match(re);
   if (matches !== null) {
	   url = matches[1];
	   if (!anchor) {
		   anchor = matches[2]
	   }
   }
   
   var url_elements = url.indexOf('?') < 0 ? [url, ''] : url.split('?');
   var prms = {};
   var i;
   if (url_elements[1]) {
      var prms_array = url_elements[1].indexOf('&') < 0 ? 
         [ url_elements[1] ] : url_elements[1].split('&');
      for (i = 0; i < prms_array.length; i++) {
         var prm_val = prms_array[i].indexOf('=') < 0 ? [prms_array[i], ''] : prms_array[i].split('=');
         var prm_name = unescape(prm_val[0]);
         if (! old_prms_regex_test || old_prms_regex_test.test(prm_name)) {
            prms[prm_name] = unescape(prm_val[1]);
         }
      }
   }
   for (i in new_prms) {
      prms[i] = new_prms[i];
   }
   var new_prms_str = '';

   for (i in prms) {
      if (!/^(undefined|function)$/i.test(typeof(prms[i])) && prms[i]) new_prms_str += '&' + escape(i).replace(/\+/g,'%2b') + '=' + escape(prms[i]).replace(/\//g,'%2F').replace(/\+/g,'%2b');
   }

   var ret = url_elements[0]
             + (new_prms_str ? '?' + new_prms_str.substr(1)  : '')
		     + (anchor ? '#' + anchor : '');
   return ret;
}

     /*Function to show hidden box with additional information*/

     function showBubble(){

          var actual_elem;
          var show_info = '';
          var isShow;
          
          if(typeof wrapperID == "undefined")
               {wrapperID = 'show_prewrap';}

          window.addEvent('domready',function(){

          $$(elemPath).addEvents({
               'mouseover' : function(){

                    actual_elem = this;
                    var ol = $(actual_elem).getPosition();
                    elLeftBody = ol.x;
                    widthW = document.documentElement.clientWidth || document.body.clientWidth;
                    leftScroll = window.pageXOffset || document.documentElement.scrollLeft;
                    leftPos = elLeftBody - leftScroll;
                    
                    wrapPos = $(wrapperID).getPosition();
                    wrapLeftPos = wrapPos.x - leftScroll;
                    rightPos = widthW - elemWidth - leftPos;
                    wrapRightPos = widthW - 1000 - wrapLeftPos;
                    var rightSpace = (wrapRightPos < 0)?rightPos:(rightPos - wrapRightPos);

                    if(rightSpace < bubbleWidth){
                         var params = (leftPos<rightSpace)?bubbleRightVar:bubbleLeftVar;
                    }
                    else{
                         var params = bubbleRightVar;
                    }
                    
                    var show = function(){
                         if(actual_elem == this){

                              $(this.id+'_bubble').setStyles({
                                   left:params[0],
                                   paddingLeft:params[3],
                                   opacity: 0,
                                   display:'block'
                              });

                              showBox = new Fx.Style($(this.id+'_bubble'), 'opacity', {
     						duration: bubbleDuration
               				}).start(1);

                              $(this.id+'_bubble').getElement('.arrow').setStyles({
                                   left: params[1]
                              }).addClass(params[2]).removeClass(params[4]);

                              $(this.id+'_bubble_wrap').setStyle('z-index','4');
                         }

                         isShow = 1;

                         $(this.id+'_bubble').addEvents({
                              'mouseover':function(){
                                   show_info = 1;
                                   $(this.id+'_wrap').setStyle('z-index','4');
                                   $(this).setStyle('display','block');
                              },
                              'mouseout':function(){
                                   show_info = 0;
                                   $(this).setStyle('display','none');
                                   $(this.id+'_wrap').setStyle('z-index','3');
                              }
                         });
                    }

                    timer = show.delay(bubbleDelay,this);
                    },
                    'mouseout':function(){
                         if((isShow == 1 && show_info == "") || (show_info == 0)){
                              $(this.id+'_bubble').setStyle('display','none');
                              $(this.id+'_bubble_wrap').setStyle('z-index','3');
                              show_info = '';
                         }
                         actual_elem = '';
                         $clear(timer);
                    },
                    'click':function(){
                         actual_elem = '';
                    }
               });

          });

     }

/**
 * Move titles in a list of articles from below-image to above-image positions.
 * @param boxID
 *   ID attribute of the box wrapper DIV.
 * @param itemSelector
 *   Mootools selector string of the list item in the context of the box DIV.  
 * @param titleSelector
 *   Mootools selector string of the title element in the context of the list item.
 * @param imageSelector
 *   Mootools selector string of the image element in the context of the list item.
 * @param rowCount
 *   Number of items in a row.
 */
function placeTitlesAboveImages(boxID, itemSelector, titleSelector, imageSelector, rowCount) {
	if (!rowCount) {return false;}
	var maxHeight;
 	var rowItems = new Array();
 	var box = $(boxID);
 	$ES(itemSelector, box).each(function(item, idx){
 		var title = $E(titleSelector, item).injectBefore($E(imageSelector, item));
 		var height = title.getSize().size.y;
 		maxHeight = maxHeight > height ? maxHeight : height;  // Update maxHeight according to current title height.
 		rowItems[idx % rowCount] = item;  // Fill in each row with items.
 		if (!((idx + 1) % rowCount)) {
 			// The last item in the row
 			// Set new height for title element of each item in the row.
 			rowItems.each(function(rowItem) {
 				$E(titleSelector, rowItem).setStyle('height', maxHeight);
 			});		
 			maxHeight = 0;	// Reset maxHeight for new line.
 		}
 	});
 	box.setStyles('position:relative');  // Reset position style rule of the box. 
}






/*
 
     var hover_img_selector = '.catchup_related_video .video_img_wrap .img';
     var video_box_class = '.catchup_related_video';
     var bubble_class = '.more_info';
     var elemWidth = 200;
     var bubbleWidth = 256;

*/
 
var actual_bubble = null;
var is_fade_complete = false;
var is_hover_bubble = false;

 
     function JQ_showBubble(){
               jQuery(document).ready(function(){
                    
                    jQuery(hover_img_selector).mouseover(function(e){
              
                         if(typeof wrapperID == "undefined")
                         {wrapperID = '#show_prewrap';}

                         actual_elem = this;
                         
                         var ol = jQuery(actual_elem).offset();
                         e_offset_left = ol.left;
                         window_width = jQuery(window).width();
                         left_scroll = document.documentElement.scrollLeft;
                         left_space = e_offset_left - left_scroll;

                         wrap_position = jQuery(wrapperID).position();
                         wrapLeftPos = wrap_position.left - left_scroll;
                         right_position = window_width - elemWidth - left_space;
                         wrap_right_position = window_width - 1000 - wrapLeftPos;
                         var right_space = (wrap_right_position < 0)?right_position:(right_position - wrap_right_position);
                         
                         if(right_space < bubbleWidth){
                              var side = (left_space<right_space)?null:'left_side';
                         }
                         else{
                              var side = null;
                         }
                         
              
              
                         image = this;
                         e.stopPropagation();
                         actual_bubble = jQuery(image).parents(video_box_class).find(bubble_class);
                         wrap = jQuery(image).parents(video_box_class);
                         
                         jQuery(wrap).css('z-index',3);
                         jQuery(actual_bubble).css('z-index',3).addClass(side);
                                       
                         jQuery(actual_bubble).delay(600).fadeIn('fast', function() {
                         
                              is_fade_complete = true;
                              
                              jQuery(this).mouseover(function(){
                                   is_hover_bubble = true;
                                   
                                   jQuery(this).css('display','block').addClass(side);
                                   jQuery(wrap).css('z-index',3);
                                   jQuery(actual_bubble).css('z-index',3);
                                   
                                   jQuery(this).mouseleave(function(){
                                        jQuery(this).removeClass('left_side').css('display','none');
                                        jQuery(wrap).css('z-index',0);
                                        is_fade_complete = false;
                                        is_hover_bubble = false;
                                        
                                   });                              
                              });                             
                                                       
                         });
                         
                         hoverImg(image); 
                    
                    });
                    
               });//end ready
                    
               }
          
          
               function hoverImg(elem){
               
                    jQuery(elem).mouseleave(function(){
                    
                         if(is_fade_complete && is_hover_bubble){
                              
                         }
                         else{
                              jQuery(actual_bubble).removeClass('left_side').css('display','none');
                              jQuery(actual_bubble).clearQueue();
                              
                              jQuery(elem).parents(video_box_class).css('z-index',0);
                              jQuery(actual_bubble).css('z-index',0);
                              
                              is_fade_complete = false;
                              is_hover_bubble = false;
                         }
                    
                    });
               }

            // ColorBox v1.3.18 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
            // Copyright (c) 2011 Jack Moore - jack@colorpowered.com
            // Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
            (function(a,b,c){function Y(c,d,e){var g=b.createElement(c);return d&&(g.id=f+d),e&&(g.style.cssText=e),a(g)}function Z(a){var b=y.length,c=(Q+a)%b;return c<0?b+c:c}function $(a,b){return Math.round((/%/.test(a)?(b==="x"?z.width():z.height())/100:1)*parseInt(a,10))}function _(a){return K.photo||/\.(gif|png|jpe?g|bmp|ico)((#|\?).*)?$/i.test(a)}function ba(){var b;K=a.extend({},a.data(P,e));for(b in K)a.isFunction(K[b])&&b.slice(0,2)!=="on"&&(K[b]=K[b].call(P));K.rel=K.rel||P.rel||"nofollow",K.href=K.href||a(P).attr("href"),K.title=K.title||P.title,typeof K.href=="string"&&(K.href=a.trim(K.href))}function bb(b,c){a.event.trigger(b),c&&c.call(P)}function bc(){var a,b=f+"Slideshow_",c="click."+f,d,e,g;K.slideshow&&y[1]?(d=function(){F.text(K.slideshowStop).unbind(c).bind(j,function(){if(Q<y.length-1||K.loop)a=setTimeout(W.next,K.slideshowSpeed)}).bind(i,function(){clearTimeout(a)}).one(c+" "+k,e),r.removeClass(b+"off").addClass(b+"on"),a=setTimeout(W.next,K.slideshowSpeed)},e=function(){clearTimeout(a),F.text(K.slideshowStart).unbind([j,i,k,c].join(" ")).one(c,function(){W.next(),d()}),r.removeClass(b+"on").addClass(b+"off")},K.slideshowAuto?d():e()):r.removeClass(b+"off "+b+"on")}function bd(b){if(!U){P=b,ba(),y=a(P),Q=0,K.rel!=="nofollow"&&(y=a("."+g).filter(function(){var b=a.data(this,e).rel||this.rel;return b===K.rel}),Q=y.index(P),Q===-1&&(y=y.add(P),Q=y.length-1));if(!S){S=T=!0,r.show();if(K.returnFocus)try{P.blur(),a(P).one(l,function(){try{this.focus()}catch(a){}})}catch(c){}q.css({opacity:+K.opacity,cursor:K.overlayClose?"pointer":"auto"}).show(),K.w=$(K.initialWidth,"x"),K.h=$(K.initialHeight,"y"),W.position(),o&&z.bind("resize."+p+" scroll."+p,function(){q.css({width:z.width(),height:z.height(),top:z.scrollTop(),left:z.scrollLeft()})}).trigger("resize."+p),bb(h,K.onOpen),J.add(D).hide(),I.html(K.close).show()}W.load(!0)}}var d={transition:"elastic",speed:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:!1,returnFocus:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:undefined},e="colorbox",f="cbox",g=f+"Element",h=f+"_open",i=f+"_load",j=f+"_complete",k=f+"_cleanup",l=f+"_closed",m=f+"_purge",n=a.browser.msie&&!a.support.opacity,o=n&&a.browser.version<7,p=f+"_IE6",q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X="div";W=a.fn[e]=a[e]=function(b,c){var f=this;b=b||{},W.init();if(!f[0]){if(f.selector)return f;f=a("<a/>"),b.open=!0}return c&&(b.onComplete=c),f.each(function(){a.data(this,e,a.extend({},a.data(this,e)||d,b)),a(this).addClass(g)}),(a.isFunction(b.open)&&b.open.call(f)||b.open)&&bd(f[0]),f},W.init=function(){if(!r){if(!a("body")[0]){a(W.init);return}z=a(c),r=Y(X).attr({id:e,"class":n?f+(o?"IE6":"IE"):""}),q=Y(X,"Overlay",o?"position:absolute":"").hide(),s=Y(X,"Wrapper"),t=Y(X,"Content").append(A=Y(X,"LoadedContent","width:0; height:0; overflow:hidden"),C=Y(X,"LoadingOverlay").add(Y(X,"LoadingGraphic")),D=Y(X,"Title"),E=Y(X,"Current"),G=Y(X,"Next"),H=Y(X,"Previous"),F=Y(X,"Slideshow").bind(h,bc),I=Y(X,"Close")),s.append(Y(X).append(Y(X,"TopLeft"),u=Y(X,"TopCenter"),Y(X,"TopRight")),Y(X,!1,"clear:left").append(v=Y(X,"MiddleLeft"),t,w=Y(X,"MiddleRight")),Y(X,!1,"clear:left").append(Y(X,"BottomLeft"),x=Y(X,"BottomCenter"),Y(X,"BottomRight"))).find("div div").css({"float":"left"}),B=Y(X,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),a("body").prepend(q,r.append(s,B)),L=u.height()+x.height()+t.outerHeight(!0)-t.height(),M=v.width()+w.width()+t.outerWidth(!0)-t.width(),N=A.outerHeight(!0),O=A.outerWidth(!0),r.css({"padding-bottom":L,"padding-right":M}).hide(),G.click(function(){W.next()}),H.click(function(){W.prev()}),I.click(function(){W.close()}),J=G.add(H).add(E).add(F),q.click(function(){K.overlayClose&&W.close()}),a(b).bind("keydown."+f,function(a){var b=a.keyCode;S&&K.escKey&&b===27&&(a.preventDefault(),W.close()),S&&K.arrowKey&&y[1]&&(b===37?(a.preventDefault(),H.click()):b===39&&(a.preventDefault(),G.click()))})}},W.remove=function(){r.add(q).remove(),r=null,a("."+g).removeData(e).removeClass(g)},W.position=function(a,b){function g(a){u[0].style.width=x[0].style.width=t[0].style.width=a.style.width,C[0].style.height=C[1].style.height=t[0].style.height=v[0].style.height=w[0].style.height=a.style.height}var c=0,d=0,e=r.offset();z.unbind("resize."+f),r.css({top:-99999,left:-99999}),K.fixed&&!o?r.css({position:"fixed"}):(c=z.scrollTop(),d=z.scrollLeft(),r.css({position:"absolute"})),K.right!==!1?d+=Math.max(z.width()-K.w-O-M-$(K.right,"x"),0):K.left!==!1?d+=$(K.left,"x"):d+=Math.round(Math.max(z.width()-K.w-O-M,0)/2),K.bottom!==!1?c+=Math.max(z.height()-K.h-N-L-$(K.bottom,"y"),0):K.top!==!1?c+=$(K.top,"y"):c+=Math.round(Math.max(z.height()-K.h-N-L,0)/2),r.css({top:e.top,left:e.left}),a=r.width()===K.w+O&&r.height()===K.h+N?0:a||0,s[0].style.width=s[0].style.height="9999px",r.dequeue().animate({width:K.w+O,height:K.h+N,top:c,left:d},{duration:a,complete:function(){g(this),T=!1,s[0].style.width=K.w+O+M+"px",s[0].style.height=K.h+N+L+"px",b&&b(),setTimeout(function(){z.bind("resize."+f,W.position)},1)},step:function(){g(this)}})},W.resize=function(a){S&&(a=a||{},a.width&&(K.w=$(a.width,"x")-O-M),a.innerWidth&&(K.w=$(a.innerWidth,"x")),A.css({width:K.w}),a.height&&(K.h=$(a.height,"y")-N-L),a.innerHeight&&(K.h=$(a.innerHeight,"y")),!a.innerHeight&&!a.height&&(A.css({height:"auto"}),K.h=A.height()),A.css({height:K.h}),W.position(K.transition==="none"?0:K.speed))},W.prep=function(b){function g(){return K.w=K.w||A.width(),K.w=K.mw&&K.mw<K.w?K.mw:K.w,K.w}function h(){return K.h=K.h||A.height(),K.h=K.mh&&K.mh<K.h?K.mh:K.h,K.h}if(!S)return;var c,d=K.transition==="none"?0:K.speed;A.remove(),A=Y(X,"LoadedContent").append(b),A.hide().appendTo(B.show()).css({width:g(),overflow:K.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(t),B.hide(),a(R).css({"float":"none"}),o&&a("select").not(r.find("select")).filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one(k,function(){this.style.visibility="inherit"}),c=function(){function q(){n&&r[0].style.removeAttribute("filter")}var b,c,g=y.length,h,i="frameBorder",k="allowTransparency",l,o,p;if(!S)return;l=function(){clearTimeout(V),C.hide(),bb(j,K.onComplete)},n&&R&&A.fadeIn(100),D.html(K.title).add(A).show();if(g>1){typeof K.current=="string"&&E.html(K.current.replace("{current}",Q+1).replace("{total}",g)).show(),G[K.loop||Q<g-1?"show":"hide"]().html(K.next),H[K.loop||Q?"show":"hide"]().html(K.previous),K.slideshow&&F.show();if(K.preloading){b=[Z(-1),Z(1)];while(c=y[b.pop()])o=a.data(c,e).href||c.href,a.isFunction(o)&&(o=o.call(c)),_(o)&&(p=new Image,p.src=o)}}else J.hide();K.iframe?(h=Y("iframe")[0],i in h&&(h[i]=0),k in h&&(h[k]="true"),h.name=f+ +(new Date),K.fastIframe?l():a(h).one("load",l),h.src=K.href,K.scrolling||(h.scrolling="no"),a(h).addClass(f+"Iframe").appendTo(A).one(m,function(){h.src="//about:blank"})):l(),K.transition==="fade"?r.fadeTo(d,1,q):q()},K.transition==="fade"?r.fadeTo(d,0,function(){W.position(0,c)}):W.position(d,c)},W.load=function(b){var c,d,e=W.prep;T=!0,R=!1,P=y[Q],b||ba(),bb(m),bb(i,K.onLoad),K.h=K.height?$(K.height,"y")-N-L:K.innerHeight&&$(K.innerHeight,"y"),K.w=K.width?$(K.width,"x")-O-M:K.innerWidth&&$(K.innerWidth,"x"),K.mw=K.w,K.mh=K.h,K.maxWidth&&(K.mw=$(K.maxWidth,"x")-O-M,K.mw=K.w&&K.w<K.mw?K.w:K.mw),K.maxHeight&&(K.mh=$(K.maxHeight,"y")-N-L,K.mh=K.h&&K.h<K.mh?K.h:K.mh),c=K.href,V=setTimeout(function(){C.show()},100),K.inline?(Y(X).hide().insertBefore(a(c)[0]).one(m,function(){a(this).replaceWith(A.children())}),e(a(c))):K.iframe?e(" "):K.html?e(K.html):_(c)?(a(R=new Image).addClass(f+"Photo").error(function(){K.title=!1,e(Y(X,"Error").text("This image could not be loaded"))}).load(function(){var a;R.onload=null,K.scalePhotos&&(d=function(){R.height-=R.height*a,R.width-=R.width*a},K.mw&&R.width>K.mw&&(a=(R.width-K.mw)/R.width,d()),K.mh&&R.height>K.mh&&(a=(R.height-K.mh)/R.height,d())),K.h&&(R.style.marginTop=Math.max(K.h-R.height,0)/2+"px"),y[1]&&(Q<y.length-1||K.loop)&&(R.style.cursor="pointer",R.onclick=function(){W.next()}),n&&(R.style.msInterpolationMode="bicubic"),setTimeout(function(){e(R)},1)}),setTimeout(function(){R.src=c},1)):c&&B.load(c,K.data,function(b,c,d){e(c==="error"?Y(X,"Error").text("Request unsuccessful: "+d.statusText):a(this).contents())})},W.next=function(){!T&&y[1]&&(Q<y.length-1||K.loop)&&(Q=Z(1),W.load())},W.prev=function(){!T&&y[1]&&(Q||K.loop)&&(Q=Z(-1),W.load())},W.close=function(){S&&!U&&(U=!0,S=!1,bb(k,K.onCleanup),z.unbind("."+f+" ."+p),q.fadeTo(200,0),r.stop().fadeTo(300,0,function(){r.add(q).css({opacity:1,cursor:"auto"}).hide(),bb(m),A.remove(),setTimeout(function(){U=!1,bb(l,K.onClosed)},1)}))},W.element=function(){return a(P)},W.settings=d,a("."+g,b).live("click",function(a){a.which>1||a.shiftKey||a.altKey||a.metaKey||(a.preventDefault(),bd(this))}),W.init()})(jQuery,document,this);
/* START: jQuery Pinify - support for IE9 features */

/*
* jQuery pinify Plugin v1.2
* http://ie9ify.codeplex.com
*
* Copyright 2011, Brandon Satrom and Clark Sell
* Licensed under MS-PL.
* http://ie9ify.codeplex.com/license
*
* Date: Wednesday May 11 2011 11:47:27 -05
*/
(function(d,e){function c(f,h,g){if(d("meta[name="+f+"]").length&&f!=="msapplication-task"){return}if(!h.length){return}d("<meta>",{name:f,content:h}).appendTo(g)}function a(){return(!!window.external)&&("msIsSiteMode" in window.external)}var b={init:function(g){var f={applicationName:document.title.toString(),favIcon:"http://"+location.host+"/favicon.ico",navColor:"",startUrl:"http://"+location.host,tooltip:document.title.toString(),window:"width=800;height=600",tasks:[]};g=d.extend({},f,g);return this.each(function(){var i=g.tasks;var h=this;if(d("link[type^=image]").length===0){d("<link />",{rel:"shortcut icon",type:"image/ico",href:g.favIcon}).appendTo(this)}c("application-name",g.applicationName,this);c("msapplication-tooltip",g.tooltip,this);c("msapplication-starturl",g.startUrl,this);c("msapplication-navbutton-color",g.navColor,this);c("msapplication-window",g.window,this);d.each(i,function(j,k){c("msapplication-task","name="+k.name+";action-uri="+k.action+";icon-uri="+k.icon,h)})})},enablePinning:function(f){return this.each(function(){f=f||"Drag this image to your Windows 7 Taskbar to pin this site with IE9";d(this).addClass("msPinSite").attr("title",f)})},enableSiteMode:function(f){f=f||"click";return this.each(function(){d(this).bind(f,function(g){g.preventDefault();try{window.external.msAddSiteMode()}catch(h){}})})},pinTeaser:function(o){if(window.external.msIsSiteMode()){return this}var j=d(this);var i={type:"hangingChad",icon:"http://"+location.host+"/favicon.ico",pinText:"Drag this image to the taskbar to pin this site",secondaryText:"Simply drag the icon or tab to taskbar to pin.",addStartLink:true,linkText:"Click here to add this site to the start menu",sticky:true,timeout:10000,style:{linkColor:"rgb(0, 108, 172)",backgroundColor:"rgb(0, 108, 172)",textColor:"white",backgroundImage:null,leftBackgoundImage:null,rightBackgoundImage:null,closeButtonImage:null}};var m,g,l,f,n,h;var k={topHat:function(){j.addClass("pinify-topHat-container pinify-teaser").css("color",o.style.textColor);if(o.style.backgoundImage){j.css("background-image",o.style.backgroundImage)}m=d("<div>",{"class":"pinify-topHat-alignment"}).appendTo(j);g=d("<div>",{"class":"pinify-topHat-content"}).appendTo(m);d("<img>",{id:"pinify-topHat-logo",src:o.icon,alt:"Drag Me","class":"msPinSite"}).appendTo(g);d("<span>").addClass("pinify-topHat-text").text(o.pinText).appendTo(g)},brandedTopHat:function(){j.addClass("pinify-brandedTopHat-container pinify-teaser").css("color",o.style.textColor);if(o.style.backgoundImage){j.css("background-image",o.style.backgroundImage)}g=d("<div>",{"class":"pinify-brandedTopHat-content"}).appendTo(j);d("<img>",{id:"pinify-brandedTopHat-firstLogo",src:o.icon,alt:"Drag Me","class":"msPinSite"}).appendTo(g);d("<img>",{id:"pinify-brandedTopHat-thirdLogo",src:o.icon,alt:"Drag Me","class":"msPinSite"}).appendTo(g);d("<div>",{"class":"pinify-mainText"}).text(o.pinText).appendTo(g);d("<div>",{"class":"pinify-brandedTopHat-secondaryText"}).text(o.secondaryText).appendTo(g)},doubleTopHat:function(){j.addClass("pinify-doubleTopHat-container pinify-teaser").css("color",o.style.textColor);l=d("<div>",{"class":"pinify-doubleTopHat-left"}).appendTo(j);if(o.style.leftBackgroundImage){d(l).css("background-image",o.style.leftBackgoundImage)}f=d("<div>",{id:"pinify-doubleTopHat-leftBar"}).appendTo(l);d("<img>",{id:"pinify-doubleTopHat-logo",src:o.icon,alt:"Drag Me","class":"msPinSite"}).appendTo(f);n=d("<div>",{"class":"pinify-doubleTopHat-right"}).appendTo(j);if(o.style.rightBackgroundImage){d(n).css("background-image",o.style.rightBackgoundImage)}d("<div>",{id:"pinify-doubleTopHat-rightBar"}).appendTo(n);h=d("<div>",{id:"pinify-doubleTopHat-rightBarMainContent"}).appendTo(n);d("<div>",{"class":"pinify-mainText"}).text(o.pinText).appendTo(h);d("<div>",{"class":"pinify-doubleTopHat-lighterText"}).text(o.secondaryText).appendTo(n)},hangingChad:function(){j.hide();j.css({color:o.style.textColor,"background-color":o.style.backgroundColor}).addClass("pinify-hanging-container pinify-teaser");d("<img>",{src:o.icon,"class":"msPinSite"}).appendTo(j);d("<div>",{"class":"pinify-hanging-content"}).appendTo(j);d("<div>",{id:"pinify-pinText"}).text(o.pinText).appendTo(j);j.fadeIn("slow")}};o=d.extend({},i,o);return this.each(function(){k[o.type]();if(!o.sticky){this.delay(o.timeout).fadeOut("slow")}else{d("<div>").addClass("pinify-closePin").click(function(){d(".pinify-teaser").slideUp("slow");j.slideUp("slow")}).appendTo(j)}if(!o.addStartLink){return}d("<a>").addClass("pinify-addSiteLink").attr("href","#").click(function(p){p.preventDefault();try{window.external.msAddSiteMode()}catch(q){}}).css("color",o.linkColor).appendTo(j).text(o.linkText)})}};d.fn.pinify=function(f){if(!a()){return this}if(b[f]){return b[f].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof f==="object"||!f){return b.init.apply(this,arguments)}else{d.error("Method "+f+" does not exist on jQuery.pinify")}}};d.pinify={};d.pinify.firstRunState=function(f){if(!a()){return 0}if(f){f=false}try{return window.external.msIsSiteModeFirstRun(f)}catch(g){return 0}};d.pinify.isPinned=function(){if(!a()){return false}try{return window.external.msIsSiteMode()}catch(f){return false}};d.pinify.addJumpList=function(h){if(!a()){return this}var f={title:"",items:[]};h=d.extend({},f,h);try{if(window.external.msIsSiteMode()){window.external.msSiteModeClearJumplist();window.external.msSiteModeCreateJumplist(h.title);var g=h.items;d.each(g,function(j,k){window.external.msSiteModeAddJumpListItem(k.name,k.url,k.icon)});window.external.msSiteModeShowJumplist()}}catch(i){}return this};d.pinify.clearJumpList=function(){if(!a()){return this}try{if(window.external.msIsSiteMode()){window.external.msSiteModeClearJumpList()}}catch(f){}};d.pinify.addOverlay=function(g){if(!a()){return this}var f={eventName:"click",title:"",icon:""};g=d.extend({},f,g);try{if(window.external.msIsSiteMode()){window.external.msSiteModeClearIconOverlay();window.external.msSiteModeSetIconOverlay(g.icon,g.title)}}catch(h){}};d.pinify.clearOverlay=function(){if(!a()){return this}try{if(window.external.msIsSiteMode()){window.external.msSiteModeClearIconOverlay()}}catch(f){}};d.pinify.flashTaskbar=function(f){if(!a()){return this}try{if(window.external.msIsSiteMode()){window.external.msSiteModeActivate()}}catch(g){}};d.pinify.createThumbbarButtons=function(i){if(!a()){return this}var g={buttons:[]};i=d.extend({},g,i);try{if(window.external.msIsSiteMode()){var j=[];var f=function(){};f.prototype.button=null;f.prototype.alternateStyle=null;f.prototype.activeStyle=0;f.prototype.click=null;var h=function(l){var n=j[l.buttonID];n.click();if(n.alternateStyle){var m=n.activeStyle===0?n.alternateStyle:0;window.external.msSiteModeShowButtonStyle(n.button,m);n.activeStyle=m}};d.each(i.buttons,function(m,p){var l=window.external.msSiteModeAddThumbBarButton(p.icon,p.name);var o;if(p.alternateStyle){var n=p.alternateStyle;o=window.external.msSiteModeAddButtonStyle(l,n.icon,n.name)}var q=new f();q.button=l;q.alternateStyle=o;q.click=p.click;j[l]=q;document.addEventListener("msthumbnailclick",h,false)});window.onunload=function(){var l;for(l in j){if(j.hasOwnProperty(l)){window.external.msSiteModeUpdateThumbBarButton(j[l].button,true,false)}}};window.onload=function(){var l;for(l in j){if(j.hasOwnProperty(l)){window.external.msSiteModeUpdateThumbBarButton(j[l].button,true,true)}}};window.external.msSiteModeShowThumbBar()}}catch(k){}}})(jQuery);

/* END: jQuery Pinify - support for IE9 features */

