
$(document).ready(function() { 
	$('#logo').css('zIndex', 1000);
}); 
 
// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    return true; 
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  { 

	if( responseText.search(/OK/) < 0 ){
		happy_load('div.loginmodule .wrapper3', '/module.php?module=login&type=-2');
	}
	else{
		happy_load('div.loginmodule .wrapper3', '/module.php?module=user&type=-2');
	}

} 

function happy_load( el, link ){
	temp = $(el).height();
	tempp = Math.round((temp-40)/2);
	
	$(el).html('<div style="text-align:center;height:'+temp+'px;"><img style="margin:0 auto;padding-top:'+tempp+'px;" src="http://www.odmorise.com/images/loading.gif" alt="loading" /></div>' );
	var options = {}
	options.url=link;
	options.cache=false;
	options.success=function(data, status){
		_happy_load( el, data, status );
	}
	$.ajax(options);
}
function _happy_load( el, data, status ){
	if( status == 'success' ){
		$(el).html( data );
	}
}

function parseQuery ( query ) {
	var Params = {};
	if ( ! query ) {return Params;}// return empty object
	var Pairs = query.split(/[;&]/);
	for ( var i = 0; i < Pairs.length; i++ ) {
		var KeyVal = Pairs[i].split('=');
		if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
		var key = unescape( KeyVal[0] );
		var val = unescape( KeyVal[1] );
		val = val.replace(/\+/g, ' ');
		Params[key] = val;
	}
	return Params;
}

function setCookie(n, v) {
	var cookieStr = "";
	var date = new Date();
	date.setTime(date.getTime()+(3*30*24*60*60*1000));
	var expiry = "; expires="+date.toGMTString();
	cookieStr = n + " = " + v + ";domain=.odmorise.com;expires="+expiry+";path=/ "  ;
	document.cookie = cookieStr;
}

function getCookie(c_name){
	if (document.cookie.length>0){
			c_start=document.cookie.indexOf(c_name + "=");
			if (c_start!=-1){ 
					c_start=c_start + c_name.length+1; 
					c_end=document.cookie.indexOf(";",c_start);
					if (c_end==-1) c_end=document.cookie.length;
					return unescape(document.cookie.substring(c_start,c_end));
				} 
		}
	return "";
}
// function setCookie(n, v) {
// 	var cookieStr = "";
// 	var date = new Date();
// 	date.setTime(date.getTime()+(3*30*24*60*60*1000));
// 	var expiry = "; expires="+date.toGMTString();
// 	cookieStr = n + " = " + v + ";domain=.odmorise.com;expires="+expiry+";path=/ "  ;
// 	document.cookie = cookieStr;
// }

$(document).ready(function() { 
	$('.memberListNav a.pagenav').click(function(){
		link = $(this).attr('href');
		happy_load( '#borivojeMain', link +'&no_html=1');
		return false;
	});
});

$(window).load(function() { 
	$('.memberListNav a.pagenav').click(function(){
		link = $(this).attr('href');
		happy_load( '#borivojeMain', link +'&no_html=1') ;
		return false;
	});
});


