function getContent(arg) {
$.history.load(arg);
}

function myTimestamp(){
    tstmp = new Date();    
    return tstmp.getTime();
}

function pageload(hash) {
		if(hash)	{
//			window.scrollTo(0,0);
			$("#loader").fadeIn('fast');
			$("#tmp").fadeOut("fast",function() {
			$("#tmp").load('get.php?p='+hash + '&avoidcache=' + myTimestamp(),function() {
			$("#loader").fadeOut('fast',function() {
			$("#tmp").fadeIn("fast");
			initAjaxLinks();
			initforms();
			initforms2();
			initforms3();
			replacedeprecatedtags();
			if (hash == 'elerhetosegek')
			{
				ginitialize();
			}

			});
			});
			});
					}

	else	{
			document.getElementById("tmp").style.display = "block";
			}

						}


function initAjaxLinks() {
			$("#tmp a[rel='a']").click(function(){
				var temphash = this.href;
				hashit(temphash);
				$.history.load(hash);
				return false;
			});
		}

function initforms() { 
			$("form[name='ajax_form']").ajaxForm({ 
				target: '#tmp', 
				success: function() { 
					$('#tmp').fadeIn('fast'); 
				} 
			}); 
		};

function initforms2() { 
			$("form[name='ajax_form2']").ajaxForm({ 
				target: '#guestF', 
				success: function() { 
					$('#guestF').fadeIn('fast'); 
				} 
			}); 
		};

function initforms3() { 
			$("form[name='ajax_form3']").ajaxForm({ 
				target: '#subscribe', 
				success: function() { 
					$('#subscribe').fadeIn('fast'); 
				} 
			}); 
		};

function initforms4() { 
			$("form[name='ajax_form4']").ajaxForm({ 
				target: '#unsubtarget', 
				success: function() { 
					$('#unsubtarget').fadeIn('fast'); 
				} 
			}); 
		};

$(document).ready(function(){
			$.history.init(pageload);
			$("a[rel='a']").click(function(){
				var temphash = this.href;
				var menuid = this.id;
				if (menuid != "") {changemenu(menuid)};
				hashit(temphash);
				$.history.load(hash);
				return false;
			});
		});

// other functions

function show_message(html)
	{
		$.blockUI({ message: (html) }); 
	}

function hide_message()
	{
		$.unblockUI();
	}

function popload(mit)
	{
		$.get(mit,function(html){show_message(html);});
	}


function slideload(mit,hova) {
		$.get(mit,function(html) 
		{	
			$('#'+hova).html(html);
			$('#'+hova).slideDown('slow');	
		});
	} 

function slideloadback(hova) {
			$('#'+hova).slideUp('slow');
//			location.reload(); 
	} 


function noekezet(str)
{
var accent=new Array("í","Í","ö","Ö","ü","Ü","ó","Ó","ő","Ő","ú","Ú","á","Á","é","É","ű","Ű"," ",";","\"","/");
var deaccent=new Array("i","I","o","O","u","U","o","O","o","O","u","U","a","A","e","E","u","U","_","_","-","-");
return str_replace(accent,deaccent,str);
}


function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

// nyelv valtasa cookieba

function chlang(nyelv) {
	setCookie('language',nyelv,'30');
	document.location.replace("http://www.szinesgyongyok.hu");
}


// menu aktiv pozicioba allitasa

function changemenu(menuid) {
//	alert(menuid);
if (menuid > 100) menuid = 3;
	$("#jsddm  > li a.isactive").removeAttr('style');
	$("#jsddm  > li a.isactive").removeClass("isactive");
	$('.mainMenu #'+menuid+":first").addClass('isactive');
}



function activeslider(){


var gorog = $("#szabad_e_gorgetni").val();
if (gorog == 'szabad')
{

			k = i - 1;
			// elso menetbe ha utolso mar aktiv
			if (i == 101) {
			if ( $('.programok #104').hasClass('active') ) {
				$('.programok #104').removeClass('active',100);}

			}
			else
			// tobbi menetbe az elotte levot torli
			{
			if ( $(".programok #" + k + "").hasClass('active') ) {
				$(".programok #" + k + "").removeClass('active',100);}
			}
			// add aktualhoz
			$(".programok #" + i + "").addClass('active',100);
			i = i + 1;
			// ha eleri a 4et induljon elolrol
			if (i == 105) {i = 101}
}


}

// slider ami valtogatja az aktiv state-t
function programslider(rotime) {
	i = 101;
	// timer
	setInterval( "activeslider()", rotime );
}


function loadbackmail() {
		$("#subscribe").fadeOut("fast",function() {
		$("#subscribe").load('modules/hirlevel/feliratkozas.php',function() {
		$("#subscribe").fadeIn("fast");
});
});
}

// fckeditor odivatusagat megoldo fuggveny

jQuery.fn.extend({
	riplejsz : function() {

	var hspace = $(this).attr('hspace');
	var vspace = $(this).attr('vspace');
	if (hspace != -1) {$(this).css("margin-left","" + hspace + "px"); $(this).css("margin-right","" + hspace + "px");}
	if (vspace != -1) {$(this).css("margin-top","" + vspace + "px"); $(this).css("margin-bottom","" + vspace + "px");}


	var align = $(this).attr('align');
	//$(this).css("margin","" + vspace + "px " + hspace + "px");
	
	if (align == "left") {$(this).css("margin-left","0px");}
	if (align == "right") {$(this).css("margin-right","0px");}
	}
});


function replacedeprecatedtags() {
$('.aktOldal img').each(function(){
	$(this).riplejsz();
});
}
