var ie = ((navigator.userAgent.toLowerCase().indexOf("msie") != -1) && (navigator.userAgent.toLowerCase().indexOf("opera") == -1) );
var ieki = navigator.userAgent.toLowerCase().indexOf("msie") + 5;
var ieverzio = navigator.userAgent.substr(ieki, 1);

function fokusz(obj){
	document.getElementById(obj).focus();
}

function ugras(url){
	document.location.href = url;	
}

function select_beallito(snev, str){
	db = document.getElementById(snev).length;
	j = 0;
	for(i=0;i<db;i++){
	  	if( document.getElementById(snev).options[i].value.toLowerCase()==str.toLowerCase() ){
		  	j = i;
			break;
		}
	}
	document.getElementById(snev).selectedIndex = j;
}

function ertek_kereso(miben, mit, tVv){
	db 	= document.getElementById(miben).length;
	j 	= 0;
	van = 0;
	for(i=0;i<db;i++){
		if(tVv=="value"){
			if( document.getElementById(miben).options[i].value.toLowerCase()==mit.toLowerCase() ){
				van = 1;
				break;
			}
		}else{
			if( document.getElementById(miben).options[i].text.toLowerCase()==mit.toLowerCase() ){
				van = 1;
				break;
			}
		}
	}
	return van;
}

function getFormValues(fobj){
	var str = "";

	for(var i = 0; i < document.getElementById(fobj).elements.length; i++){
		str += document.getElementById(fobj).elements[i].name + "=" + escape(document.getElementById(fobj).elements[i].value) + "&";
	}
	return str;
}

function inputCheck_notEmpty(obj){
	if(document.getElementById(obj).type=="text" || document.getElementById(obj).type=="textarea"){
		var ertek = document.getElementById(obj).value;
		if(ertek.length==0){
			//alert("A mezo erteke nem lehet ures!");
			//fokusz(obj);
			return 0;	
		}else{
			return 1;
		}
	}
	return 1;
}

function inputCheck_number(obj){
	if(document.getElementById(obj).type=="text"){
		var ertek = document.getElementById(obj).value;
		if(isNaN(ertek)){
			alert("A mezo ertekenek szamnak kell lennie!");
			fokusz(obj);
			return 0;	
		}else{
			return 1;
		}
	}
	return 1;
}

function countLetter(str, letter){
	count = 0;
	pos = str.indexOf(letter);
	while ( pos != -1 ) {
		count++;
   		pos = str.indexOf(letter, pos+1);
	}
	return count;
}

function check_emailAddress(email){
	if(email.length < 5 ) { return 0; }
	if(email.indexOf("@")==-1 || email.indexOf("@")==0) { return 0; }
	if(email.indexOf(".")==-1 || email.indexOf(".")==0 || email.indexOf(".")==1) { return 0; }
	if(countLetter(email, "@")>1) { return 0; }
	if(countLetter(email, ".")==0) { return 0; }
	return 1;
}

function kozepre(){
	_mx = screen.width/2-200;
	_my = screen.height/2-100;
	moveTo(_mx, _my);
}

function resetFormValues(formName){
	for(var i = 0; i < document.getElementById(formName).elements.length; i++){
		if(document.getElementById(formName).elements[i].type=="text" || document.getElementById(formName).elements[i].type=="textarea"){
			document.getElementById(formName).elements[i].value = "";
		}
	}
}

function rejt(obj){
	document.getElementById(obj).style.visibility = "hidden";
}

function megjegyzesON(evt, szoveg){
	var obj   = document.getElementById("megjegyzes");
	var x_offset = (ie==false) ? window.pageXOffset : document.body.scrollLeft;
	var y_offset = (ie==false) ? window.pageYOffset : document.documentElement.scrollTop;

  	obj.style.left = evt.clientX + "px";
  	obj.style.top = evt.clientY + y_offset + 20 + "px";
	var obj2 = document.getElementById("szoveglada");
	obj2.innerHTML = szoveg;
	if(szoveg!=""){
		obj.style.visibility = "visible";
	}
}

