/* GLOBAL SCRIPTS */
function isempty(str)
{
	r = new RegExp("^[ .*]$");
	return (r.test(str) || str.length == '');
}

function checkValidEmail(mailstr) {
	r = new RegExp("^[0-9a-zA-Z\\._\\-]{2,}@([0-9a-zA-Z_\\-]{2,}\\.){1,7}[a-zA-Z]{2,3}$");
	return r.test(mailstr);
}

function iecheck()
{
	var pos = navigator.userAgent.indexOf("MSIE ");
	if (pos == -1) return false;
	var version = navigator.userAgent.substring(pos + 5);
	return (((version.indexOf("5.5") == 0) || (version.indexOf("6") == 0)  || (version.indexOf("7") == 0)));
}

function ie_png_check()
{
	var pos = navigator.userAgent.indexOf("MSIE ");
	if (pos == -1) return false;
	var version = navigator.userAgent.substring(pos + 5);
	return ((version.indexOf("5.5") == 0) || (version.indexOf("6") == 0));
}

// PNG ALPHA CHANNEL IMG-RE //
function iepng_alphachannel(imgid,timg,size)
{
	if(ie_png_check())
	{
		d = document.getElementById(imgid);
		origsrc = d.src;
		d.src = timg;
		d.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + origsrc + "',sizingMethod='image')";
		d.width = size[0];
		d.height = size[1];
	}
}

// PNG ALPHA CHANNEL DIV BACKGROUND //
function iepng_alphachannel_bg(divid,bgimg,size)
{
	d = document.getElementById(divid);
	d.style.width = size[0]+"px";
	d.style.height = size[1]+"px";
	if(iecheck())
	{
		d.style.backgroundImage = '';
		d.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + bgimg + "',sizingMethod='image')";
	}
}

function swf_search()
{
	d = document.getElementsByTagName("DIV");
	r = new RegExp("^flash_[0-9]+$");
	for(var i = 0; i<d.length; i++)
	{
		if(r.test(d[i].id))
		{
			path = d[i].innerHTML;
			w = d[i].style.width.replace("px","");
			h = d[i].style.height.replace("px","");
			swf_insert(d[i].id,path,w,h);
		}
	}
}

function insertFlash(swf,size,cel)
{
	var str = "";
	if(iecheck())
	{
		str +='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,47,0" width="'+size[0]+'" height="'+size[1]+'">';
		str +='	<param name="movie" value="'+swf+'" />';
		str +='	<param name="quality" value="high" />';
		str +=' <param name="menu" value="false" />';
		str +=' <param name="wmode" value="transparent" />';
		str +=' <param name="allowScriptAccess" value="sameDomain" />';
		str +='</object>';

	}
	else
	{
		
		str +='<object type="application/x-shockwave-flash" data="'+swf+'" width="'+size[0]+'" height="'+size[1]+'">';
		str +='<param pluginurl="http://www.macromedia.com/go/getflashplayer">';
		str +='	<param name="menu" value="false" />';
		str +='	<param name="quality" value="high" />';
		str +=' <param name="wmode" value="transparent" />';
		str +=' <param name="allowScriptAccess" value="sameDomain" />';
		str +='</object>';
	}
	document.getElementById(cel).innerHTML = str;
}


function set_hover(a) {
	a.style.backgroundimage = 'images/menu_item_hover.gif';	
}

function recode(t)
{
	$('#'+t).attr({src: '/includes/gifcode.php?code='+Math.random()});
}

function show_map()
{
	$.ajax({
		type: "POST",
		url: "/process/terkep.php",
		success: function(msg){
			var mod='\<div><h2 class="red floatleft" style="margin-top: 3px;">Elérhetőségünk</h2>\
			<img src="/js/facebox/closelabel.gif" alt="" width="66" height="22" style="cursor: pointer;" class="hand vmid floatright"\
			onclick="jQuery(document).trigger(\'close.facebox\');" />\
			<br class="clear" style="clear: both;" /></div><div id="kordinata"></div>\
			<div> \
			'+msg+'\
			</div>';
			jQuery.facebox(mod);
			loadmap();
		}
	});
}

