function ffind(){
	document.getElementById('ffi').submit()
}
function cont_send(){
	document.getElementById('theForm').submit()
}

function sendForm(id){
	document.getElementById(id).submit()
}

function cont_send_mail(){
	var fname=urlEncode(document.getElementById('fname').value);
	var femail=urlEncode(document.getElementById('femail').value);
	var fmess=urlEncode(document.getElementById('fmess').value);
	if (fname && femail && fmess)
		var _ajax = new ajax.ContentLoader('contact.php?fname='+fname+'&femail='+femail+'&fmess='+fmess,
			function(){
				document.getElementById('jinn').style.display='none';
				document.getElementById('jin2').style.display='block';
			});
}

var cc= new Array();
function cl(id,name){
	if(!cc[id]){
		document.getElementById(name).value='';
		cc[id]=1;
	}
}

function cheng_count(){
	jQueryM.post('ajax.php', {
        	"ccountrs": $('#ccountrs').attr('value')
		},function(data){
			$("#kurorrts").html(data);
		});
}
function cheng_count_city(){
	jQueryM.post('ajax.php', {
        	"ccity": $('#ccountrs').attr('value')
		},function(data){
			$("#kuro").html(data);
		});
}


function del(id){
	
			jQuery.post('ajax.php', {
	        	"del_basket": id
			},function(data){
				if(data){
					if($('.basket_show').css('display')!='none'){
						$('.basket_show').slideUp(300,function(){
							$("#in_basket").html(data);
							jQuery.post('ajax.php', {
					        	"getAmount": 1
							},function(dt){
								$("#amount").html(dt+'грн');	
								jQuery.post('ajax.php', {"getKol": 1},function(d){
									$("#col_kor").html(d);	
									$('.basket_show').slideDown('slow');
								});
							});
							
							
							
						});
					} else {
						if(data){
							$("#in_basket").html(data);
							jQuery.post('ajax.php', {
					        	"getAmount": 1
							},function(dt){
								$("#amount").html(dt+'грн');	
								jQuery.post('ajax.php', {"getKol": 1},function(d){
									$("#col_kor").html(d);	
									$('.basket_show').slideDown('slow');
								});
							});
						} else {
							$('.basket_show').slideUp('slow');
							$('#zak_boot').hide('slow');
						}
					}
				} else {
					$('.basket_show').slideUp('slow');
					$('#zak_boot').hide('slow');
				}
			});
			
		
	
			
		
    	return false;
	
}



function ch_color_img(im){
	$('#main_img').fadeOut('slow',function(){
			
		$('#main_img').attr({'src':'files/Image/'+im});
		//currentArrowInterval = setInterval(whileArrowButtonDown, 100);

		$('#main_img').fadeIn('slow');
		//alert($('#main_img').attr('src'));
	});
	
	
	
}

function add_mail2(){
	
	var fio=$('#fio_rass').attr("value");
	var email=$('#emil_rass').attr("value");
	jQuery.post('ajax.php', {
	       "fio_rass":  fio,
	      	"email_rass":  email
	},function(data){
		$('.survey_cont').html('Подписка прошла успешно!');
	});
	//alert('asd');
	
	
}

