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

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

/**
 *   Event loads when DOM is ready
 *   This functions will fire right after HTML DOM is ready (before pictures load)
 */
window.addEvent('domready', function()
{
	if (load_banners_onstart)
		load_banners();

	/**
	 * SET VARIABLES
	 */
	dom_ready = true;



	/**
	 *  PRELOAD FOLLOWING IMAGES:
     */
	preload_images = new Array(
//		"/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",
		"/static/shared/img/icons/ajax.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();
	
});

/**
 * 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 = '/';
    
    JyxoCrossDomain.logout(this.href);
		reload_user_info();
	});
}


/**
 *  ########################################################################################
 *  ############################  FUNCTIONS BELOW THIS LINE  ###############################
 *  ########################################################################################
 */
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();
}

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
 * @author Anže Robida
 * @author Matej Balantič <matej@balantic.si> (ajax-loader animation)
 */
function returnContent(div_name,script_name,media_title,media_id) {


	temp = $('div_hover_layer');
	if( temp){
		// looks like user is clicking to fast
		temp.innerHTML = '';
		temp = temp.remove();
		temp = null;
	}
	// hide flash
	flash_show(true, $(div_name));
	
	slided_out = false;

	// create hover layer
	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'
			});
	// we need this id for multiple clicks
	hover_layer.id = 'div_hover_layer';
	
	if (div_name == 'vsection_content_margin')
	{
		hover_layer.setStyles({
				'margin-left': '10px'
			});
	}

	// create ajax loader
	ajax_load = new Element("img")
	ajax_load.src = '/static/shared/img/icons/ajax.gif';
	move_top  =   ($(div_name).getSize()['size']['y']/2) - (ajax_load.height/2);
	move_left =   ($(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(hover_layer);	
	
	// call ajax script
	popajax = 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' || div_name == 'only_main') {
				if (media_id != undefined) { //if media id is not defined do not put this in url
					//put # tag into location
					var url_temp = window.location.href; //parse fixed location
					url_temp = url_temp.substring(0,url_temp.indexOf('#')); 
					var media_idx = script_name; //parse media_id
					media_idx = media_idx.substring(media_idx.indexOf('media_id=')+9);
					media_idx = parseInt(media_idx.substring(0,media_idx.indexOf('section_id')-1));
					window.location = url_temp + '#media_id=' + media_idx;

				}
			}

			//if video page
			if (div_name == 'videosection' || div_name == 'video_section_main_video' || div_name == 'embed_flvvideo' || div_name == 'only_main') {
				//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
					window.location.href = '#video';
				}
			}
			
			//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();
			popajax.evalScripts();
			
			/*if (div_name == 'embed_flvvideo')
				video_player_setup();*/
			

			if (div_name == 'only_main' && !isNaN(media_id)) //if media_id is set & video should start playing (only_main)
			{
				//TODO - need to check id div is populated
				video_at_thumb(media_id, 'div_big_video',440,248);
			}

			try	{
				$('video_main_box').setStyle("visibility",'visible');					
			} catch (e) {null;}
			
			//proceed gemius
			if (response.indexOf('gemius_to_proceed') !=-1 && typeof(gemius_proceed) != 'undefined' ) {
   	    pp_gemius_identifier = rc_gemius;
				gemius_proceed();
			}

		},
		// do eval scripts inside the AJAX response
		evalScripts: false 
	}).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) {

	new Ajax(script_name, {
		method: 'post',
		encoding: 'utf-8',
		postBody: document.article_send,
		onComplete: function(response) {
			if (response == 'OK') {
				$(div_name).innerHTML = text_ok;
				try	{
					$("email_to").value = "";
				} catch (r) {null;}
			} else {
				$(div_name).innerHTML = text_error;
			}
		}
	}).request();
}


/**
 * This function execute PHP file,
 * which writes into database rating for current article comment
 * and shows current rating.
 */
