// JavaScript Document

slideshow_names = new Array('floors.jpg', 'kitchen.jpg', 'bathroom.jpg' );
slideshow_text = new Array('<b>Floors</b><p>ABK<br />Graniti Fiandre<br />Daugres<br />Hongweng<br />Gazzotti</p>', '<b>Kitchen</b><p>Schiffini<br />Moretuzzo<br />Leicht</p>', '<b>Bathroom</b><p>Antonio Lupi<br />Zucchetti<br />Keuco<br />Bellavista</p>' );
slideshow_layer_side = new Array('l', 'l', 'l');
slideshow_number = 3;
slide_active = 2;


function dc_start() {
	/*
	// png fix a jquerypngfix pluginnel
	$(document).pngFix();
	*/
	//
	$('.iframe').fancybox({	'frameWidth': 600, 
						  	'frameHeight': 350,
							'zoomOpacity': true,
							'overlayShow': true,
							'overlayOpacity': 0.6,
							'zoomSpeedIn': 500,
							'zoomSpeedOut': 500	,
							'padding': 3});
	// a helyettesitendő css :hover elemek eltüntetése
	$('.no_js').removeClass('no_js').addClass('js');
	
	// a hivatkozások popup animációja
	$('a > em.popup').parent().hover(
						function() {
							$(this).children('em').stop().css({
															  'opacity': 0, 
															  'left': $(this).offset().left+($(this).width()/2)-($(this).children('em').width()/2), 
															  'top':$(this).offset().top-80}
															  ).show();
							$(this).children('em').animate({'top': '+=10px', 'opacity': 0.9}, 'fast');
						},
						function() {
							$(this).children('em').stop().animate({'opacity': 0, 'top': '-=10px'}, 'slow', 
																  function() {
																	  $(this).css({'display': 'none'});
																  }
							);
						});
	
	// a menü animációja
	$('.menu a.js:not(.selected)').add('a.back_button').add('.send_button').add('.discount').fadeTo(1000, 0.5).hover(
		function() {
			$(this).stop().fadeTo('fast', 1);
		},
		function() {
			if ($(this).is(':animated')) $(this).stop().fadeTo('fast', 1 , 
															   function() {
																   $(this).fadeTo(600, 0.5);
																});
			else $(this).stop().fadeTo(600, 0.5);
		}
	);
	// a galéria animációja
	$('a.gallery').fadeTo(1000, 0.7).hover(
		function() {
			$(this).stop().fadeTo('fast', 1);
		},
		function() {
			if ($(this).is(':animated')) $(this).stop().fadeTo('fast', 1 , 
															   function() {
																   $(this).fadeTo(600, 0.7);
																});
			else $(this).stop().fadeTo(600, 0.7);
		}
	);
	// a lábléc logók animációja
	$('a.logo_footer').fadeTo(1000, 0.3).hover(
		function() {
			$(this).stop().fadeTo('fast', 1);
		},
		function() {
			if ($(this).is(':animated')) $(this).stop().fadeTo('fast', 1 , 
															   function() {
																   $(this).fadeTo(600, 0.3);
																});
			else $(this).stop().fadeTo(600, 0.3);
		}
	);
}

function slide() {
	$('.slideshow2 span').slideToggle('slow', 
									 function() {
										 $('.slideshow2').fadeOut('slow', 
																  function() {
																	  $('.slideshow2').css({'backgroundImage': 'url(inc/img/'+slideshow_names[slide_active]+')'}).show().children('span').html(slideshow_text[slide_active]).removeClass('r l c').addClass(slideshow_layer_side[slide_active]).slideToggle('slow');
																	  slide_active++;
																	  if (slide_active==slideshow_number) slide_active=0;
																	  $('.slideshow').css({'backgroundImage': 'url(inc/img/'+slideshow_names[slide_active]+')'});
																	  setTimeout('slide();', 7000);

																  }
										 );
									 }
	);
}

function start_slideshow() {
	
	$('.slideshow2 span').hide().css({'opacity': 0.8});
	$('.slideshow2').css({'backgroundImage': 'url(inc/img/'+slideshow_names[slide_active]+')'});
	$('.slideshow2 span').addClass(slideshow_layer_side[slide_active]).slideToggle('slow');
	slide_active = 0;
	$('.slideshow').css({'backgroundImage': 'url(inc/img/'+slideshow_names[slide_active]+')'});
	setTimeout('slide();', 7000);
	//console.log(slideshow_names[slide_active]);
	//console.log(slideshow_layer_side[slide_active]);

}

function make_gallery() {
	
		$("a.gallery").fancybox({
			'zoomOpacity'			: true,
			'overlayShow'			: true,
			'overlayOpacity'		: 0.4,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500,
			'hideOnContentClick'	: false,
			'callbackOnStart'		: function() {
											$(".head > div").hide();
										},
			'callbackOnClose'		: function() {
											$(".head > div").show();
										}
		});
	
}

function show_error(input_tag) {
	
	$('#'+input_tag).parent().addClass('error').children('span').show();
	
}

