
$(document).ready(function() {   	 	   

		hrel = location.href.lastIndexOf("/");
		href = location.href.substr(hrel);
		pathArray = window.location.pathname.split( '/' );

		if (href=='/') {
	
			if (mobile_device==0) {
				$("#site_bottom").hide();
				$("#site_main").hide();			
				$("#site_top_header").css({ opacity: 0.0 });
				$("#site_top_logo").css({ opacity: 0.0, marginLeft: '40px' });
				$("#site_top_header").css({ paddingLeft: '60px' });
				$('#startbigbox a span').each(function() {
					$(this).css({ marginTop: 5 });
				});
				
				$("#site").fadeIn(600);			
				$("#site_bottom").fadeIn(1200);
				$("#site_top_header").animate({ opacity: 1.0, paddingLeft: '0px' }, 1200);
				$("#site_top_logo").animate({ opacity: 1.0, marginLeft: '70px' }, 1200);
				$("#site_main").fadeIn(1200);		
	
				$('#startbigbox a span').each(function() {
					$(this).animate({ marginTop: 30 }, 800);
				});	
			}
								
					
			//startboxes animation 
		
			var startbox_speed = 250; 
			var startbox_speed2 = 150; 
			var startbox_speed3 = 80; 
			var startbox_speed4 = 200; 
		
			$('#startbigbox a').hover(function() {
				//$(this).animate({ opacity: 0.7 }, startbox_speed3); $(this).animate({ opacity: 1.0 }, startbox_speed3);					
				$(this).animate({ opacity: 0.8 }, startbox_speed4);									  
				$(this).children("span").stop().animate({ marginTop: 30, marginRight: 0, paddingTop: 5, paddingBottom: 5,  marginLeft: 10, opacity: 0.9 }, { queue:true,duration:startbox_speed2 });
			  }, function() {
				$(this).animate({ opacity: 1.0 }, startbox_speed);									  
				$(this).children("span").stop().animate({ marginTop: 30, marginRight: 20, paddingTop: 5, paddingBottom: 5, marginLeft: 0, opacity: 1.0 }, startbox_speed );
			});

	
		} else {
			
			if (pathArray[1]=="admin") {


				// admin alatt no anim
				//$("#site_main").css({ opacity: 0.0 });
				document.getElementById('site_main_content').style.visibility = 'visible';
				//$("#site_main").animate({ opacity: 1.0 }, 1);


				// admin bejelentkezés
				$("#login_fnev").focus();				
				$("#form_adminlogin").validate({
					rules: {						
						login_fnev: { required: true },
						login_jelszo: { required: true }		
					},
					messages: { 										
						login_fnev: {	required: "Kötelezően kitöltendő mező!" },
						login_jelszo: {	required: "Kötelezően kitöltendő mező!" }		
					}	
				});	


				// content és galéria -hoz confirm a törlésnél
				$("#delete").click( function() {				
 					cnf = confirm('Biztosan törölni akarod?');
					if (cnf) { return true;	} else { return false; }
				});




				//menu szerkesztése
				if (pathArray[2]=="menu") {

					$('#se_menu').change( function(){  window.location = '/admin/menu/'+$('#se_menu').val();  });
										
					// menu confirm a törlésnél
					$("#delete_menu").click( function() {										
	 					if ($('#se_menu :selected').text()=='') { return false;	}						
						cnf = confirm('FIGYELEM! Az alatta lévő menük és oldalak is tőrlődnek! Biztosan törölni akarod?');
						if (cnf) { return true;	} else { return false; }						
					});
			
					$("#menuitem_new").click( function() {										
						if ($('#new_menuitem_name').val()=='') { return false; } 						
					});
					


				}


				// content szerkesztése
				if (pathArray[2]=="content") {

					$(function(){
					  $.fck.config = {path: '/include/fckeditor/', width: '100%', height: 600 };	 		   
					  $('textarea#editbox').fck({ toolbar: 'Custom' });					  
					});		
					
					$('#se_content').change( function(){  window.location = '/admin/content/'+$('#se_content').val();  });				 	

				}



				// galéria szerkesztése												

				$("#se_photo option:first").attr("selected", true);
				
				$("#del_photo").click( function() {				
					cnf = confirm('Biztosan törölni akarod?');
					if (cnf) { return true;	} else { return false; }
				});			
				
				$("#se_photo").change( function(){ 					
					img = $("#se_photo :selected").attr("file");
					
					if (img!="") {

						txt = $('#se_photo :selected').text();
						$(".thumb_box #photo_text").val(txt);
						$(".thumb_box #photo_img").attr("src", '/images/galeria/thumb_'+img);
						$(".thumb_box #del_photoname").val(img);

					} 
				});
				
				
				// owner szerkesztése
				$("#form_owner").validate({
					rules: {						
						in_site_name: { required: true },
						in_site_description: { required: true },
						in_site_keywords: { required: true },
						in_logo_text: { required: false },
						in_company: { required: true },
						in_company_short: { required: true },
						in_address: { required: false },
						in_post_address: { required: false },
						in_tel_fax: { required: false },
						in_mail: { required: true, email: true } 
						
					},
					messages: { 										
						in_site_name: {	required: "Kötelezően kitöltendő mező!" },
						in_site_description: {	required: "Kötelezően kitöltendő mező!" },		
						in_site_keywords: {	required: "Kötelezően kitöltendő mező!" },
						in_logo_text: {	required: "Kötelezően kitöltendő mező!" },						
						in_company: {	required: "Kötelezően kitöltendő mező!" },						
						in_company_short: {	required: "Kötelezően kitöltendő mező!" },						
						in_address: {	required: "Kötelezően kitöltendő mező!" },						
						in_post_address: {	required: "Kötelezően kitöltendő mező!" },
						in_tel_fax: {	required: "Kötelezően kitöltendő mező!" },						
						in_mail: {	required: "Kötelezően kitöltendő mező!", email: "Kérjük valós email címet adjon meg!" }						
					}	
				});	
				
				
			} else {							
				
				// aloldalak animációja
				//$("#site_main_content").css({ marginTop: '30px' });
				document.getElementById('site_main_content').style.visibility = 'visible';
				
				//dbcontent oldalakhoz img megjenelítés fancy-val
				$("div#dbcontent a.fancybox").fancybox({ 'hideOnContentClick': true }); 

				// kapcsolat
					$("#form_kapcsolat").validate({
						rules: {						
							kapcsolat_nev: { required: true },
							kapcsolat_email: { required: true, email: true },				
							kapcsolat_uzenet: { required: true }
						},
						messages: { 										
							kapcsolat_nev: {	required: "Kötelezően kitöltendő mező!" },
							kapcsolat_email: {	required: "Kötelezően kitöltendő mező!", email: "Kérem valós email címet adjon meg!" },			
							kapcsolat_uzenet: { required: "Kötelezően kitöltendő mező!" }
						}	
					});
			
			
			
				//galéria

				// ezt kell állítani, ha nagyobb box van állítva a php-ben a képek dobozának
				gbox = 50;
				max_anim = -20;
				padmarg = 2;
				
				$('#galeria a').hover(function() {					
					anim_width = ($(this).children("img").width()+padmarg-gbox)*-1;					
					if (anim_width>0) { anim_width = 0; }	
					if (anim_width<max_anim) { anim_width = max_anim; }	
											   
					$(this).stop().animate({ marginLeft: anim_width }, {queue:true, duration: 300});		
					$(this).parent("div").stop().animate({ backgroundColor: '#333333' }, {queue:true,duration:200});	
				  }, function() {
					$(this).animate({ marginLeft: 0 }, {queue:true,duration:350});	
					$(this).parent("div").animate({ backgroundColor: 'white' }, {queue:true,duration: 250});						
				  });	
			
				if (mobile_device==0) {
					$("div#galeria a").fancybox({ 'hideOnContentClick': true }); 
				}


				// a végére került IE miatt, mert túl gyorsan futott le
				$("#site_main_content").animate({  marginTop: '0px' }, 800);


			}

		}
		


	//main menu animation 

		$(".lavaLampNoImage li ul").each( function() {
			//$(this).css({ opacity: 1.0, paddingTop: 5 })
			$(this).hide();							
		});


		$('.lavaLampNoImage li ul li a').hover(function() {
			$(this).animate({ color: '#1458c7' }, {queue:true, duration: 300 });		
		}, function() {
			$(this).animate({ color: 'black' }, {queue:true, duration: 400 });			
		});

        $(function() {
            $("#lavamenu").lavaLamp({
                fx: "backout",
                speed: 1000,
				ulspeed: 250
            });
        });



	//site bottom
	$('#site_bottom_footer a').hover(function() {
		$(this).stop().animate({ color: 'white', paddingLeft: 0 }, 150);		
      }, function() {
        $(this).stop().animate({ color: '#294a57', paddingLeft: 0 }, 900 );
      });	



});