function ajax_put_comment_vote(comment_id, vote) {

	var url = '/bin/ajax/article_comment_vote.php?comment_id=' + comment_id + '&rating=' + vote;
	var div = 'comment_vote_' + comment_id;
	var already_voted = 'comment_already_vote_' + comment_id;

	new Ajax(url, {
		method: 'get',
		onComplete: function(response) {
			if(response == 'already'){
				$(already_voted).innerHTML = "Svoj glas ste že oddali";
			}else if ($(div)){
				// Choice of class depends on rate (negative - red, positive - green)
				if(response > 0)
					$(div).setProperty('class', 'green');
				else if(response < 0)
					$(div).setProperty('class', 'red');
				else
					$(div).setProperty('class', '');

				// we show rating
				$(div).innerHTML = response;
			}
		}
	}).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',
		onComplete: function(response) {
			if ($("vote_stars_tnx"))
				$("vote_stars_tnx").src = response;
		}
	}).request();
}


/**
 * Function sends comment on article to server
 */
function ajax_comment_send(text_wait, text_saved, text_pwd, text_bnd, text_pnd, text_err, text_act, text_sent, text_dirty, text_another, $text_cap)
{
	var url = '/lbin/ajax/comment_save.php';
	var r = Math.random();
	
	if (document.comment_send.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.substring(0,3);
			var answer_1 = response.substring(3);

			//comment saved
			if (result_1 == 'OK-') {

				comment_1 = $('comment');
				if (!comment_1)
					return false;

				comment_1.innerHTML = answer_1;

				span_comment_msg_1.innerHTML = "<span class='message'>" + text_saved + "<br /><br /><a href='#' onclick='ajax_comment_box("+$("article_id").value+"); return false;'>"+text_another+"</a></span>";
				$('form_article_comment_send').reset();
			}

			//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;

			//dirty words error
			if (response == 'DIRTY')
				span_comment_msg_1.innerHTML = text_dirty;

			//user is not activated
			if (response == 'ACT')
				span_comment_msg_1.innerHTML = text_act;
				
			//wrong captcha
/*
			if (response == 'CAP'){
				span_comment_msg_1.innerHTML = text_cap;
				img_src_1 = $('captcha');
				if (!img_src_1)
					return false;
				
				img_src_1.src = "/bin/ajax/generate_captcha.php?r="+r;
			}
*/
		}
	}).request();
}

/**
 * Function returns empty article comment box
 */
function ajax_comment_box(article_id) {

	var url = '/bin/ajax/comment_box.php?article_id='+article_id;

	new Ajax(url, {
		method: "get",
		onComplete: function(response) {
			try	{
				$('comment_form').innerHTML = response;
				reload_user_info();
			} catch (r) {}

		}
	}).request();
}

