﻿var nDes = 1;
var delay = 500;

function Set_Cookie( name, value, expires, path, domain, secure )  
{ 
	var today = new Date(); 
	today.setTime( today.getTime() ); 
	if ( expires ) 
	{ 
		expires = expires * 1000 * 60 * 60 * 24; 
	} 
	var expires_date = new Date( today.getTime() + (expires) ); 
	document.cookie = name + "=" +escape( value ) + 
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +  
	( ( path ) ? ";path=" + path : "" ) +  
	( ( domain ) ? ";domain=" + domain : "" ) + 
	( ( secure ) ? ";secure" : "" ); 
}

$(document).ready(function(){

	for(var i=0;i<107;i++){	
		$("#ib"+i).click(function () {
			$(this).hide("slide", {direction: "down"}, delay, function (){
				//alert("#dest"+nDes+":hidden");
				document.getElementById("dest"+nDes).src = this.src;
				//$("div#dest"+nDes).css('visibiliti','visible');
				//alert('ad');
				$("#dest"+nDes+":hidden").show("slide", {direction: "up"}, delay, function () {
					$(this).effect("bounce", { times: 2, distance: 3}, 100 , function() {
					if(nDes == 5){
						for(var i=1;i<5;i++)
							Set_Cookie("bottle"+i, document.getElementById("res"+i).value, 1, '/');
						document.forms.resultForm.submit();
					}});
				});
				document.getElementById("res"+nDes).value = this.id.substring(2);
				nDes++;
			});
		});
	}
	
	$(".more").click(function () {
		$("div[id^='dopinfo']:visible").not("div[id='dopinfo"+this.id+"']").slideUp("slow");
		$("div[id='dopinfo"+this.id+"']").slideToggle("slow");
		$("a.more[id!="+this.id+"] > span").html('читать полностью...');
		$("a.more[id!="+this.id+"] > span").show();
		//$("a.more[id="+this.id+"] > span").html('свернуть описание');
		$("a.more[id="+this.id+"] > span").hide();
		return false;
    });

});