jQuery(document).ready(function() {
	
	
	$('.baton').click(function(){
		var mim=$(this).attr("name");
		var kkl=$('#kol_'+mim).attr("value");
			jQuery.post('ajax.php', {
	        	"add_basket":  $(this).attr("name"),
	        	"koll_k":  kkl
			},function(data){
				if(data){
					if($('.basket_show').css('display')!='none'){
						$('.basket_show').slideUp(300,function(){
							$("#in_basket").html(data);
							jQuery.post('ajax.php', {
					        	"getAmount": 1
							},function(dt){
								$("#amount").html(dt+'грн');	
								jQuery.post('ajax.php', {"getKol": 1},function(d){
									$("#col_kor").html(d);
									$('#dop_kol'+mim).hide('slow');
									$('#zak_boot').show('slow');
									$('#itog').html('Итого');
									
									$('.basket_show').slideDown('slow');
									
								});
							});
							
						});
					} else {
						if(data){
								$("#in_basket").html(data);
								jQuery.post('ajax.php', {
						        	"getAmount": 1
								},function(dt){
									$("#amount").html(dt+'грн');
									jQuery.post('ajax.php', {"getKol": 1},function(d){
										$("#col_kor").html(d);
										$('#dop_kol'+mim).hide('slow');
										$('#itog').html('Итого');
										$('.basket_show').slideDown('slow');
										$('#zak_boot').show('slow');
										
									});
									
								});
								
							}
					}
				}
			});
			
		
	
		
		
    	return false;
	});
	
	$('.news_mail').click(function(){
		$('.rass_add').toggle('slow');
    	return false;
	});
	
	
	$('#reg_new').click(function(){
		if($('#log_in').attr("value") && $('#pass_in').attr("value") && $('#repass_in').attr("value") && $('#email_in').attr("value") && $('#tel_in').attr("value") && $('#addr_in').attr("value")) document.getElementById('reg_new_form').submit();
		else alert('Не все обязательные поля заполнены!');
		//document.getElementById('reg_new_form').submit();
    	return false;
	});
	
	$('#add_child').click(function(){
		$('#cont_add_child').append($('#pattern_child').html());
    	return false;
	});
	
	
	
	$('.gol_f').click(function(){
		document.getElementById('gol_f').submit();
    	return false;
	});
	
	
	$('#in_login').click(function(){
		
		$('.login').toggle('slow');
    	return false;
	});
	$('.close').click(function(){
		
		$('.login').hide('slow');
    	return false;
	});
	$('#in_l').click(function(){
		jQuery.post('ajax.php', {
	        	"in_login":  $('#name_log').attr("value"),
	        	"in_pass":  $('#pass_log').attr("value")
			},function(data){
				if(data){
					if(data==1){
						$('#log_red').css('color','red');
						$('#pas_red').css('color','red');
					} else {
						$('.reg').html('Логин: '+data);
						$('.login').hide('slow');
					}
				}
			});
    	return false;
	});
	
	
	$('.ch_main_img').click(function(){
		var lann=$(this).attr("name");
		$('#main_img').fadeOut('slow',function(){
			
			$('#main_img').attr({'src':lann});
			$('#main_img').fadeIn('slow');
			//alert($('#main_img').attr('src'));
		});
		
		return false;
	});
	
	
	$('.basket_in').click(function(){
		var mim=$(this).attr("name");
		//alert(mim);
$('#dop_kol'+mim).show('slow');
//alert('sdsdf');
/*
		//alert( $(this).attr("name"));
		
			jQuery.post('ajax.php', {
	        	"add_basket":  $(this).attr("name")
			},function(data){
				if(data){
					if($('.basket_show').css('display')!='none'){
						$('.basket_show').slideUp(300,function(){
							$("#in_basket").html(data);
							jQuery.post('ajax.php', {
					        	"getAmount": 1
							},function(dt){
								$("#amount").html(dt+'грн');	
								jQuery.post('ajax.php', {"getKol": 1},function(d){
									$("#col_kor").html(d);	
									$('#zak_boot').show('slow');
									$('.basket_show').slideDown('slow');
								});
							});
							
						});
					} else {
						if(data){
								$("#in_basket").html(data);
								jQuery.post('ajax.php', {
						        	"getAmount": 1
								},function(dt){
									$("#amount").html(dt+'грн');
									jQuery.post('ajax.php', {"getKol": 1},function(d){
										$("#col_kor").html(d);	
										$('.basket_show').slideDown('slow');
										$('#zak_boot').show('slow');
									});
									
								});
								
							}
					}
				}
			});
			
		
	
	*/		
		
    	return false;
	});
	
	

	
	
    $('#log_in').click(function(){
    	jQuery.post('ajax.php', {
        	"llgogin": $('#llgogin').attr("value"),
			"lpass": $('#lpass').attr("value")
		},function(data){
			if(data==1){
				//$("#log_in a").text("Выйти");
				$("#in_log").fadeOut('slow',
					function(){
						$("#in_log").html('<label>Логин: <b>'+$('#llgogin').attr("value")+'</b></label>');
						$("#in_log").fadeIn('slow');
						$("#in_pass").slideUp('slow');
						//$("#log_in, #in_reg").hide();
						$("#log_in, #in_reg").hide();
						$("#log_out").show();
						
					});
			} else {
				$("#l_err").fadeIn('slow');
			}
		});
		return false;
    });
    $('#log_out').click(function(){
    	jQuery.post('ajax.php', {
        	"exlogin": 1
		},function(){
			//$("#log_in a").text("Выйти");
			$("#in_log").fadeIn('slow',
				function(){
					$("#in_log").html('<label>Логин</label><input type="text" class="input_iw_obl" id="llgogin" />');
					$("#in_log").fadeIn('slow');
					$("#in_pass").slideDown('slow');
					$("#log_in, #in_reg").show();
					$("#log_out").hide();
					
				});
			
		});
		return false;
    });
    
    function isValidEmailAddress(emailAddress) {
   	 	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    	return pattern.test(emailAddress);
    }

    
    $('#podis').click(function(){
    	if (isValidEmailAddress($('#pe').attr("value"))){
	    	jQuery.post('ajax.php', {
	        	"pl": $('#pl').attr("value"),
				"pe": $('#pe').attr("value"),
				"codd": $('#codd').attr("value")
			},function(data){
				switch (data) {
					case '1':
					    $("#inp, #inp2").fadeOut('slow',
						function(){
							$("#usp").html('Подписка прошла успешно!');
							$("#res1").fadeIn('slow');
						});
					    break;
					case '2':
					    $("#usp").html('Код не совпадает!');
						$("#res1").fadeIn('slow');
					    break;
					case '3':
					    $("#usp").html('Такой E-mail уже подписан!');
						$("#res1").fadeIn('slow');
					    break;
				    case '4':
					    $("#usp").html('Все поля обязательны для заполнения!');
						$("#res1").fadeIn('slow');
					    break;
				}
			});
    	} else {
    		alert('Некорректно заполнено поле  E-mail')
    	}
		return false;
    });

});
function upBigImg(id){
	jQuery.post('ajax.php', {
        	"upImgGal": id
		});
}

hs.registerOverlay(
    	{
    		thumbnailId: null,
    		overlayId: 'controlbar',
    		position: 'top right',
    		hideOnMouseOut: true
		}
	);
	
    hs.graphicsDir = 'js/highslide/graphics/';
    hs.captionEval = 'this.thumb.alt';
    //hs.captionEval = 'this.thumb.title';