function megjegyzesMOVE(evt){
	var obj   = document.getElementById("megjegyzes");
	var x_offset = (ie==false) ? window.pageXOffset : document.body.scrollLeft;
	var y_offset = (ie==false) ? window.pageYOffset : document.documentElement.scrollTop;

  	obj.style.left = evt.clientX + "px";
  	obj.style.top = evt.clientY + y_offset + 20 + "px";
}

function ieBrowserWarning(){
	var ki = navigator.userAgent.toLowerCase().indexOf("msie") + 5;
	var verzio = navigator.userAgent.substr(ki, 1);
	var newDiv = document.createElement("div");
	newDiv.setAttribute("id", "ieBrowser");
	newDiv.innerHTML = "<a href='#' id='aIEWarning' title='Eltuntet'><img src='images/iewarning.png' width='281' height='30' alt='ieWarning' /></a>";
	document.body.appendChild(newDiv);
	if(verzio<7){
		$("#ieBrowser").fadeIn("slow");
		setTimeout("$('#ieBrowser').fadeOut('slow')", 5000);
	}
}

function menuReszHu(){
	with(document){
		write("<a id='aMenu1' href='javascript:void(0);' class='menu1'><div class='menuTaroloDiv' id='imgMenu1'><img src='images/menu01.png' width='124' height='96' alt='menu1' /></div></a>");
		write("<a id='aMenu2' href='javascript:void(0);' class='menu2'><div class='menuTaroloDiv' id='imgMenu2'><img src='images/menu02.png' width='141' height='96' alt='menu2' /></div></a>");
		write("<a id='aMenu3' href='javascript:void(0);' class='menu3'><div class='menuTaroloDiv' id='imgMenu3'><img src='images/menu03.png' width='114' height='96' alt='menu3' /></div></a>");
		write("<a id='aMenu4' href='javascript:void(0);' class='menu4'><div class='menuTaroloDiv' id='imgMenu4'><img src='images/menu04.png' width='129' height='96' alt='menu4' /></div></a>");
	}
}

function menuAktivalas(id){
	$("#aMenu1").click(function(){ document.location.href = "start.php"; });
	$("#aMenu1").hover(
		function(){
			if(id!=1){$("#imgMenu1").animate({top:"-32px"}, 200);}
		},
		function(){
			if(id!=1){$("#imgMenu1").animate({top:"0px"}, 300)};
		}
	);
	$("#aMenu2").click(function(){ document.location.href = "szolgaltatas.php"; });
	$("#aMenu2").hover(
		function(){
			if(id!=2){$("#imgMenu2").animate({top:"-32px"}, 200)};
		},
		function(){
			if(id!=2){$("#imgMenu2").animate({top:"0px"}, 300)};
		}
	);
	$("#aMenu3").click(function(){ document.location.href = "referencia.php"; });
	$("#aMenu3").hover(
		function(){
			if(id!=3){$("#imgMenu3").animate({top:"-32px"}, 200)};
		},
		function(){
			if(id!=3){$("#imgMenu3").animate({top:"0px"}, 300)};
		}
	);
	$("#aMenu4").click(function(){ document.location.href = "elerhetoseg.php"; });
	$("#aMenu4").hover(
		function(){
			if(id!=4){$("#imgMenu4").animate({top:"-32px"}, 200)};
		},
		function(){
			if(id!=4){$("#imgMenu4").animate({top:"0px"}, 300)};
		}
	);
}

function gallery() {
	 //if no IMGs have the show class, grab the first image  
	 var current = ($('#keptarolo img.show')?  $('#keptarolo img.show') : $('#keptarolo img:first'));  
   
	 //Get next image, if it reached the end of the slideshow, rotate it back to the first image  
	 var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#keptarolo img:first') :current.next()) : $('#keptarolo img:first'));     
	   
	 //Get next image caption  
	 var caption = next.find('img').attr('rel');   
	   
	 //Set the fade in effect for the next image, show class has higher z-index  
	 next.css({opacity: 0.0})  
	 .addClass('show')  
	 .animate({opacity: 1.0}, 1000);  
   
	 //Hide the current image  
	 current.animate({opacity: 0.0}, 1000)  
	 .removeClass('show');  
	   
	 //Set the opacity to 0 and height to 1px  
	 //$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });   
	   
	 //Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect  
	 //$('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );  
	   
	 //Display the content  
	 $('#gallery .content').html(caption);  
}