function hide_error(input_tag) {
	
	$('#'+input_tag).parent().removeClass('error').children('span').hide();
	
}

function submit_contact() {
	
	error = false;
	name =$('input#name').val();
	email =$('input#email').val();
	phone =$('input#phone').val();
	address =$('input#address').val();
	city =$('input#city').val();
	state =$('input#state').val()
	postcode =$('input#postcode').val();
	comment =$('textarea#comment').val();
	
	if (name == "") {
		
		error = true;
		show_error('name');
		
	}

	if (email == "") {
		
		error = true;
		show_error('email');
		
	}
	
	if (phone == "") {
		
		error = true;
		show_error('phone');
		
	}
	
	if (comment == "") {
		
		error = true;
		show_error('comment');
		
	}
	
	if (error) return false;
	
	dataString = 'name=' + name + '&email=' + email + '&phone=' + phone + '&address=' + address + '&city=' + city + '&state=' + state + '&postcode=' + postcode + '&comment=' + comment;
	
	$('form').hide().parent().css(	{'color': '#cc0066', 'text-align': 'center', 'vertical-align': 'middle'}).html('<br /><br /><br /><br /><img src="/inc/img/ajax-loader.gif" /> Please wait...').fadeIn(300);
	
	$.ajax({  
		type: "POST",  
		url: "/inc/contact.php",  
		data: dataString,
		dataType: "html",
		success: function(response_cont) {  
			$('#form').slideDown('slow')
			.html(response_cont)
			.fadeIn(600);
			$('form').slideUp('slow');
		}  
	});  
	return false;  

}

function submit_register() {
	
	error = false;
	name =$('input#name').val();
	email =$('input#email').val();
	phone =$('input#phone').val();
	address =$('input#address').val();
	city =$('input#city').val();
	state =$('input#state').val()
	postcode =$('input#postcode').val();
	
	if (name == "") {
		
		error = true;
		show_error('name');
		
	}

	if (email == "") {
		
		error = true;
		show_error('email');
		
	}
	
	if (phone == "") {
		
		error = true;
		show_error('phone');
		
	}
	
	if (address == "") {
		
		error = true;
		show_error('address');
		
	}
	
	if (city == "") {
		
		error = true;
		show_error('city');
		
	}

	if (postcode == "") {
		
		error = true;
		show_error('postcode');
		
	}

	if (error) return false;
	
	dataString = 'name=' + name + '&email=' + email + '&phone=' + phone + '&address=' + address + '&city=' + city + '&state=' + state + '&postcode=' + postcode;
	
	$('form').hide().parent().css(	{'color': '#cc0066', 'text-align': 'center', 'vertical-align': 'middle'}).html('<br /><br /><br /><br /><img src="/inc/img/ajax-loader.gif" /> Please wait...').fadeIn(300);
	
	$.ajax({  
		type: "POST",  
		url: "/inc/register.php",  
		data: dataString,
		dataType: "html",
		success: function(response_cont) {  
			$('#form').slideDown('slow')
			.html(response_cont)
			.fadeIn(600);
			$('form').slideUp('slow');
		}  
	});  
	return false;  

}

function submit_register2() {
	
	error = false;
	name =$('input#name').val();
	email =$('input#email').val();
	phone =$('input#phone').val();
	address =$('input#address').val();
	city =$('input#city').val();
	state =$('input#state').val()
	postcode =$('input#postcode').val();
	
	if (name == "") {
		
		error = true;
		show_error('name');
		
	}

	if (email == "") {
		
		error = true;
		show_error('email');
		
	}
	
	if (phone == "") {
		
		error = true;
		show_error('phone');
		
	}
	
	if (address == "") {
		
		error = true;
		show_error('address');
		
	}
	
	if (city == "") {
		
		error = true;
		show_error('city');
		
	}

	if (postcode == "") {
		
		error = true;
		show_error('postcode');
		
	}

	if (error) return false;
	
	dataString = 'name=' + name + '&email=' + email + '&phone=' + phone + '&address=' + address + '&city=' + city + '&state=' + state + '&postcode=' + postcode;
	
	$('form').hide().parent().css(	{'color': '#cc0066', 'text-align': 'center', 'vertical-align': 'middle'}).html('<br /><br /><br /><br /><img src="/inc/img/ajax-loader.gif" /> Please wait...').fadeIn(300);
	
	$.ajax({  
		type: "POST",  
		url: "/inc/register2.php",  
		data: dataString,
		dataType: "html",
		success: function(response_cont) {  
			$('#form').slideDown('slow')
			.html(response_cont)
			.fadeIn(600);
			$('form').slideUp('slow');
		}  
	});  
	return false;  

}

$(document).ready(function () { dc_start(); if (slideshow) start_slideshow(); if (gallery) make_gallery(); /*.parent().hover(function() {
    // on hovering over, find the element we want to fade *up*
		$(".slideshow span").slideToggle('slow');
    }, function() {
    // on hovering over, find the element we want to fade *up*
		$(".slideshow span").slideToggle('slow'); 
	});*/
});