function getContent(arg) {
arg = arg.replace('?','');
$.history.load(arg);
}

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


function gallerize() {
	$("a.fancygal").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	400, 
		'speedOut'		:	150, 
		'overlayShow'	:	true
	});
	
}

function pageload(hash) {
		if(hash)	{
			window.scrollTo(0,0);
			$("#loader").fadeIn('fast');
			$("#centerContent").fadeOut("fast",function() {
			$("#centerContent").load('getContent.php?'+hash + '&avoidcache=' + myTimestamp(),function() {
			$("#loader").fadeOut('fast',function() {
			$("#centerContent").fadeIn("fast");
			initAjaxLinks();
			initforms();
			gallerize();
			});
			});
			});
					}

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

						}


function initAjaxLinks() {
			$("#centerContent 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() { 
					$('#centerContent').fadeIn('fast'); 
				} 
			}); 
		};

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

// 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 searchBlur(obj,label) {

	 if (obj.value.length == 0) {
			obj.value = label;
	 }

	}



///
function setImage(ID) {
	var ID;
	url = 'getImageProps.php?id='+ID;
	$.ajax({
		  url: url,
		  success: function(data){
				$('#termekImageCntr').html(data);
		  }
		});

}
//////



//////
function insertCart(ID) {
	var ID;
	var num = document.getElementById("tcv_"+ID).value;

	//alert(num);

}
//////



/////
function clearSearchText(obj,label) {
	if (obj.value == label) {
		obj.value = '';
	}
}
/////

/////
function checkSend() {

	var s1 = document.getElementById('s1').value;
	var a = document.getElementById('keresesIN');
	if (a.value == s1) {
		a.value = '';
	}
}
/////


//////
function openKatMenu() {
	document.getElementById('katMenu').style.display = 'block';
	document.getElementById('mainMenu').style.display = 'none';
}
function closeKatMenu() {
	document.getElementById('katMenu').style.display = 'none';
	document.getElementById('mainMenu').style.display = 'block';
}
/////


/////
function openSzamlazasiCimCntr() {


	var s2 = document.getElementById('s2').value;

	document.getElementById("szamlazasiCimCntr").style.display = "block";
	document.getElementById("szmlazasiCimLink").href = "javascript:closeSzamlazasiCimCntr()";
	document.getElementById("szmlazasiCimLink").innerHTML = '&laquo; '+s2;

}
/////

/////
function closeSzamlazasiCimCntr() {

	var s3 = document.getElementById('s3').value;

	document.getElementById("szamlazasiCimCntr").style.display = "none";
	document.getElementById("szmlazasiCimLink").href = "javascript:openSzamlazasiCimCntr()";
	document.getElementById("szmlazasiCimLink").innerHTML = s3+' &raquo;';

}
/////



function addToCart(id) {

	var id;
	var db = document.getElementById('db_'+id).value;
	document.getElementById('cart').style.display = 'block';	
	var url = host+'addToCart.php?id='+id+'&db='+db;
	
	$.ajax({
	  url: url,
	  success: function(data){
			$('#cartCntr').html(data);
			document.getElementById('kosarOsszesen').innerHTML = document.getElementById('kosarOsszesenH').value;
	  }
	});
	
}
/////



function delFromCart(id) {
	var id;
	var url = host+'addToCart.php?id='+id+'&m=1';
	$.ajax({
		  url: url,
		  success: function(data){
				$('#cartCntr').html(data);
				document.getElementById('kosarOsszesen').innerHTML = document.getElementById('kosarOsszesenH').value;
		  }
		});

}
/////


/////
function notLogged() {
	var s4 = document.getElementById('s4').value;
	alert(s4);
}
/////


/////
function hideCart() {
	document.getElementById('cart').style.display = 'none';
	//location.href = location.pathname + document.getElementById('page').value;
}
/////


////
function errorMsg(n) {
	var n;
	var s5 = document.getElementById('s5').value;
	var str = s5.replace('xxx',n);
	alert(str);//'Tisztelt látogató! \n\n Ebből a termékből maximum '+n+' darab rendelhető egyszerre!'
}
////


////
function rendeles() {

	getContent('?id=18&r=1');

}
////

////
function onlineshop() {

	document.getElementById('mainMenu').style.display = 'none';
	document.getElementById('katMenu').style.display = 'block';
	getContent('?id=4');

}
///

function kezdolap() {

	document.getElementById('mainMenu').style.display = 'block';
	document.getElementById('katMenu').style.display = 'none';
	getContent('?id=2');

}



/////
function displayElement(id) {
	var obj = document.getElementById('lItem_'+id);
	if (obj.style.display == 'none') {
		obj.style.display = 'table-row';
	} else {
		obj.style.display = 'none';
	}

}
///// 