function show_article_comments(article_id, page, order, max_number) {
	
	if(!max_number)
		max_number = 10;
	
	var url = '/bin/ajax/article_comments.php?article_id=' + article_id + '&page=' + page + '&order=' + order + '&max_number='+ max_number +'&ajax=1';
		
	new Ajax(url, {
		method: 'get',
		onComplete: function(response) {

			article_comment_div = $('article_comment_id');
			if (!article_comment_div)
				return false;
			
			article_comment_div.innerHTML = response;

			//proceed gemius
			if (response.indexOf('gemius_to_proceed') !=-1 && typeof(gemius_proceed) != 'undefined' ) {
   	    pp_gemius_identifier = rc_gemius;
				gemius_proceed();
			}
				
		}
	}).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/ajax/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 < 230)
		top_s = 230;

	$("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'});
	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 description_box = $('hedline_news_image_description');
	var source_box = $('hedline_news_image_source');
	var all_imgs = image_array.length;
  var prev_img = container.getElement('img');
  prev_img.setStyle('z-index', 50);
  prev_img.setProperty('id', 'prev_img');

	myImg = new Element("img", {
		src: image_array[current_img]['url'],
		alt: image_array[current_img]['title'],
		title: image_array[current_img]['title'],
    styles: {
        'z-index': 40,
        'border': 0
    }
	})
	.injectInside(container);
	var description = image_array[current_img]['comment'];
	var source = image_array[current_img]['source'];
  (function(){ 
    $('prev_img').remove(); 
    description_box.empty();
    source_box.empty();
    description_box.appendText(description);
    source_box.appendText(source);
  }).delay(1000);

	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) {
	
	if (typeof(tnx_div) == 'undefined')
		tnx_div = 'tnx_for_vote';

	formx.answer_id.value = answerx;

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

/*
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);
	
}

/*
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 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. 
 }          

/* Opens all links with class="external-link" in new tab automaticly */
jQuery("a.external-link").die().live( 'click', function(){
	window.open( jQuery(this).attr('href') );
	return 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 */


/*
 jQuery Tools 1.2.5 / Flashembed - New wave Flash embedding
 NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 http://flowplayer.org/tools/toolbox/flashembed.html
 Since : March 2008
 Date  :    Wed Sep 22 06:02:10 2010 +0000 
*/
(function(){function f(a,b){if(b)for(var c in b)if(b.hasOwnProperty(c))a[c]=b[c];return a}function l(a,b){var c=[];for(var d in a)if(a.hasOwnProperty(d))c[d]=b(a[d]);return c}function m(a,b,c){if(e.isSupported(b.version))a.innerHTML=e.getHTML(b,c);else if(b.expressInstall&&e.isSupported([6,65]))a.innerHTML=e.getHTML(f(b,{src:b.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title});else{if(!a.innerHTML.replace(/\s/g,"")){a.innerHTML="<h2>Flash version "+b.version+
" or greater is required</h2><h3>"+(g[0]>0?"Your version is "+g:"You have no flash plugin installed")+"</h3>"+(a.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+k+"'>here</a></p>");if(a.tagName=="A")a.onclick=function(){location.href=k}}if(b.onFail){var d=b.onFail.call(this);if(typeof d=="string")a.innerHTML=d}}if(i)window[b.id]=document.getElementById(b.id);f(this,{getRoot:function(){return a},getOptions:function(){return b},getConf:function(){return c},
getApi:function(){return a.firstChild}})}var i=document.all,k="http://www.adobe.com/go/getflashplayer",n=typeof jQuery=="function",o=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,j={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};window.attachEvent&&window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}});
window.flashembed=function(a,b,c){if(typeof a=="string")a=document.getElementById(a.replace("#",""));if(a){if(typeof b=="string")b={src:b};return new m(a,f(f({},j),b),c)}};var e=f(window.flashembed,{conf:j,getVersion:function(){var a,b;try{b=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(c){try{b=(a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"))&&a.GetVariable("$version")}catch(d){try{b=(a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"))&&a.GetVariable("$version")}catch(h){}}}return(b=
o.exec(b))?[b[1],b[3]]:[0,0]},asString:function(a){if(a===null||a===undefined)return null;var b=typeof a;if(b=="object"&&a.push)b="array";switch(b){case "string":a=a.replace(new RegExp('(["\\\\])',"g"),"\\$1");a=a.replace(/^\s?(\d+\.?\d+)%/,"$1pct");return'"'+a+'"';case "array":return"["+l(a,function(d){return e.asString(d)}).join(",")+"]";case "function":return'"function()"';case "object":b=[];for(var c in a)a.hasOwnProperty(c)&&b.push('"'+c+'":'+e.asString(a[c]));return"{"+b.join(",")+"}"}return String(a).replace(/\s/g,
" ").replace(/\'/g,'"')},getHTML:function(a,b){a=f({},a);var c='<object width="'+a.width+'" height="'+a.height+'" id="'+a.id+'" name="'+a.id+'"';if(a.cachebusting)a.src+=(a.src.indexOf("?")!=-1?"&":"?")+Math.random();c+=a.w3c||!i?' data="'+a.src+'" type="application/x-shockwave-flash"':' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';c+=">";if(a.w3c||i)c+='<param name="movie" value="'+a.src+'" />';a.width=a.height=a.id=a.w3c=a.src=null;a.onFail=a.version=a.expressInstall=null;for(var d in a)if(a[d])c+=
'<param name="'+d+'" value="'+a[d]+'" />';a="";if(b){for(var h in b)if(b[h]){d=b[h];a+=h+"="+(/function|object/.test(typeof d)?e.asString(d):d)+"&"}a=a.slice(0,-1);c+='<param name="flashvars" value=\''+a+"' />"}c+="</object>";return c},isSupported:function(a){return g[0]>a[0]||g[0]==a[0]&&g[1]>=a[1]}}),g=e.getVersion();if(n){jQuery.tools=jQuery.tools||{version:"1.2.5"};jQuery.tools.flashembed={conf:j};jQuery.fn.flashembed=function(a,b){return this.each(function(){$(this).data("flashembed",flashembed(this,
a,b))})}}})();      
/* END: Flashembed */ 

