function shBoxWithCheckbox(checkboxId, boxId){
	var isCheckbox = $("#"+checkboxId);
	var boxContainer = $("#"+boxId);
	
	if(isCheckbox.attr("checked")==true) boxContainer.show();
	else boxContainer.hide();
}

function showConfirmBox(text, url){
    var messageBox = "<div id='dialog'>"+text+"</div>";
    $("#end").after(messageBox);
    
	$("#dialog").dialog({ 
		modal: true,
	    overlay: { 
	        opacity: 0.5, 
	        background: "black" 
	    },		
	    resizable: false,
	    buttons: { 
	        "Anuluj": function() { 
	            $(this).dialog("close"); 
	            $(this).dialog("destroy"); 
	            $("#dialog").remove();	            
	        } ,	    	
	        "Ok": function() { 
	            self.location.href = url 
	        }
	    } 
	});  
	
}

function showInfoBox(text){
    var messageBox = "<div id='dialog'>"+text+"</div>";
    $("#end").after(messageBox);
    
	$("#dialog").dialog({ 
		modal: true,
	    overlay: { 
	        opacity: 0.5, 
	        background: "black"
	    },		
	    resizable: false,
	    buttons: { 
	        "Ok": function() { 
	            $(this).dialog("close");
	            $(this).dialog("destroy"); 
	            $("#dialog").remove();	             
	        }
	    } 
	});  	
}

function showProductPhoto(imageUrl, currentPhoto){
	$("#productPhoto").attr("src", imageUrl);
	currentImage = currentPhoto;
}

function showSystemMessage(text){
	var closeBtn = "<div class='dialogOkBtn'><input type='button' class='greyBtn' value='OK' onclick='$.modal.close();' /></div>";
		
	$.modal(text+closeBtn, {
		close : true,
		escClose : true,
		closeClass: "modalCloseImg",
		closeHTML : "<a href='#'> </a>"
	});
}

function showCartMessage(text, add){
	if(add!=1) {
		var closeBtn = "<div class='dialogOkBtn'><input type='button' class='greyBtn' value='OK' onclick='$.modal.close();' /></div>";
		text = text+closeBtn;
	}
	
	
	$.modal(text, {
		close : true,
		escClose : true,
		closeClass: "modalCloseImg",
		closeHTML : "<a href='#'> </a>"
	});
}

function copyToInvoice(){
	$("#invoiceName").val($("#companyName").val());
	$("#invoiceStreet").val($("#street").val());
	$("#invoicePremise").val($("#premise").val());
	$("#invoiceFlat").val($("#flat").val());
	$("#invoicePostCode").val($("#postCode").val());
	$("#invoiceCity").val($("#city").val());
	$("#invoiceName").val($("#companyName").val());
	$("#invoiceName").val($("#companyName").val());
}

function nextImage(){
	currentImage++;	
	if(currentImage>lastImage) currentImage = firstImage;
						
	var nextPhotoSrc = $("#photoNumber"+currentImage).attr("src");
	nextPhotoSrc = nextPhotoSrc.replace("thumb", "main");
						
	$("#productPhoto").attr("src", nextPhotoSrc);
}
					
function prevImage(){
	currentImage--;	
	if(currentImage<firstImage) currentImage = lastImage;
						
	var nextPhotoSrc = $("#photoNumber"+currentImage).attr("src");
	nextPhotoSrc = nextPhotoSrc.replace("thumb", "main");
						
	$("#productPhoto").attr("src", nextPhotoSrc);
}

function showWaitPromo(){
	$('#waitPromoForm').toggle();
}