function loadmap() {
	if (GBrowserIsCompatible()) 
	{
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		var icon = new GIcon();
		
		icon.image = "http://www.reveszetterem.hu.tesztszerver.hu/images/marker.png";
		icon.iconSize = new GSize(26, 26);
		icon.iconAnchor = new GPoint(13,13);
		
		var parking = new GIcon();
		parking.image = "http://www.reveszetterem.hu.tesztszerver.hu/images/parking.png";
		parking.iconSize = new GSize(26, 26);
		parking.iconAnchor = new GPoint(13,13);
		markerOptionspark = {icon:parking/*,draggable:true*/};
		
		markerOptions = {icon:icon/*,draggable:true*/};
		map.setCenter(new GLatLng(47.69655321261998, 17.6299546334839), 16);
		var point = new GLatLng(47.696553,17.629958);
		var pointpark = new GLatLng(47.696188,17.630074);
		var marker = new GMarker(point, markerOptions);
		var markerpark = new GMarker(pointpark, markerOptionspark);
		map.addOverlay(marker);								
		map.addOverlay(markerpark);								
	}
	
	/*
	GEvent.addListener(markerpark, "drag", function(){
									document.getElementById("kordinata").innerHTML=markerpark.getPoint().toUrlValue();
									
								});
								*/
								
	var myHtml = '<strong>Révész étterem</strong><br /><br />9026 Győr<br />\
				Hédervári utca 22.\
					<br \/><br \/>\
					<table cellpadding="0" cellspacing="0">\
					<tr>\
						<td style="width:70px;"><b>Telefon:<\/b><\/td><td>+36 96 320-667<\/td>\
					<\/tr>\
					<tr>\
						<td><b>E-mail:<\/b><\/td><td><a style="color:#010101;" href="mailto:info@whbhotel.hu">info@reveszetterem.hu<\/a><\/td>\
					<\/tr>\
					<\/table><br \/>';
	GEvent.addListener(marker, "click", function() {	
		map.openInfoWindowHtml(point, myHtml);
	});
	map.openInfoWindowHtml(point, myHtml);
}

/*Napi ajánlatok*/ 

function napimenu(time){

	$.ajax({
		type: "POST",
		url: "process/menuAction.php",
		data: "action=napimenu&time=" + time,
		success: function(back){
			$("#napimenu").html(back);
		}
	 });


}

var time;

function nyit(ceil){
	
	var margin=$("#menuhir").css('marginLeft');
		
	margin=margin.replace("px","");
	margin=parseInt(margin);
	
	margin+=(ceil-margin)/4;
	
	$("#menuhir").css('margin-left',margin+'px')
	if (parseInt(margin)!=parseInt(ceil)){
		time=setTimeout("nyit("+ceil+")",40);
	}
	
}


function nyitcsuk(){
	
	if (NYITVA==0){
		clearTimeout(time);
		nyit(300);
			
		$("#menuful").css('background','url(../images/menuhirlev_be.gif)');
		NYITVA=1;
	}
	else{
		clearTimeout(time);
		nyit(614);
		$("#menuful").css('background','url(../images/menuhirlev_ki.gif)');
		NYITVA=0;	
	}

}

function sendform(){
	
	var query=$("#hirlevform").serialize();
	
	$("#uzenet").html("Az adatok küldése...");
	
	$.ajax({
		type: "POST",
		url: "process/menuAction.php",
		data: "action=menuhirlev&" + query,
		success: function(back){
	
			switch (back){
				
				case "1": 
					$("#uzenet").html('<span class="green">Ön sikeresen feliratkozott a heti menü hírlevelünkre.</span>');
					clearTimeout(time);
					setTimeout("nyit(614)",2000);
					$("#menuful").css('background','url(../images/menuhirlev_ki.gif)');
					NYITVA=0;
				break;
				
				case "2": 
					$("#uzenet").html('<span class="green">Ön már korábban feliratkozott hírlevelünkre.</span>');
					clearTimeout(time);
					setTimeout("nyit(614)",2000);
					$("#menuful").css('background','url(../images/menuhirlev_ki.gif)');
					NYITVA=0;
				break;
				
				case "3": 
					$("#uzenet").html('<span class="red">Az e-mail cím nem helyes!</span>');
				break;
				
				case "4": 
					$("#uzenet").html('<span class="red">A név kitöltése kötelező!</span>');
				break;
				
				case "5": 
					$("#uzenet").html('<span class="red">Az adatvédelmi szabályzatot el kell fogadni!</span>');
				break;
				
				default: 
					$("#uzenet").html('<span class="red">Valamilyen hiba történt. Kérjük próblja újra!</span>');
				break;
			
			}
			
			
		}
	 });
	 
	 
}

function szabalyzat(){

	$.ajax({
		type: "POST",
		url: "/process/szabalyzat.php",
		success: function(msg){
			var mod='\<div><h2 class="red floatleft" style="margin-top: 3px;">Adatvédelmi szabályzat</h2>\
			<img src="/js/facebox/closelabel.gif" alt="" width="66" height="22" style="cursor: pointer;" class="hand vmid floatright"\
			onclick="jQuery(document).trigger(\'close.facebox\');" />\
			<br class="clear" style="clear: both;" /></div>\
			<div style="width:650px; height: 400px; overflow: auto;"> \
			'+msg+'\
			</div>';
			jQuery.facebox(mod);
		}
	});

}
$(document).ready(function(){
	$("#elfogadom").click(function(){
		if ($(this).hasClass('fakechecked')){
			$(this).removeClass('fakechecked')
			document.getElementById('elfogad').checked=false;
		} 
		else {
			$(this).addClass('fakechecked');
			document.getElementById('elfogad').checked=true;
		}
		
		return false;
	});
});

