function validate_add2basket_form()
{
	if(document.getElementById('size').selectedIndex==0)
	{
		$("#size_color_error").fadeIn("fast");
		$("#size").fadeOut("fast").fadeIn("fast");
		return false;
	}
	
	if(document.getElementById('color').selectedIndex==0)
	{
		$("#size_color_error").fadeIn("fast");
		$("#color").fadeOut("fast").fadeIn("fast");
		return false;
	}
	
	return true;
}

function show_invoice_data(checked)
{
	if(checked)
		$("#invoiceData").fadeIn("fast");
	else
		$("#invoiceData").fadeOut("fast");
}

function addDiscount()
{
	if(document.getElementById('discount').value!='')
	{
		document.getElementById('discount_code').value=document.getElementById('discount').value;
		document.getElementById('discount_form').submit();
	}
}

function contact_send()
{
	if(document.getElementById('contact_title').value=='' ||
		document.getElementById('contact_email').value=='' ||
		document.getElementById('contact_message').value=='')
	{
		alert("Wypełnij formularz kontaktowy");
		return false;
	}
	
	$.ajax({
	   type: "POST",
	   url: "/ajax/contact/send/",
	   data: "title="+escape(document.getElementById('contact_title').value)+"&email="+escape(document.getElementById('contact_email').value)+"&message="+escape(document.getElementById('contact_message').value),
	   beforeSend: function(req){
	     $('#contact').text("Wysyłam wiadomość...");
	   },
	   success: function(msg){
	     if(msg)
	     	$('#contact').text("Wiadomość została wysłana.");
	     else
	     	$('#contact').text("Wystąpił błąd podczas wysyłania.");
	   },
	   error: function(msg){
	     $('#contact').text("Wystąpił błąd podczas wysyłania.");
	   }
	 });
}

//do powiekszania i zmieniania zdjec:
var lastImage='';

function zoomImageFun(id,src,filename)
{
	document.getElementById(id).src=src;
	lastImage=filename;
}

function openWin(windowURL,windowName,windowFeatures) { 

	if (windowName == "") windowName = "newWin";
	return window.open( windowURL, windowName, windowFeatures);
} 