﻿var gallery_action = false;function gallery_move(id, cnt, dir){	if(gallery_action)		return;			var curr = document.getElementById("gallery-"+id+"-holder").style.left;	curr = parseFloat(curr);	if(isNaN(curr))		curr = 0;		if(dir > 0)	{		if(curr >= 0)			return;	}	else	{		if(curr + cnt * (190 + 20) - 3 * (190 + 20) <= 0)			return;	}	gallery_action = true;	var offset = 210;	if(dir < 0)		dir = "-";	else		dir = "+";			$("#gallery-"+id+"-holder").animate(		{left : dir+"="+offset+"px"},		{queue:true, duration:100, complete: function() {gallery_action = false;}}	);}function delete_bookmark(id){	$.ajax({		url: "index.php",		type: "POST",		data: ({action : "delete_bookmark", action_type : 'ajax', id: id}),		dataType: "html",		success: function(msg)		{			$("#bookmark-"+id).fadeOut(500);		}	});		}function delete_calendar(id){	$.ajax({		url: "index.php",		type: "POST",		data: ({action : "delete_calendar", action_type : 'ajax', id: id}),		dataType: "html",		success: function(msg)		{			$("#bookmark-"+id).fadeOut(500);		}	});		}function delete_admin_alert(id, cnt){	$.ajax({		url: "index.php",		type: "POST",		data: ({action : "delete_admin_alert", action_type : 'ajax', id: id}),		dataType: "html",		success: function(msg)		{			$("#alert-"+cnt).slideUp(500);		}	});		}function delete_recommendation(id, cnt){	$.ajax({		url: "index.php",		type: "POST",		data: ({action : "delete_recommendation", action_type : 'ajax', id: id}),		dataType: "html",		success: function(msg)		{			$("#alert-"+cnt).slideUp(500);		}	});		}function recommend_email(type, id, div_id){	var div_id = (div_id) ? "-" + div_id : "";		var user_sender = document.getElementById('user_sender'+div_id).value;	var email = document.getElementById('friends_email'+div_id).value;		if(document.getElementById('use_username-'+div_id).value == 1)	{		if(user_sender.length < 3)		{			alert("Vaše korisničko ime je prekratko.");			return false;		}	}		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;	if(reg.test(email) == false) 	{		alert('Email adresa je krivo upisana.');		return false;	}		$.ajax({		url: "index.php",		type: "POST",		data: ({action : "recommend_email", action_type : 'ajax', type: type, id: id, email: email, user_sender : user_sender}),		dataType: "html",		success: function(msg)		{			$("#recommend_form"+div_id).slideUp(500, function(){$("#recommend_text"+div_id).slideDown(500);});		}	});		}var calendar_status = 0;var calendar_start = 0;function calendar_move(dir){	if(calendar_status == 1)		return;			var pages = document.getElementById('calendar_count').value;		/*	if(calendar_start <= 0)		return;	if(calendar_start >= pages)		return;	*/	calendar_status = 1;		calendar_start = calendar_start + (dir * 11);		if(calendar_start + 11 > pages)	{		$("#calendar_prev").removeClass('kalendar');		$("#calendar_prev").addClass('disabled');	}		if(calendar_start - 11 < 0)	{		$("#calendar_next").removeClass('kalendar');		$("#calendar_next").addClass('disabled');	}		$.ajax({		url: "index.php",		type: "POST",		data: ({action : "calendar_ajax", action_type : 'ajax', 'start' : calendar_start}),		dataType: "html",		success: function(msg)		{			msg = ajax_retrieve_messages(msg);			$("#loader1").fadeOut(500, function() {				document.getElementById("loader1").innerHTML = msg[0];				$("#loader1").fadeIn(500, function() {calnedar_status = 0; });			});		}	});	}function save_calendar(content, type){	$.ajax({		url: "index.php",		type: "POST",		data: ({action : "save_calendar", action_type : 'ajax', 'content_id': content, 'type' : type}),		dataType: "html",		success: function(msg)		{			//$("#c-options-"+content+"-yes").fadeOut(500);			//$("#c-options-"+content+"-maybe").fadeOut(500);			if(type == 'yes')			{				$("#c-options-"+content+"-maybe").removeClass('current');				$("#c-options-"+content+"-"+type).addClass('current');				$("#c-event-"+content).removeClass('green');				$("#c-event-"+content).addClass('red');			}			else if(type == 'maybe')			{				$("#c-options-"+content+"-yes").removeClass('current');				$("#c-options-"+content+"-"+type).addClass('current');				$("#c-event-"+content).removeClass('red');				$("#c-event-"+content).addClass('green');			}		}	});	}function save_calendar_fold(content, type){	save_calendar(content, type);	$("#users_going").slideDown(500, function(){		$("#users_going_me").fadeIn(500)	});}function check_search(c){	var c = (c) ? c : 3;	var q = document.getElementById('query').value;	if((q.length < c) || (q == 'Pretraga...'))	{		$("#search-error").fadeIn(500);		return false;	}		return true;}var wassup_counter = 1;function wassup_more(){	wassup_counter++;	var new_start = 20 + 10 * wassup_counter;	var type = document.getElementById('interact-type').value;		$("#wassup_loader").show();	$.ajax({		url: "index.php",		type: "POST",		data: ({action : "load_wassup", action_type : 'ajax', 'new_start' : new_start, 'type' : type}),		dataType: "html",		success: function(msg)		{			msg = ajax_retrieve_messages(msg);			document.getElementById('wassup').innerHTML += msg[0];			$("#wassup_loader").hide();		}	});	}function show_tags(){	$('.hiddentag').fadeIn(1000);	$("#all-tags").fadeOut(1000);}function menuopen(id, total){	if (document.getElementById('submenu' + id).style.display != 'none')		return;	for (var x = 1; x < total; x++)	{		if (document.getElementById('submenu' + x))			document.getElementById('submenu' + x).style.display = 'none';	}		$('#submenu' + id).fadeIn();}function menuclear(total){	for (var x = 1; x < total; x++)	{		if (document.getElementById('submenu' + x))			document.getElementById('submenu' + x).style.display = 'none';	}}function tabs(id){	if (document.getElementById('tab' + id).style.display != 'none')		return;	document.getElementById('tab1').style.display = 'none';	document.getElementById('tab2').style.display = 'none';		document.getElementById('tab1h5').className = 'grey';	document.getElementById('tab2h5').className = 'grey';		document.getElementById('tab' + id + 'h5').className = 'green';		$('#tab' + id).fadeIn();}function vote(vote, id){			var spanname = '#scores'+id;		if(vote == 1)	{		var action = "score_up";	}	else	{		var action = "score_down";	}			$.ajax({		url: "index.php",		type: "POST",		data: ({action : action, action_type : 'ajax', id : id}),		dataType: "html",		success: function(msg)		{			$(spanname).fadeOut("slow");		}	});}function bookmark(type, id){	var spanname = '#bookmark'+id;			$.ajax({		url: "index.php",		type: "POST",		data: ({action : "save_bookmark", action_type : 'ajax', id : id, type : type}),		dataType: "html",		success: function(msg)		{			$(spanname).fadeOut("slow");		}	});}
function recommend_to_friends(id){	var spanname = '#recommend-to-friends-'+id;			$.ajax({		url: "index.php",		type: "POST",		data: ({action : "do_recommend", action_type : 'ajax', id : id}),		dataType: "html",		success: function(msg)		{			$(spanname).fadeOut("slow");		}	});}function center(object) {	var x,y;	if (self.pageYOffset) // all except Explorer	{		y = self.pageYOffset;	}	else if (document.documentElement && document.documentElement.scrollTop)	// Explorer 6 Strict	{		y = document.documentElement.scrollTop;	}	else if (document.body) // all other Explorers	{		y = document.body.scrollTop;	}	document.getElementById('popup').style.top = y+180 + 'px';}function setVisible(obj, grayout){	center('popup');	obj = document.getElementById(obj);	//if(obj.style.visibility == 'hidden')	//{		obj.style.visibility = 'visible';	//}		//obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';	if(grayout == true)	{		grayOut(true, {'zindex':'50', 'bgcolor':'#000000', 'opacity':'70'});	}}function closeDiv(obj, grayout){	obj = document.getElementById(obj);	obj.style.visibility = 'hidden';	if(grayout == true)	{		grayOut(false, {});	}}function grayOut(vis, options) {  var options = options || {};   var zindex = options.zindex || 50;  var opacity = options.opacity || 70;  var opaque = (opacity / 100);  var bgcolor = options.bgcolor || '#000000';  var dark=document.getElementById('darkenScreenObject');  if (!dark) {    var tbody = document.getElementsByTagName("body")[0];    var tnode = document.createElement('div');           // Create the layer.        tnode.style.position='absolute';                 // Position absolutely        tnode.style.top='0px';                           // In the top        tnode.style.left='0px';                          // Left corner of the page        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars                    tnode.style.display='none';                      // Start out Hidden        tnode.id='darkenScreenObject';                   // Name it so we can find it later    tbody.appendChild(tnode);                            // Add it to the web page    dark=document.getElementById('darkenScreenObject');  // Get the object.  }  if (vis) {    // Calculate the page width and height     if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {        var pageWidth = document.body.scrollWidth+'px';        var pageHeight = document.body.scrollHeight+'px';    } else if( document.body.offsetWidth ) {      var pageWidth = document.body.offsetWidth+'px';      var pageHeight = document.body.offsetHeight+'px';    } else {       var pageWidth='100%';       var pageHeight='100%';    }       //set the shader to cover the entire page and make it visible.    dark.style.opacity=opaque;                          dark.style.MozOpacity=opaque;                       dark.style.filter='alpha(opacity='+opacity+')';     dark.style.zIndex=zindex;            dark.style.backgroundColor=bgcolor;      dark.style.width= pageWidth;    dark.style.height= pageHeight;    dark.style.display='block';                            } else {     dark.style.display='none';  }}function avatar(){}function mouseClickCoord(e){	if (!e.pageX && e.clientX){		// In Internet Explorer 7 some properties (mouse coordinates) are treated as physical,		// while others are logical (offset).		var zoom = 1;			var body = document.body;				if (body.getBoundingClientRect) {			var bound = body.getBoundingClientRect();			zoom = (bound.right - bound.left)/body.clientWidth;		}		return {			x: e.clientX / zoom + d.body.scrollLeft + d.documentElement.scrollLeft,			y: e.clientY / zoom + d.body.scrollTop + d.documentElement.scrollTop		};	}		return {		x: e.pageX,		y: e.pageY	};}function fire(){	var c = mouseClickCoord(document);	alert(c.x + ", " + c.y);}var current_pitch_cal = 1;var cal_width = 296;function pitch_cal_next(total){	var to_move = '-='+cal_width+'px';		if(current_pitch_cal == total)	{		to_move = (total - 1) * cal_width;		to_move = '+='+to_move+'px';		current_pitch_cal = 0;	}		//alert(to_move + ": "+ current_pitch_cal+", "+total);		$(".hor_switch_wrap_v").animate({left: to_move}, { duration: "slow" });	current_pitch_cal++;}var current_top_menu = 1;function doswitch(id, min, max){	if(id != current_top_menu)	{		for(var i = min; i <= max; i++)		{			$("#title"+i).stop();			$("#title"+i).css('opacity', 0); 			$("#title"+i).hide();		}				$("#title"+id).show();		$("#title"+id).animate({opacity: 1}, {duration: 300});		current_top_menu = id;	}}