function fixPng()
{
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version >= 5.5 && version < 7) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
		  var img = document.images[i]
		  var imgName = img.src.toUpperCase()
		  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		  {
			 var imgID = (img.id) ? "id='" + img.id + "' " : ""
			 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			 var imgStyle = "display:inline-block;" + img.style.cssText 
			 if (img.align == "left") imgStyle = "float:left;" + imgStyle
			 if (img.align == "right") imgStyle = "float:right;" + imgStyle
			 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			 img.outerHTML = strNewHTML
			 i = i-1
		  }
	   }
	}
}

function fade()
{
	$("#riszponz").fadeIn(1000, function(){
		$("#riszponz").fadeOut(3000);
	});	
}

function lapMeret(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function enableHover(lang)
{
	$(".lab #hirek").hover(function(){
		$(this).css("background-image","url(images/"+lang+"/hirekdoboz-over.jpg)")
	}, function(){
		$(this).css("background-image","url(images/"+lang+"/hirekdoboz.jpg)")
	});
	$(".lab #legujabb").hover(function(){
		$(this).css("background-image","url(images/"+lang+"/legujabbdoboz-over.jpg)")
	}, function(){
		$(this).css("background-image","url(images/"+lang+"/legujabbdoboz.jpg)")
	});
	$(".lab #megrendeles").hover(function(){
		$(this).css("background-image","url(images/"+lang+"/megrdoboz-over.jpg)")
	}, function(){
		$(this).css("background-image","url(images/"+lang+"/megrdoboz.jpg)")
	});
}
	
function disableHover(lang)
{
	$(".lab #hirek").css("background-image","url(images/"+lang+"/hirekdoboz.jpg)").hover(function(){
		$(this).css("background-image","url(images/"+lang+"/hirekdoboz.jpg)")
	}, function(){
		$(this).css("background-image","url(images/"+lang+"/hirekdoboz.jpg)")
	});
	$(".lab #legujabb").css("background-image","url(images/"+lang+"/legujabbdoboz.jpg)").hover(function(){
		$(this).css("background-image","url(images/"+lang+"/legujabbdoboz.jpg)")
	}, function(){
		$(this).css("background-image","url(images/"+lang+"/legujabbdoboz.jpg)")
	});
	$(".lab #megrendeles").css("background-image","url(images/"+lang+"/megrdoboz.jpg)").hover(function(){
		$(this).css("background-image","url(images/"+lang+"/megrdoboz.jpg)")
	}, function(){
		$(this).css("background-image","url(images/"+lang+"/megrdoboz.jpg)")
	});
}

$(function(){ 
	fixPng();
	$(".pics div").each(function(){
		$(this).cycle({fx:'turnLeft', easing: 'bounceout', timeout: 15000});
	});
	$("#kontener").height(window.innerHeight);
    
	/*$(".fej img:not(img[usemap])").mouseover(function(){
		$(this).animate({"left":"+=10px"}, 100, function(){
			$(this).animate({"left":"-=20px"}, 100, function(){
				$(this).animate({"left":"+=10px"}, 100)
			})
		});	
	});
	$("#map").mouseover(function(){
		$(this).next().animate({"left":"+=10px"}, 100, function(){
			$(this).animate({"left":"-=20px"}, 100, function(){
				$(this).animate({"left":"+=10px"}, 100)
			})
		});	
	});*/
	
	var lm = lapMeret();$("#kontener").height(lm[1]);
	$(window).resize(function(){var lm = lapMeret();$("#kontener").height(lm[1])})
	
	$("#szlogen").cycle({fx:'fade', timeout: 15000});
	
	$("#uzinyito").click(function(){
		if($(this).prev().css("display")=="none")
			$(this).attr("src","images/hu/uzidobozzaro.jpg").prev().show();
		else
			$(this).attr("src","images/hu/uzidoboznyito.jpg").prev().hide();
	});
	
	//if($.browser.safari)
	//	$("#szlogen").css("top","139px");
	
	
	var bopen = 0;
	$("#hirek").click(function(){
		if(bopen==0){
		if($(this).height()>241)
		{
			bopen = 1;
			$("#hirek img:eq(0)").hide();$("#hireknegy").hide();
			$(this).animate({
				"width":"240px",
				"height":"140px"
			}, 1500, "backinout", function(){$(this).css("z-index","0");enableHover(lang);bopen=0;$("#elso_h").show();})
		}
		else
		{bopen = 1;
			disableHover(lang);$("#nagyito").show();$("#elso_h").hide();
			$(this).css("z-index","50").animate({
				"width":"738px",
				"height":"280px"
			}, 1000, "backinout", function(){$("#hirek img:eq(0)").show();bopen=0;$("#hireknegy").show();})
		}
		}
	});
	
	$("#legujabb").click(function(){
		if(bopen==0){
		if($(this).height()>241)
		{bopen = 1;
			$("#legujabb img:eq(0)").hide();$("#legujabbnegy").hide();
			$(this).animate({
				"width":"240px",
				"height":"140px",
				"left":"327px"
			}, 1500, "backinout", function(){$(this).css("z-index","0");enableHover(lang);bopen=0;$("#elso").show();})
		}
		else
		{bopen = 1;
			disableHover(lang);$("#elso").hide();
			$(this).css("z-index","50").animate({
				"width":"738px",
				"height":"310px",
				"left":"78px"
			}, 1000, "backinout", function(){$("#legujabb img:eq(0)").show();bopen=0;$("#legujabbnegy").show();})
		}
		}
	});
	
	$("#megrendeles img:eq(0)").click(function(){
		$(this).hide();$("#megr1").show();$("#megr2").hide();
		$("#megrendeles").animate({
				"width":"240px",
				"height":"140px",
				"right":"84px"
		}, 1500, "backinout", function(){$(this).css("z-index","0");enableHover(lang);bopen=0;})
	});
	
	$("#megrendeles").click(function(){
		hopp('kalkulator.hu');
		/*if(bopen==0){
		if($(this).height()>241)
		{
			bopen = 1;
		}
		else
		{bopen = 1;	
			disableHover(lang);$("#megr1").hide();$("#megr2").show();
			$(this).css("z-index","50").animate({
				"width":"738px",
				"height":"280px",
				"rigt":"582px"
			}, 1000, "backinout", function(){$("#megrendeles img:eq(0)").show();bopen=0;
				$("#megrendeles img:eq(0)").animate({"right":"+=10px"}, 300, function(){
					$(this).animate({"right":"-=20px"}, 300, function(){
						$(this).animate({"right":"+=10px"}, 300)
					})
				});
			})
		}
		}*/
	});
	
	$(".box").children().next("a").children().hover(function(){
		if(lang=="de"){														 
			$(this).css("opacity","0.5");$(this).parent().next().next().prepend("(amschauen:) ");
		}else if(lang=="en"){
			$(this).css("opacity","0.5");$(this).parent().next().next().prepend("(check out:) ");
		}else{
			$(this).css("opacity","0.5");$(this).parent().next().next().prepend("(megnézem:) ");
		}
	}, function(){
		rt = $(this).parent().next().next().text();
		if(lang=="de"){
			$(this).css("opacity","1");$(this).parent().next().next().text(rt.replace(/\(amschauen:\) /, ""));
		}else if(lang=="en"){
			$(this).css("opacity","1");$(this).parent().next().next().text(rt.replace(/\(check out:\) /, ""));
		}else{
			$(this).css("opacity","1");$(this).parent().next().next().text(rt.replace(/\(megnézem:\) /, ""));
		}
	});						
	
	$(".box").children().nextAll("a:contains('www')").hover(function(){
		if(lang=="de"){																 
			$(this).prev().prev().children().css("opacity","0.5");$(this).prepend("(amschauen:) ");
		}else if(lang=="en"){
			$(this).prev().prev().children().css("opacity","0.5");$(this).prepend("(check out:) ");
		}else{
			$(this).prev().prev().children().css("opacity","0.5");$(this).prepend("(megnézem:) ");
		}
	}, function(){
		rt = $(this).text();
		if(lang=="de"){
			$(this).prev().prev().children().css("opacity","1");$(this).text(rt.replace(/\(amschauen:\) /, ""));
		}else if(lang=="en"){
			$(this).prev().prev().children().css("opacity","1");$(this).text(rt.replace(/\(check out:\) /, ""));
		}else{
			$(this).prev().prev().children().css("opacity","1");$(this).text(rt.replace(/\(megnézem:\) /, ""));
		}
	});	
	/*
	$("#menu a").each(function(){
		$(this).hover(function(){
		if(lang=="de")						   
			$(this).prepend("(mehr über) ");
		else if(lang=="en")
			$(this).prepend("(read more) ");
		else
			$(this).prepend("(bõvebben) ");
		}, function(){
			r = $(this).text();
			if(lang=="de")
				$(this).text(r.replace(/\(mehr über\) /, ""));
			else if(lang=="en")
				$(this).text(r.replace(/\(read more\) /, ""));
			else
				$(this).text(r.replace(/\(bõvebben\) /, ""));
		});					   
	});*/
	
	$("#kontener").show();
    
    $(".fej ul li a").hover(function() {
        $(this).parent("li").css("list-style-image", "url(images/hu/boxb.jpg)");
    }, function() {
        $(this).parent("li").css("list-style-image", "url(images/hu/box.jpg)");
    });
    
    if($.browser.msie) {
        $(".rsshir").css("margin", "33px 10px 20px");
        $(".fej ul").css("margin-left","50px");
    }
});

function eHover(lng) {
    $(function(){enableHover(lng);$("#szoveg label").each(function(){$(this).click(function(){if($(this).next().next().css("display")=="none"){$(".info").each(function(){$(this).slideUp("slow")});$(this).next().next().slideDown("slow");}else $(this).next().next().slideUp("slow")});$(this).hover(function(){$(this).prev().before('<img src="images/'+lng+'/miez.jpg" width="51" height="18" />')}, function(){$(this).prevAll("img").remove();});});});
}

function postMsg() {
    if($("#uzi").val() != "Nachricht" && $("#uzi").val() != "üzenet") {
        $.post("index.php", $(this.elements).serialize(), function(r) {
            $('.uzidoboz').hide();$('#uzi').val('üzenet')
        });
    }
}

function loadchat()
{
	jQuery('#wibiyaToolbar_item_normal_3').trigger('click');
}
function rmwb()
{
 jQuery("#wibiyaToolbar_item_normal_anchor_2").parent().hide();	
 jQuery(".wibiyaToolbar_wiwi_footerlink").css("display","none");	
}

function hopp(target){
    window.location=target;
}

function hopp_up(target){
    window.parent.location=target;
}

function hoppn(target) {
window.open(target, '', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=700,height=600,left=0,top=0');
}
