jQuery(document).ready(function(){
	groups = [];
	jQuery('[class^="image_group"]').each(function(){
		$(this).attr('rel',$(this).attr('class'));
		rel = $(this).attr('rel');
		if( jQuery.inArray(rel,groups) ){
			groups.push($(this).attr('rel'));
		}
	});
	//console.log(groups);
	jQuery.each(groups,function(key,item){
		jQuery('[class="'+item+'"]').fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Kép ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});	
	});	

	/*
	jQuery('[class^="image_group"]').fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Kép ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	*/
/*
	jQuery('.image_group').each(function(){
		jQuery(this).attr('rel','image_group');
	});
	jQuery("a[rel=image_group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Kép ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});*/
    $('.sf-menu > li:last-child').css({'width':'145px'});
  //  $('.ui-accordion > h3:first-child').css({'background-image':'url('+doc_root+'templates/template/img/leftmenu_bg_fst.jpg)','background-position':'0px 0px'});
  //,'background-image':'url('+doc_root+'templates/template/img/navbar_last.jpg)'}
	jQuery('.showimage').each(function(){
		jQuery(this).bind('click',function(){
			return false;
		});
		jQuery(this).bind('mouseover',function(){
			$('#showImage').html('<img src="'+$(this).attr('longdesc')+'" class="shimage">');
			var offset = $(this).offset();
			var top = offset.top;
			var left = offset.left;
			$('#showImage').css('top',top+'px').css('left',left+'px').css('position','absolute');
			$('#showImage').show('slow');
			$('#showImage').bind('mouseout',function(){
				$(this).hide('slow');
			});
		});
		
	});
	
	$('.texthover[title]').tooltip();
	

        // HACK gyula: elso accordin (kapcsolat doboz) kiemelese a harmonikabol, hogy ne csukodjon ossze soha!
        jQuery('#accordin h3:first').each(function(){
            jQuery('#accordin_first').append('<h3 style="background-attachment: scroll;background-clip: border-box;background-color: black;background-image: url(http://www.hairhungary.hu/hhdummy1/templates/template/img/leftmenu_bg_on.jpg);background-origin: padding-box;background-position: 50% 34px;background-repeat: no-repeat;border-bottom-color: black;border-bottom-style: solid;border-bottom-width: 1px;border-left-style: none;border-right-style: none;border-top-style: none;cursor: pointer;display: block;font-family: arial, helvetica, sans-serif;font-size: 12px;font-weight: bold;height: 40px;line-height: 40px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;text-align: center;text-transform: uppercase;width: 189px;">'+jQuery(this).html()+'</h3>');
            jQuery(this).remove();
        });
        jQuery('#accordin div:first').each(function(){
            jQuery('#accordin_first').append('<div style="background-color: transparent;background-image: none;background-position: 0% 0%;background-repeat: repeat;border-bottom-style: none;border-left-style: none;border-right-style: none;border-top-style: none;display: block;font-family: arial, helvetica, sans-serif;font-size: 12px;height: 301px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;overflow-x: visible;overflow-y: visible;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;width: 189px;">'+jQuery(this).html()+'</div>');
            jQuery(this).remove();
        });



  jQuery('.accordion').accordion({
    autoHeight: false,
    event: 'mouseover',
    speed: 3000,
    duration: 3000   
  });

  jQuery('.navbar_menu').supersubs({
    minWidth: 12,
    maxWidth: 27,
    extraWidth: 1
  }).superfish({
    autoArrows:  false,
    dropShadows: false
  });

  jQuery("#slider").easySlider({
    auto: true,
    continuous: true,
    numeric: true,
    speed: 1000,
    pause: 5000
  });
  
  $("#contact_send").click(function(){                  
      var hasError = false;
      var phone = $("#contact_phone").val();
      var name = $("#contact_name").val();
      if(!phone || !name || name=='Név'){
            alert("Kérjük adja meg nevét és telefonszámát is!");
      }else{
            $.ajax({
                type: "POST",
                async : false,
                url: doc_root+"ajax.php", 
                data: "name="+name+"&phone="+phone+"&module=idopont_egyeztetes",
                dataType : "json",
                success: function(msg){
                    
                    if(msg.ok){
                        $("#contact_phone").val("");
                        $("#contact_name").val("Név");
                        location.href=doc_root+"koszonet";
                    }else{
                        alert(msg.mess);
                    }
                }
            });
      }
      return false;
  });
  
  if($('#velemeny_name').length!=0){
    overtext("velemeny_name","Kérjük adja meg nevét");                                        
  }
  if($('#velemeny_email').length!=0){
    overtext("velemeny_email","Kérjük adja e-mail címét");                                        
  }
  if($('#velemeny_name').length!=0){
    overtext("velemeny_tel","Kérjük adja meg telefonszámát");                                        
  }
  
  overtext("contact_name","Név");
  overtext("offer_email","E-mail cím");
  
  $("#offer_send").click(function(){                  
      var hasError = false;
      var email = $("#offer_email").val();     
      var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;             
      if(!email || !emailReg.test(email) ){
            alert("Kérjük adja ismerőse címét pontosan!");
      }else{
            $.ajax({
                type: "POST",
                async : false,
                url: doc_root+"ajax.php", 
                data: "email="+email+"&module=offer&url="+location.href,
                dataType : "json",
                success: function(msg){
                    alert(msg.mess);
                    if(msg.ok){
                        $("#offer_email").val("E-mail cím");                                    
                    }
                }
            });
      }
      return false;
  });
  
});

function overtext(id,value){
    $('#'+id).focus(function(){
            if ($(this).val()==value) $(this).val("");
        });
        $('#'+id).blur(function(){
            if ($(this).val()=="") $(this).val(value);
        });
}

function ellenor_velemeny(){
    if(!$('#velemeny_name').val() || !$('#velemeny_message').val() || $('#velemeny_name').val()=="Kérjük adja meg nevét" ){
        alert("Kérjük adja meg a nevét és az üzenet szövegét is!");
        return false;
    }else{
        return true;
    }
}
function ellenor_kontakt(){
    if(!$('#velemeny_name').val() || !$('#velemeny_message').val() || $('#velemeny_name').val()=="Kérjük adja meg nevét" 
        || !$('#velemeny_email').val() || $('#velemeny_email').val()=="Kérjük adja e-mail címét"
        || !$('#velemeny_tel').val() || $('#velemeny_tel').val()=="Kérjük adja meg telefonszámát"){
        alert("Kérjük adja meg a nevét, telefonszámát, e-mail címét és az üzenet szövegét is!");
        return false;
    }else{
        return true;
    }
}
function ellenor_iratkozas(){
    if(!$('#iratkozas_name').val() || !$('#iratkozast_mail').val()){
        alert("Kérjük adja meg a nevét és az e-mail címét is!");
        return false;
    }else{
        $('#iratkozas_form').submit();
        
    }
}

