function nc() {
	this.active_nav    = null;
	this.active_subnav = null;
    this.hide_interval = null;
    
    this.mn_out = function()
    {
		cont = this;
		this.hide_interval = window.setTimeout(function() {
			cont.reset();
		},750);
    }
    
    this.mn_in = function (item)
    {
		clearTimeout(this.hide_interval);
		$('ul#navigation li').removeClass('selected');
		$('ul#navigation li#nav_'+item).addClass('selected');
		$('ul.subnavigation').hide();
		$('ul#subnav_'+item).show();
    }
    
    this.sn_out = function()
    {
		cont = this;
		this.hide_interval = window.setTimeout(function() {
			cont.reset();
		},750);
    }
    
    this.sn_in = function() {
		clearTimeout(this.hide_interval);
    }
	
	this.init = function() {
		this.active_nav = $('ul#navigation li.selected');
		var id = this.active_nav.attr('id');
		if (id){
			this.active_subnav =  id.substring(4);
		} else {
			this.active_subnav = 'profil';
		}
	}
	
	
	this.reset = function() {
		//console.log('RESEEET');
		$('ul#navigation li').removeClass('selected');
		this.active_nav.addClass('selected');
		$('ul.subnavigation').hide();
		$('ul#subnav_'+this.active_subnav).show();
	}
	
	this.init();
}
    

$().ready(function()
{
	/** banner **/
	var winWidth = $(window).width();
	var maxHeight = $('#container').height();
	$('.wall_right').css('height',maxHeight);
	if( winWidth > 1000) {
		$('html').css('width', winWidth);
		$('html').css('overflow-x', 'hidden');
		$('.wall_right').css('display','block');
	} else {
		$('html').css('width', 1000);
		$('html').css('overflow-x', 'scroll');
		$('.wall_right').css('display','none');
	}
}
);

$(window).bind('resize', function() {
	var winWidth = $(window).width();
	if( winWidth > 1000) {
		$('html').css('width', winWidth);
		$('html').css('overflow-x', 'hidden');
		$('.wall_right').css('display','block');
	} else {
		$('html').css('width', 1000);
		$('html').css('overflow-x', 'scroll');
		$('.wall_right').css('display','none');
	}
});


$().ready(function()
{

    $('#login_float').jqm({
        trigger: '#login_trigger',
        overlay: 60,
        overlayClass: 'blackOverlay',
	onHide: function(hash) {
	    $('#login_float div#login_error').hide()
	    hash.o.remove();
	    $('#login_float').hide();
	}
    }).jqmAddTrigger($('#login_comment_trigger')).jqmAddTrigger($('#prijava_trigger')).jqmAddTrigger($('#login')); // kod clanka dodaje trigger :)


	$('#avatar_float').jqm({
		trigger: '#avatar_trigger',
		overlay: 60,
		overlayClass: 'blackOverlay'
	});

	$('#status_float').jqm({
		trigger: '#status_trigger',
		overlay: 60,
		overlayClass: 'blackOverlay'
	});

    $('#comment_float').jqm({
		trigger: '#comment_trigger',
		overlay: 60,
		overlayClass: 'blackOverlay'
    });

	$('#login_float_fb_connect').jqm({
        overlay: 60,
        overlayClass: 'blackOverlay'
	});

    $('#send_content_float').jqm({
		trigger: '#send_content_trigger',
		overlay: 60,
		overlayClass: 'blackOverlay',
		onHide: function(hash) {
		    $('#send_content_float form#frm_send_recommend').show();
		    $('#send_content_float div#send_sucess').hide();
		    $('#send_content_float div#send_error').hide();
		    hash.o.remove();
		    $('#send_content_float').hide();
		}
    }).jqmAddTrigger($('#send_content_trigger_2'));

    $('#ex3b').jqm({
        trigger: '#ex3bTrigger',
        overlay: 50
    });

    // login
    $('#ex3c').jqm({
        trigger: '#ex3cTrigger',
        overlay: 50
    });

    // posalji prijatelju
    $('#ex3d').jqm({
        trigger: '#ex3dTrigger',
        overlay: 50
    });

    $('input.jqmdX')
		.focus(
		    function(){ $(this).addClass('jqmdXFocus'); })
		.blur(
			function(){ $(this).removeClass('jqmdXFocus'); });
	}
);