$(document).ready(function() {
		$('#perisaSearchHolder').html(perisaHTML);
		if( $('body').width() > 1010 ){
			$('#bookmark_us2').attr('id', 'bookmark_us');
			$('#innerBook').bookmark({compact: true});
			$('#barkod2').attr('id', 'barkod');
			//			$('#actionBox').css('margin-left', $('#actionBox').css('margin-left')+30);
		}

		/* google reklame */
		if( $('body').width() > 1010 && $('.stranasearchgr').length==0){
			if( $('.stranafireboard').length>0 ){
				if( $('.topic_title').length>1 ){ //forum crveni
					$('#glavniSadrzaj').append('<iframe class="google_desno" src="scripts/google.php?gad=2" width="125" height="605" frameborder="0" scrolling="no" style="padding:0;margin:0;border:0"></iframe>');
				}
				else{ //forum sivi
					$('#glavniSadrzaj').append('<iframe class="google_desno" src="scripts/google.php?gad=3" width="125" height="605" frameborder="0" scrolling="no" style="padding:0;margin:0;border:0"></iframe>');
				}
			}
			else{
				$('#glavniSadrzaj').append('<iframe class="google_desno" src="scripts/google.php?gad=0" width="125" height="605" frameborder="0" scrolling="no" style="padding:0;margin:0;border:0"></iframe>');
			}
			//			$('#google1').load('google.php');
		}
		else{
			if( document.location.href.search('portfolio') != 7 ){ //ruzno izgledaju na portfolio-u oglasi
				$('#glavniSadrzaj').append('<iframe class="google_dole" src="scripts/google.php?gad=1" width="733" height="95" frameborder="0" scrolling="no" style="padding:0;margin:0;border:0"></iframe>');
			}
		}
		$('#fb_views').append('<tr><td align="right" style="height:25px"><iframe class="google_forum_dole" src="scripts/google.php?gad=4" width="475" height="20" frameborder="0" scrolling="no" style="padding:0;margin:0;border:0"></iframe></td></tr>');
    if( typeof (setAutoComplete) =='function' ){
		setAutoComplete("searchField", "results", "index2.php?option=com_comprofiler&task=auto&no_html=1&Itemid=65&part=");
	}
	//	alert( typeof (corner) );

	$('#milenGore #milenDruga').hide();
	$('#milenGore #milenTreca').hide();
	$('#milenDole #milenPrvaThumb').hover(function(){$('#milenGore #milenPrva').show();$('#milenGore #milenDruga').hide();$('#milenGore #milenTreca').hide();},function(){});
	$('#milenDole #milenDrugaThumb').hover(function(){$('#milenGore #milenPrva').hide();$('#milenGore #milenDruga').show();$('#milenGore #milenTreca').hide();},function(){});
	$('#milenDole #milenTrecaThumb').hover(function(){$('#milenGore #milenPrva').hide();$('#milenGore #milenDruga').hide();$('#milenGore #milenTreca').show();},function(){});


	$('#bookmark_us').hover(function() {
		bookmark_show();
	}, function() {
		$('#bookmark_us #innerBook').hide();
	});

	ih = parseInt($('#infoBox').css('height'));
	ah = parseInt($('#actionBox').css('height'));
	diff = ih - ah;

});

function bookmark_show(url, description){
	if( url == undefined ){
		url = 'http://www.odmorise.com/';
	}
	$('#bookmark_us #innerBook').show();

}
$(document).ready(function(){
		$('.commentsForm h3').click(function(){
				$('.commentsForm form').toggle();
				return false;
			});
 
	});

$(document).ready( function() {
	$(".stranacomprofilerregisters .tatjanaFieldName a").click( function() {
			var left = (screen.availWidth/2-255);
			var top = (screen.availHeight/2-250);
			var windowPlayer = 
				window.open( $(this).attr('href') ,
							 "playerHolder",
							 "menubar=no,location=no,resizable=no,scrollbars=yes,status=yes,width=500,height=400,left="+left+',top='+top);
			windowPlayer.focus();
			return false;
		});

});

$(document).ready( function() {
		$('input').each(function(){
				var type = $(this).attr('type').toLowerCase();
				if(type=='button' || type=='submit' || type=='reset'){
					var indent = parseInt($(this).css('text-indent'));
					if(indent<0){
						$(this).val(' ');
					}
				}
			});
		$('button').each(function(){
				var indent = parseInt($(this).css('text-indent'));
				if(indent<0){
					$(this).val(' ');
				}
			})
			});

$(document).ready( function() {
		$('.mosmsgmodule').click(function(){$('.mosmsgmodule').hide()});
		setTimeout("$('.mosmsgmodule').hide()", 3000);
	});

$(document).ready(function(){
		$('a').click(function(){$(this).blur()});
	});


$(document).ready(function() { 
	$('.galerija-slike-prikaz a.pagenav').click(function(){
		var url = $(this).attr('href') ;
		url = url.replace(/view/, 'comments');
		parts = url.split('#');
		url = parts[0];
		link =  url +'&task=comments&no_html=1';
		happy_load('div.aksentijeComments ', link+' .aksentijeComments' );
		return false;
	});
});

$(document).ready( function() {
		$('.zodiac h2 a').click(function(){
				return false;
			});
	});

$(document).ready(function() {
		$('#infoBox .module h3').click(function(){
			aktivirajModul( $(this) );
			});
	});

