$(document).ready(function() {
		
	$("#slider-list").easySlider({
		auto: true,
		continuous: true,
		numeric: true,
		pause: 6000
	});
		
		//alert($.browser.google);
		
	$(".projects-help").fancybox({
			'scrolling'		: 'no',
			'titleShow'		: false
	});
		
	$("#site-map-box").hide();
	$("#language-box").hide();
	
	$("#site-map-link").toggle(
      function () {
        $("#site-map-box").slideDown('slow');
      },
      function () {
        $("#site-map-box").slideUp('slow');
      }
    );
    
    $("#language-link").toggle(
      function () {
        $("#language-box").slideDown('slow');
      },
      function () {
        $("#language-box").slideUp('slow');
      }
    );
    
    $(".projects-big").fancybox({
    		'titleShow'		: true,
    		'titlePosition'  : 'inside',
    		'autoScale' : false
    });
	
	$(".projects-big-grid").fancybox({
			'titleShow'		: true,
    		'titlePosition'  : 'inside',
    		'autoScale' : false
    });
    
    $(".projects-flash-750x100").fancybox({
    		'type'			: 'swf',
			'titleShow'		: false,
    		'autoScale'			: true,
    		'width'         		: 750,
			'height'        		: 100
	});
	
	$(".projects-flash-750x200").fancybox({
    		'type'			: 'swf',
			'titleShow'		: false,
    		'autoScale'			: true,
    		'width'         		: 750,
			'height'        		: 200
	});
	
	$(".projects-flash-180x150").fancybox({
    		'type'			: 'swf',
			'titleShow'		: false,
    		'autoScale'			: true,
    		'width'         		: 180,
			'height'        		: 150
	});
	
	$(".projects-flash-160x600").fancybox({
    		'type'			: 'swf',
			'titleShow'		: false,
    		'autoScale'			: true,
    		'width'         		: 160,
			'height'        		: 600
	});
	
	$(".projects-flash-300x250").fancybox({
    		'type'			: 'swf',
			'titleShow'		: false,
    		'autoScale'			: true,
    		'width'         		: 300,
			'height'        		: 250
	});
	
	$(".projects-flash-120x600").fancybox({
    		'type'			: 'swf',
			'titleShow'		: false,
    		'autoScale'			: true,
    		'width'         		: 120,
			'height'        		: 600
	});
	
	$(".projects-flash-468x60").fancybox({
    		'type'			: 'swf',
			'titleShow'		: false,
    		'autoScale'			: true,
    		'width'         		: 468,
			'height'        		: 60
	});
	
	$(".projects-flash-468x80").fancybox({
    		'type'			: 'swf',
			'titleShow'		: false,
    		'autoScale'			: true,
    		'width'         		: 468,
			'height'        		: 80
	});
	
	$("#send-question-button").fancybox({
		'scrolling'		: 'no',
		'titleShow'		: false,
		'overlayOpacity' : 0.5,
		'overlayColor' : '#000000',
		'padding'		: 0
	});
	
	//$(".slide-navi").tabs(".news-images", {
	//		// enable "cross-fading" effect
	//		effect: 'fade',
	//		fadeOutSpeed: "slow",
	//		
	//		// start from the beginning after the last tab
	//		rotate: true
	//		
	//		// use the slideshow plugin. It accepts its own configuration
	//}).slideshow({
	//		interval: 6000,
	//		autoplay: true
	//});
	
	
	$(".slide-navi2").tabs(".index-center-block-group", {
			// enable "cross-fading" effect
			effect: 'fade',
			fadeOutSpeed: "slow",
			
			// start from the beginning after the last tab
			rotate: true
			
			// use the slideshow plugin. It accepts its own configuration
	}).slideshow({
			interval: 6000
	});
	
	$("#loading-offer-button").fancybox({
		'scrolling'		: 'no',
		'titleShow'		: false
   });
	
	$("#test").fancybox({
		'scrolling'		: 'no',
		'titleShow'		: false
   });
	
	$("#download_now").tooltip({ effect: 'slide'});
	
	$("#contact-box").css({'width' : '320px', 'color' : '#3d3d3d', 'font-size' : '11px', 'background' : '#ffffff',  'padding' : '25px 25px 35px 25px', 'text-align' : 'left'});
	$("#contact-box-title-name").css({'text-indent':'0', 'font-size':'12px'});
	
	$("#contact-required").css({'margin' : '5px 0 10px 0'});
    $("#contact-form-title").css({'font-size' : '13px', 'font-weight' : 'bold', 'margin' : '0 0 8px 0'});
	$("#contact-box p").css({'line-height':'150%'});
	$("#contact-box label").css({'display':'block', 'line-height':'150%', 'margin':'8px 0 2px 0'});
    $("#contact-box select").css({'width':'270px', 'height':'22px', 'border':'1px solid #abadb3'});
    $("#contact-email, #contact-email-from, #contact-phone").css({'width':'318px', 'height':'18px', 'border':'1px solid #abadb3'});
    $("#contact-box #contct-form-type label").css({'dispaly':'inline'});
    $("#contact-form-type").css({'margin':'5px 0 0 0', 'padding':'0', 'list-style-type':'none', 'overflow':'auto'});
	$("#contact-form-type li").css({'float':'left', 'line-height':'35px'});
	$("#contact-form-type input").css({'margin':'0', 'padding':'0'})
	$(".contact-form-type-desc").css({'margin':'0 20px 0 5px'})
    $("#contact-comment").css({'width':'318px', 'height':'100px', 'border':'1px solid #abadb3', 'font-size':'12px', 'font-family':'Arial'})
    $("#contact-form-send").css({'cursor':'pointer', 'text-align':'right', 'margin-top':'20px' });
	$("#contact-form-send input").css({'width':'120px'});
    $("#empty-error, #email-error, #email-error-from").css({'background-color':'#fdb1b1', 'border':'1px solid #fe0000', 'padding':'5px 10px', 'margin':'8px 0 10px 0'});
    $("#contact-type-person, #contact-type-firm").css({'margin-top':'10px'});
	
	$("#empty-error").hide();
	$("#email-error").hide();
	$("#email-error-from").hide();
	$("#checkbox-error").hide();
	
	$("#login_form").bind("submit", function() {
		if ($("#contact-email").val() == "") {
			
			$(this).find(".required-form").each(function(i) {
				if(!$(this).attr("disabled")) {
					if($(this).val() == "") {
						valid = false;
						$(this).css("background-color","#fdb1b1");
					} else {
						$(this).css("background-color","#ffffff");	
					}
				}
			});
			
		    $("#empty-error").show();
		    
		    $.fancybox.resize();
		    return false;
    	}
    	else {
			$("#empty-error").hide();
			$(this).find(".required-form").each(function(i) {
				$(this).css("background-color","#ffffff");
			});
			
			if (!validateEmail($("#contact-email").val())){
				if (!validateEmail($("#contact-email").val())){
					$("#contact-email").css("background-color","#fdb1b1");
					$("#email-error").show();
				}
				else {
					$("#contact-email").css("background-color","#ffffff");
					$("#email-error").hide();
				}
    			
				/*
				if (!validateEmail($("#contact-email-from").val())){
					$("#contact-email-from").css("background-color","#fdb1b1");
					$("#email-error-from").show();
				}
				else {
					$("#contact-email-from").css("background-color","#ffffff");
					$("#email-error-from").hide();
				}
				*/
				return false;
			}
    	}
		
		//if ($("#offer-project").val() == "" || $("#offer-sale").val() == ""){
		//	$("#checkbox-error").show();
		//    return false;
		//}
		//else {
		//	$("#checkbox-error").hide();
		//}
    	
    	$.fancybox.showActivity();
    	
		$.ajax({
			type	: "POST",
			cache	: false,
			url		: "http://www.gbdesign.pl/promotion_form.php",
			data		: $(this).serializeArray(),
			success: function(data) {
				$.fancybox(data);
			}
    	});
	
		return false;
	});
	
	function validateEmail(address) {
   		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   		var address;
   		if(reg.test(address) == false) {
   		   return false;
   		}
   		else {
			   return true;
   		}
   	}
	
	function validateWWW(string) {
		var reg = /^(www\.)[.a-zA-z0-9]+\.[a-zA-z0-9]{2,4}$/;
		var string;
		if(reg.test(string) == false) {
			return false;
		}
		else {
		   return true;
		}
	}
	
});

function dodajDoUlubionych(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