$(document).ready(function(){
	$("#hirlevel1").click(function(){
		if ($(this).hasClass('fakechecked')){
			$(this).removeClass('fakechecked')
			document.getElementById('hirlevel_1').checked=false;
		} 
		else {
			$(this).addClass('fakechecked');
			document.getElementById('hirlevel_1').checked=true;
		}
		
		return false;
	});
});	

$(document).ready(function(){
	$("#hirlevel2").click(function(){
		if ($(this).hasClass('fakechecked')){
			$(this).removeClass('fakechecked')
			document.getElementById('hirlevel_2').checked=false;
		} 
		else {
			$(this).addClass('fakechecked');
			document.getElementById('hirlevel_2').checked=true;
		}
		
		return false;
	});
		
});	


$(document).ready(function(){
$("#letszam").keypress(function (e)  
	{ 
		  //if the letter is not digit then display error and dont type anything
		  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
		  {
			//display error message
			$("#hiba").html("Csak számok írhatóak!").show().fadeOut(3000); 
			return false;
		  }	
	});
});


function radiocheck(obj,id){
		
		$('#r1').removeClass('fakechecked');
		$('#r2').removeClass('fakechecked');
		$('#r3').removeClass('fakechecked');
		$('#r4').removeClass('fakechecked');
		
		if (!$(obj).hasClass('fakechecked')){
			$(obj).addClass('fakechecked');
			document.getElementById(id).checked=true;
		}
		
		if ($('#r3').hasClass('fakechecked')){
			//$("#ekuvokerdes").css('display','block');
		}
		else{
			//$("#ekuvokerdes").css('display','none');
		}
		
		if ($('#r4').hasClass('fakechecked')){
			$("#egyebrend").css('display','block');
		}
		else{
			$("#egyebrend").css('display','none');
		}
				
		return false;
}

function radiocheck2(obj,id){
		
		$('#r5').removeClass('fakechecked');
		$('#r6').removeClass('fakechecked');
				
		if (!$(obj).hasClass('fakechecked')){
			$(obj).addClass('fakechecked');
			document.getElementById(id).checked=true;
		}
							
		return false;
}


function opengal(id){

var fireOnThis = document.getElementById(id);
if( document.createEvent ) {
  var evObj = document.createEvent('MouseEvent');
  evObj.initEvent( 'click', true, false );
  fireOnThis.dispatchEvent(evObj);
} else if( document.createEventObject ) {
  fireOnThis.fireEvent('onclick');
}

}


function show_e()
{
	$.ajax({
		type: "POST",
		url: "/process/eskuvoi_probavacsora.php",
		success: function(msg){
			var mod='\<div><h2 class="red floatleft" style="margin-top: 3px;">Esküvői próbavacsora ajánlat</h2>\
			<img src="/js/facebox/closelabel.gif" alt="" width="66" height="22" style="cursor: pointer;" class="hand vmid floatright"\
			onclick="jQuery(document).trigger(\'close.facebox\');" />\
			<a href="/eskuvoi_probavacsora.html" target="blank" class="vmid floatright"><img src="/images/nyomtat.gif" alt="" style="cursor: pointer; margin-right:20px;" class="hand vmid floatright"\
			 /></a>\
			<br class="clear" style="clear: both;" /></div><div id="kordinata"></div>\
			<div> \
			'+msg+'\
			</div>';
			jQuery.facebox(mod);
		}
	});
}

function show_ev()
{
	$.ajax({
		type: "POST",
		url: "/process/eskuvoi_ejfeli_vacsora.php",
		success: function(msg){
			var mod='\<div><h2 class="red floatleft" style="margin-top: 3px;">Esküvői éjféli vacsora ajánlat</h2>\
			<img src="/js/facebox/closelabel.gif" alt="" width="66" height="22" style="cursor: pointer;" class="hand vmid floatright"\
			onclick="jQuery(document).trigger(\'close.facebox\');" />\
			<a href="/eskuvoi_ejfeli_vacsora.html" target="blank" class="vmid floatright"><img src="/images/nyomtat.gif" alt="" style="cursor: pointer; margin-right:20px;" class="hand vmid floatright"\
			 /></a>\
			<br class="clear" style="clear: both;" /></div><div id="kordinata"></div>\
			<div> \
			'+msg+'\
			</div>';
			jQuery.facebox(mod);
		}
	});
}
