﻿var base = '';function set_base(str){	base = str;}function menuopen(x, total){	for (var i=1; i <= total; i++)	{		document.getElementById('submenu' + i).style.display = 'none';		document.getElementById('tab' + i).className = '';	}	document.getElementById('submenu' + x).style.display = 'block';	document.getElementById('tab0').className = '';	document.getElementById('tab' + x).className = 'current';	}function menuclose(total){	for (var i=1; i <= total; i++)	{		document.getElementById('submenu' + i).style.display = 'none';		document.getElementById('tab' + i).className = '';	}		document.getElementById('tab0').className = 'current';}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 poll_vote(instance){	var cnt = 0;	for (var i=0; i < document.forms['answers-'+instance].answer.length; i++)	{		if (document.forms['answers-'+instance].answer[i].checked)		{			cnt++;			var ans = document.forms['answers-'+instance].answer[i].value;		}	}		if(cnt > 0)	{		var pollid = document.getElementById('pollid-'+instance).value;				$("#poll-vote-"+instance).hide();		$("#poll-results-"+instance).hide();		$("#poll-show-"+instance).hide();				$.ajax({			url: "index.php",			type: "POST",			data: ({action : 'poll_vote', action_type : 'ajax', answer : ans, pollid : pollid, instance: instance}),			dataType: "html",			success: function(msg)			{				msg = ajax_retrieve_messages(msg);				$("#poll_cont-"+instance).attr('innerHTML', msg[0]);			}			});	}	else	{		alert("Morate odabrati odgovor da bi mogli glasati!");	}}function poll_results(instance){	$("#poll-vote-"+instance).hide();	$("#poll-results-"+instance).hide();	$("#poll-show-"+instance).show();	var pollid = document.getElementById('pollid-'+instance).value;		$.ajax({		url: base+"index.php",		type: "POST",		data: ({action : 'poll_results', action_type : 'ajax', pollid : pollid, instance: instance}),		dataType: "html",		cache:false,		timeout:10000,		success: function(msg)		{			msg = ajax_retrieve_messages(msg);			$("#poll_cont-"+instance).attr('innerHTML', msg[0]);		},		error: function(XMLHttpRequest, textStatus, errorThrown)		{			alert(textStatus + ", " + errorThrown);		}	});}function poll_show(instance){	$("#poll-vote-"+instance).show();	$("#poll-results-"+instance).show();	$("#poll-show-"+instance).hide();	var pollid = document.getElementById('pollid-'+instance).value;		$.ajax({		url: base+"index.php",		type: "POST",		data: ({action : 'poll_show', action_type : 'ajax', pollid : pollid, instance: instance}),		dataType: "html",		success: function(msg)		{			msg = ajax_retrieve_messages(msg);			$("#poll_cont-"+instance).attr('innerHTML', msg[0]);		}	});}var current_poll = 1;function poll_slider(dir){	current_poll += dir;	var total = $('.poll').size();	if(current_poll < 1)		current_poll = total;	if(current_poll > total)		current_poll = 1;		$(".poll_slider").hide();		$(".poll").slideUp(300);	$("#poll-"+current_poll).slideDown(300, function(){$(".poll_slider").fadeIn(300)});}function ajax_retrieve_messages(str){	var i = 0;	var counter = 0;	var msgs = [];		counter = str.indexOf('[<ajax_message>', counter)	while(counter >= 0)	{		var start_m = counter;		var end_m = str.indexOf('</ajax_message>]', counter);		var message = str.substring(start_m + 15, end_m);		msgs[i] = message;		i++;		counter = str.indexOf('[<ajax_message>', end_m)	}		return msgs;}function latin2_convert(str){	str = str.replace(/=/g, '*eq*');	str = str.replace(/&/g, '*amp*');	str = str.replace(/\n/g, '*br*');	str = str.replace(/č/g, '[ch]');	str = str.replace(/ć/g, '[cs]');	str = str.replace(/š/g, '[s]');	str = str.replace(/đ/g, '[d]');	str = str.replace(/ž/g, '[z]');	str = str.replace(/Č/g, '[CH]');	str = str.replace(/Ć/g, '[CS]');	str = str.replace(/Š/g, '[S]');	str = str.replace(/Đ/g, '[D]');	str = str.replace(/Ž/g, '[Z]');	return str;}function newsletter_process(){	$("#poll-vote").show();	$("#poll-results").show();	$("#poll-show").hide();	var email = document.getElementById('email').value;		$.ajax({		url: "index.php",		type: "POST",		data: ({action : 'newsletter_process', action_type : 'ajax', email : email}),		dataType: "html",		success: function(msg)		{			msg = ajax_retrieve_messages(msg);			$("#newsletter").attr('innerHTML', msg[0]);		}	});}function input_focus(id){	$("#l"+id).addClass('lcurrent');}function input_blur(id){	$("#l"+id).removeClass('lcurrent');}function sendContact(){	// check for email	var email = $("#email").val();	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;	if(!filter.test(email))		{		$("#email-error").slideDown(500);		$("#email").focus();		return false;	}	else		$("#email-error").slideUp(500);		// check for message	/*	var msg = $("#message").val();	if(msg.length == 0)	{		$("#message-error").slideDown(500);		$("#message").focus();		return false;	}	else		$("#message-error").slideUp(500);	*/			// check for captcha	var captcha = $("#captcha").val();	if(captcha != captcha_c)	{		$("#captcha-error").slideDown(500);		$("#captcha").focus();		return false;	}	else		$("#captcha-error").slideUp(500);			var data = $("#contact_form > form").serialize();	$.ajax({		type: "POST",		url: "sendContact.php",		data: data,		cache: false,		success: function(msg){		}	});		$("#contact_form").fadeOut(1000, function() {		$("#message_sent").slideDown(500);	});			return false;}var captcha_a = Math.ceil(Math.random() * 10);var captcha_b = Math.ceil(Math.random() * 10);       var captcha_c = captcha_a + captcha_b;function generate_captcha(id){	var id = (id) ? id : 'lcaptcha';	$("#"+id).html(captcha_a + " + " + captcha_b + " = ");}
