$(document).ready(function() {
	
// news
	var sfondo1 = $("#news a:first-child").attr('title');
	$('#news a:first').addClass('on');
	$('#main_content').css('background-image', 'url('+sfondo1+')');
	$("#news a").click(function() {
			var sfondo = $(this).attr('title');
			$('#main_content').css('background-image', 'url('+sfondo+')');
			$('#news a:first-child').removeClass('on');
			$(this).addClass('on');
	   });
	
	
	//where
	var sfondo2 = $("#where_side a:first-child").attr('title');
	$('#where_side a:first').addClass('on');
	$('a.gmaps').attr('href', "http://maps.google.it/maps?q=Via+Antonio+Gramsci,+40,+48015+Cervia+Ravenna,+Emilia+Romagna&hl=it&ll=44.275473,12.349298&spn=0.010509,0.024269&sll=41.442726,12.392578&sspn=22.498138,49.702148&geocode=FcKXowIdeG-8AA&z=16");
	$('#about_pic img').attr('src', sfondo2);
	$('#where_address').html('<strong>ICEBLINK</strong><br />Viale Antonio Gramsci, 40<br />48020 Milano Marittima - RA<br />ph. +39_3355607488');
	$("#where_side a").click(function() {
			var sfondo3 = $(this).attr('title');
			var testo3 = $(this).attr('rel');
			var mappa3 = $(this).attr('name');
			$('#where_side a:first-child').removeClass('on');
			$(this).addClass('on');
			$('a.gmaps').attr('href',mappa3);
			$('#about_pic img').attr('src', sfondo3);
			$('#where_address').html(testo3);
	});
	
	
	//about
//	$(".scrollable").scrollable({ vertical: true, mousewheel: true });	
	$("a[title*='PRODUCTS']").click(function() {
		if ($('.submenu').is(":hidden")) {
		$(".submenu").slideDown("slow");
		} else {
		$(".submenu").slideUp('slow');
		}
	});
	

	// products sidebar
	$('#category_side a').hover(function () {
	var sfondo4 = $(this).attr('rel');
	if ($(this).hasClass('nonselected')) {
		$('img', this).attr('src',sfondo4);
	}
	},
	function () {
	var sfondo4 = $(this).attr('id');
	$('img', this).attr('src',sfondo4);
	});
	
	
	// single post back
	var backlink = $('#category_side a.selected').attr('href');
	$('.back a').attr('href', backlink);
	
	// mask erroneous next links
/*	var link = $('div.next a').html();	
	if (link === ' ' ) {
		$('div.next a').remove();
	}
	
	// mask erroneous prev links
	var link = $('div.previous a').html();	
	if (link === ' ' ) {
	$('div.previous a').remove();
	} */
 });

jQuery(function ($) {
	// more information
	$('#moreinfo').click(function (e) {
		$('#forminfo').modal();
		return false;
	});
});

$(function() {
  $('.error').hide();
  $(".button").click(function() {
    // validate and process form here

    $('.error').hide();
	  var name = $("input#name").val();
		if (name == "") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		var message = $("textarea").val();
	/*	if (message == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
      return false;
    }*/
	var nomep = $("#nomeprodotto").text();
	var colorep = $("#coloreprodotto").text();
	var colorel = $("#colorelente").text();
	var prezzop = $("#prezzoprodotto").text();
	var marca = $("#marca").text();

var dataString = 'name='+ name + '&email=' + email + '&message=' + message + "&modello="+ nomep + "&colore=" + colorep + "&colorelente=" + colorel + "&prezzo=" + prezzop + "&marca=" + marca;
//alert (dataString);return false;
$.ajax({
  type: "POST",
  url: "http://www.iceblink.it/bin/process.php",
  data: dataString,
  success: function() {
    $('#contact_form').html("<div id='message'></div>");
    $('#message').html("<h2>Request Submitted!</h2>")
    .append("<p>We will be in touch soon.</p>")
    .hide()
    .fadeIn(1500, function() {
      $('#message').append("<img id='checkmark' src='http://www.iceblink.it/bin/check.png' />");
    });
  }
});
return false;

  });
});


