jQuery(document).ready(function() {

    jQuery('#mycarousel').jcarousel({scroll:2,auto:4,wrap:'last'});
	$("a[rel=fotogallery]").fancybox({
		'overlayShow'	: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
	$(".shop_info").fancybox();
	$('.tip').cluetip({cluetipClass: 'jtip',
  dropShadow: false,
  positionBy: 'mouse'});
});
	function change_lang(){
		var objSel = document.getElementById("change_lang");
		MyVal2=(objSel.options[objSel.selectedIndex].value);
		document.location.href = MyVal2;
	}
	
	function isValidEmail( fieldValue ) {
						if ( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/.test(fieldValue) )	return true;
						return false;
					} 

	function show_box(id,type,id_song){
		$.ajax({
			type: "GET",
			url: "/ajax.php",
			data: "act=show_"+type+"&id_song="+id_song,
			success: function(data){
				if($('#info_td_'+id).children().attr('rel')!=type+'_'+id){
					$('#info_td_'+id).show();
					$('#info_td_'+id).children().html(data);	
					$('#info_td_'+id).children().attr('rel',type+'_'+id);
					$('#'+type+'_box_'+id).parent().parent().children('.n2').css('font-weight','bold');
				}else{
					$('#info_td_'+id).children().attr('rel','');
					$('#'+type+'_box_'+id).parent().parent().children('.n2').css('font-weight','normal');
					$('#info_td_'+id).hide();
				}	
			}	
		});	
	};
	
	function SendShopForm(){
		error=0;
		error_msg='';
		
		if ($('input#shop_title').attr('value')==''){$('input#shop_title').css('background','red');error=1;}else{$('input#shop_title').css('background','#ebb95e');}
		if ($('input#shop_phone').attr('value')==''){$('input#shop_phone').css('background','red');error=1;}else{$('input#shop_phone').css('background','#ebb95e');}
		if (!isValidEmail($('input#shop_email').attr('value'))) {			
						
						error=1;
						$('input#shop_email').css('background','red');
					}else{
						$('input#shop_email').css('background','#ebb95e');
					}
		
		
		if(error==0){
			$.ajax({
				type: "GET",
				url: "/ajax.php",
				data: 'act=send_shop_form&'+$('#ShopForm').serialize(),
				success: function(data){
					alert("Ваше замовлення оформлено - найближчим часом ми з вами зв'яжемось");	
				}	
			});
			$.fancybox.close();
			$('.error_info').html("");
		}else{
			$('.error_info').html("Заповніть всі обов'язкові поля");
		}
		return false;
	}
	
	function CheckForm(){
		resp='';
		$.ajax({
				type: "GET",
				url: "/ajax.php",
				data: 'act=check_form&cod='+$('#cod').attr('value'),
				dataType: "json",
				async: false,
				success: function(data){
					if(data.resp=='1'){resp=1;}else{resp=0;}
				}	
			});	
		if(resp==1){return true;}else{alert('Illegal cod');return false;}

	}

