// tak moglem zrobic komentarze ale mi sie nie chcialo :)//
$(function(){
		$('img').each(function(){ $(this).attr('alt','');$(this).attr('title',''); });
		if($('body').hasClass('page-id-201')){
			$('.product-right').each(function(){
				if($(this).attr('rel') != 'id_193'){
					$(this).hide();
				}
			});
		}
		$('.product-left h3').each(function(){
				$(this).click(function(){
				$(this).next().toggle();
				var id= $(this).attr('rel');
				//alert(id);
				$('.product-right').each(function(){
					if( $(this).attr('rel') != id ){
						$(this).hide();
					}else{
						$(this).show();
						
					}
				});
				$('.opis').each(function(){
					if( $(this).attr('rel') != id ){
						$(this).hide();
					}else{
						$(this).show();
					}
				});
				$('.'+id+' img').show();
				
			});
		});
		 Cufon.replace('.product-left h3,#content h3,#content h2,#content h1, .link', { fontFamily: 'Myriad' });
		 Cufon.replace('#more a, .menu-menu-top-container,.menu-menu-top-en-container', { fontFamily: 'Myriad' ,hover:true});
		 Cufon.replace('.contact-left input[type="submit"],.gadget a,.special-offer a,.special-offer1 a,.special-offer2 a,.box a,.ceramika a', { fontFamily: 'Myriad Pro'});
		 
		 $('.box').hover(function(){
			$(this).children('a').css('background','url(http://fabrykamagika.pl/wp-content/themes/promoagency/images/box-a-hover.png) no-repeat scroll 2px 0 ');
		 },
		 function(){
			$(this).children('a').css('background','url(http://fabrykamagika.pl/~fabryka/wp-content/themes/promoagency/images/box-a.png) no-repeat scroll 0 0 ');
		 }
		 
		 );
		 
		 
		 /* gallery load*/
		 $('.load').click(function(){
			$.get('http://www.fabrykamagika.pl/ajax/' , {id:$(this).attr('rel')} , function(response){
				$('#main-slider').html(response);
			
			});
		 });
	
	$('#newsletter').submit(function(){	
           
                var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; 
                if( !$('input[name="email"]').val() ){ 
                    alert('Podaj adres email'); 
                    return false; 
                } 
                else if(!emailReg.test($('input[name="email"]').val())) { 
                    alert('Podaj poprawny adres email'); 
                    return false; 
                }
				else{
					$.ajax({
							url: "wp-content/themes/promoagency/newsletter.php?mail="+$('input[name="email"]').val(),						    
						    success: function(data){
							$('.newsletter').html(data);
						  }
					});
					return false;
				}

		}); 
       
	
});


function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	
	if(typeof(arr) == 'object') { //Array/Hashes/Objects 
		for(var item in arr) {
			var value = arr[item];
			
			if(typeof(value) == 'object') { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			} else {
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	} else { //Stings/Chars/Numbers etc.
		dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}