function aktivirajModul( naslov ){
	if( naslov.parent().length < 1 ){
		return;
	}
	if( naslov.find( 'img' ).length < 1 ){
		return;
	}
	var h = naslov.parent();
	var c = h.find('.sakriMe');
	var d = ( c.css('display') == 'block' ? 0 : 1 );
// 	if( getCookie('jsdebug') != '' ){
// 		alert( naslov.parent().length + ':' + naslov.parent().attr('class') + ':' + naslov.parent().attr('id') + ':');
// 	}
	var n = h.attr('id').replace(/modul/, 'm');
	setOki( n, d );
	//	if( getCookie('jsdebug') != '' ){
		//					alert('da, to sam ja');
		var p = h.attr('id').replace(/modul_/, '');
		//		alert( '#'+h.attr('id')+' .sakriMe' + '-->' + '/module.php?module='+p+'&type=-2' );
		if( d == 1 ){
			naslov.css('padding-bottom', '9px');
			naslov.css('margin-bottom', '9px');
			happy_load( '#'+h.attr('id')+' .sakriMe', '/module.php?module='+p+'&type=-1');
			naslov.find( 'img' ).attr( 'src', naslov.find( 'img' ).attr( 'src' ).replace( /dole/, 'gore' ) );
			naslov.find( 'img' ).attr( 'title', naslov.find( 'img' ).attr( 'title' ).replace( /OPEN/, 'CLOSE' ) );
		}
		else{
			naslov.css('padding-bottom', '0px');
			naslov.css('margin-bottom', '0px');
			naslov.find( 'img' ).attr( 'src', naslov.find( 'img' ).attr( 'src' ).replace( /gore/, 'dole' ) );
			naslov.find( 'img' ).attr( 'title', naslov.find( 'img' ).attr( 'title' ).replace( /CLOSE/, 'OPEN' ) );
		}
		//	}

	c.animate({height:"toggle",width:"toggle",opacity:"toggle"});
	return false;
}
var okivalue = getCookie( '__oki' );
$(document).ready(function() {
		if( okivalue == ''){
			return;
		}
		else{
			var cs = okivalue.split( /,/ );
		}
		if( cs.length > 0 ){
			var bs = [];
			for( i in cs ){
				if( cs[i] != '' ){
					var al = cs[i].split(/:/);
					if( al[1] != undefined ){
						if( parseInt(al[1]) == 1 ){
							var elid = al[0].replace(/m/, 'modul');
							//							alert('Duzina:'+'#'+elid+$('#'+elid).length);
							aktivirajModul( $('#'+elid).find('h3') );
						}
// 						else{
// 							alert( al[1] );
// 						}
					}
				}
			}
			cs = bs;
		}
	});
	
function setOki( name, value ){
	//	alert( 'Oki: '+okivalue );

	if( okivalue != ''){
		var cs = okivalue.split( /,/ );
		//		alert( 'Duzina: '+cs.length );
	}
	else{
		var cs = [];
	}
	if( cs.length > 0 ){
		var bs = [];
		for( i in cs ){
			//			alert( 'Obradjujemo: '+i );
			if( cs[i] != '' ){
				var al = cs[i].split(/:/);
				if( al[1] != undefined ){
					bs[al[0]] = cs[i];
				}
			}
		}
		cs = bs;
	}
	//	alert( 'Nova duzina: '+cs.length );
	//	cs["jedan"]="dva";
	cs[name] = name + ':' + value;
	var bs = new Array();
	for( i in cs ){
		bs[bs.length] = cs[i];
	}
	val = bs.join();
	setCookie( '__oki', val );
	okivalue = val;
	//	alert( val );
}

$(document).ready(function() {
var config = {
        activeImageSrc: "images/active_star.gif",
	passiveImageSrc: "images/passive_star.gif",
	maxScore: 5,
	fn: new Function(),
	messages: [
	    "Your vote have been saved.",
	    "Very bad",
	    "Bad",
	    "Good, but could be better",
	    "Good enough",
	    "Very good"
	]
    };   

//$('.stranavideo p.vote').sexyVote( config );
	});

/* travian tooltip */
$(document).ready(function() {
		$('.stranatravian td.selo div.polje').hover(
							    function(){$(this).parent().find('.cardouter:hidden').show().css("z-index", 10000);},
							    function(){$(this).parent().find('.cardouter:visible').hide();}
		);
	});