function do_login() {
    var user  = $('#frm_login input#korisnicko_ime').val();
    var pass  = $('#frm_login input#lozinka').val();
    
    $.ajax({
		type: 'POST',
		url : APP_REWRITE_BASE + 'index.php?cmd=do_login&action=login',
		data : 'korisnicko_ime='+user+'&lozinka='+pass,
		success : function(raw_data) {
	
			var pattern = /^(ERR|OK):(.*?)$/i;
			var m = pattern.exec(raw_data);
			if (m.length == 3) {
				var data = m[1];
				var err  = m[2];
			} else {
				var data = '';
				var err  = raw_data;
			}
			
			if (data == 'OK')
			{
			    window.location.reload();
			} else
			{
			    $('#login_float div#login_error span').html(err);
			    $('#login_float div#login_error').show()
			}
		}
    });
}

function posalji_sadrzaj() {
	$.ajax({
	    type: 'POST',
	    url: APP_REWRITE_BASE + 'index.php?cmd=ajax_posalji_prijatelju&action=posalji',
	    //data: 'content_id='+p_clanak_id+'&content_type=1',
	    data: {
		   'content_id' : $('input#content_id').val(),
		   'content_type' : '1',
		   'source_mail' : $('input#source_mail').val(),
		   'dest_mail' : $('input#dest_mail').val(),
		   'zbroj' : $('input#zbroj').val(),
		   'seckey' : $('input#seckey').val()
		},
	    success: function(data) {
		$('input#zbroj').val('');
		if (data == 'OK:') {
		    $('#send_content_float form#frm_send_recommend').hide();
		    $('input#source_mail').val('');
		    $('input#dest_mail').val('');
		    $('#send_content_float div#send_sucess').show();
		} else {
		    $('#send_content_float div#send_error span').html(data.substring(4));
		    $('#send_content_float div#send_error').show();
		}
	    }
	});
}


    $(document).ready(function(){

		if( typeof $('#slider_special') != 'undefined' ){
	        $("#slider_special").easySlider({
				auto: true, 
				continuous: true,
				prevText: '',
				nextText:'',
				speed: 500,
				pause: 5000
	        });
		}
		
		if( typeof $('#slider_special_2') != 'undefined' ){
	        $("#slider_special_2").easySlider({
				auto: true, 
				continuous: true,
				prevId: 'prevBtn_2',
				nextId: 'nextBtn_2',
				prevText: '',
				nextText:'',
				speed: 500,
				pause: 5000
	        });
		}

		if( typeof $('#slider_galleries') != 'undefined' ){
			$("#slider_galleries").easySlider({
				auto: false, 
				continuous: false,
				prevId: 'prevBtnGalleries',
				nextId: 'nextBtnGalleries',
				prevText: '',
				nextText:'',
				speed: 1500,
				pause: 3000
			});
		}

	if( typeof $('#breaking_wrap') != 'undefined' ){
		$('#breaking_wrap').easySlider({
			auto: false,
			continuous: false,
			prevId: 'prevBreaking',
			nextId: 'nextBreaking',
			prevText: '',
			nextText:'',
			speed: 700
			//pause: 3000
		});
	}

	$("#slider_blogs").easySlider({
			auto: false, 
			continuous: false,
			prevId: 'prevBtnBlogs',
			nextId: 'nextBtnBlogs',
			orientation: 'vertical',
			vertical: true,
			prevText: '',
			nextText:'',
			speed: 1000,
			pause: 3000
        });
	
	if (document.getElementById('title_main_news')) {
	    var back_main_news = document.getElementById('title_main_news').offsetHeight;
	    back_main_news = back_main_news + "px";
	    document.getElementById('back_main_news').style.height = back_main_news;
	}
	
    });
    
    function showHarmonikaTab(tab) {
		$("ul#najcitanije, ul#najkomentiranije, ul#najnovije").hide();
		$("a#tab_najcitanije_new, a#tab_najkomentiranije_new, a#tab_najnovije_new").removeClass("selected");
		$("ul#"+tab).show();
		$("#tab_"+tab+"_new").addClass("selected");
    }

    function showStockHarmonikaTab(tab) {
		$("div#tecajna, div#burze").hide();
		$("a#tab_tecajna, a#tab_burze").removeClass("selected");
		$("div#"+tab).show();
		$("#tab_"+tab).addClass("selected");
    }

	function showBurzeTab(tab) {
		$("#stock_tables").children().hide();
		$("#stock_titles").children().removeClass("selected");
		$("div#"+tab).show();
		$("#tab_"+tab).addClass("selected");
    }

	function showTvTab(tab) {
		$("#tv_programi").children().hide();
		$("#tv_programi_tabs").children().removeClass("selected");
		$("div#"+tab).show();
		$("#tab_"+tab).addClass("selected");
    }

    




