﻿// JavaScript Document

$(document).ready(function() { 
 $("#inertube7").css({visibility:"hidden",position:"absolute", textAlign:"justify",  padding:"4px", width:"57%", height:"390px", margin:"0px 0px 0px 41%"});
 
$("#tab1").click(function () {$("#suplement").hide(1000);$("#subtext").show(1000); $("#tab1a").show().text("Hide");$("#tab1").hide();});

$("#tab2contact").click(function () {$("#inertube1").hide();$ ("#inertube2").hide();$("#inertube4").hide();$("#inertube5").hide();
$("#inertube6").show(); $("#inertube7").css({visibility:"visible"});});

$("#tab3abtus").click(function () {$("#inertube1").hide();$ ("#inertube2").hide();$("#inertube5").hide();$("#inertube6").hide();$("#inertube7").css({visibility:"hidden"});
$("#inertube4").show();}); 

$("#tab5").click(function () {$("#inertube1").hide();$ ("#inertube2").hide();$("#inertube4").hide();$("#inertube5").hide();
$("#inertube6").show(); $("#inertube7").css({visibility:"visible"});});

 $("#tab4abservice").click(function () {$("#inertube1").hide();$ ("#inertube2").hide();$("#inertube4").hide();$("#inertube6").hide();$("#inertube7").css({visibility:"hidden"});      $("#inertube5").show();}); 
//Folio funks
//1
$("#DE1G").hover(function () { $("#link").show().appendTo (this),
$(this).css({ backgroundColor:"blue"}),
$("#linkInfo1").css({visibility:"visible"}),
$("#foliodetail1").show().appendTo (".infotube")},
function () { $(this).find("#link:last").fadeOut(100),$(".infotube").find("#foliodetail1:last").fadeOut(100),
$("#linkInfo1").css({visibility:"hidden"}),
$(this).css({ backgroundColor:"black"});
  });
//2
$("#DE2G").hover(function () { $("#link2").show().appendTo (this),
$(this).css({ backgroundColor:"blue"}),
$("#linkInfo1").css({visibility:"visible"}),
$("#foliodetail2").show().appendTo (".infotube")},
function () { $(this).find("#link2:last").fadeOut(100),$(".infotube").find("#foliodetail2:last").fadeOut(100),
$("#linkInfo1").css({visibility:"hidden"}),
$(this).css({ backgroundColor:"black"});
  });
//3
$("#DE3G").hover(function () { $("#link3").show().appendTo (this),
$(this).css({ backgroundColor:"blue"}),
$("#linkInfo1").css({visibility:"visible"}),
$("#foliodetail3").show().appendTo (".infotube")},
function () { $(this).find("#link3:last").fadeOut(100),$(".infotube").find("#foliodetail3:last").fadeOut(100),
$("#linkInfo1").css({visibility:"hidden"}),
$(this).css({ backgroundColor:"black"});
  });
//4
$("#DE4G").hover(function () { $("#link4").show().appendTo (this),
$(this).css({ backgroundColor:"blue"}),
$("#linkInfo1").css({visibility:"visible"}),
$("#foliodetail4").show().appendTo (".infotube")},
function () { $(this).find("#link4:last").fadeOut(100),$(".infotube").find("#foliodetail4:last").fadeOut(100),
$("#linkInfo1").css({visibility:"hidden"}),
$(this).css({ backgroundColor:"black"});
  });
//5
$("#DE5G").hover(function () { $("#link5").show().appendTo (this),
$(this).css({ backgroundColor:"blue"}),
$("#linkInfo1").css({visibility:"visible"}),
$("#foliodetail5").show().appendTo (".infotube")},
function () { $(this).find("#link5:last").fadeOut(100),$(".infotube").find("#foliodetail5:last").fadeOut(100),
$("#linkInfo1").css({visibility:"hidden"}),
$(this).css({ backgroundColor:"black"});
  });
//6
$("#DE6G").hover(function () { $("#link6").show().appendTo (this),
$(this).css({ backgroundColor:"blue"}),
$("#linkInfo1").css({visibility:"visible"}),
$("#foliodetail6").show().appendTo (".infotube")},
function () { $(this).find("#link6:last").fadeOut(100),$(".infotube").find("#foliodetail6:last").fadeOut(100),
$("#linkInfo1").css({visibility:"hidden"}),
$(this).css({ backgroundColor:"black"});
  });

 });


//Slider
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 2,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
});
//Slider End



//Forms
jQuery(document).ready(function() {
 
  
  $('.error').hide();
  $('input#guestname').keyup(function(){
    $('#label_guestname').css({borderBottom:"1px dashed green"});
  });
  $('input#email').keyup(function(){
    $('#label_email').css({borderBottom:"1px dashed green"});
  });
  $('input#phone').keyup(function(){
    $('#label_phone').css({borderBottom:"1px dashed green"});
  });
  $('textarea#note').keyup(function(){
    $('#label_note').css({borderBottom:"1px dashed green"});
  });
  

  $("#pmSubmit").click(function() {
	 var device = $("input#device").val();
	  var dtam = $("input#dtam").val();
	   var ip_ad = $("input#ip_ad").val();
	    
		 
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var guestname = $("input#guestname").val();
		if (guestname == "") {
      $("#guestname_error").show().fadeOut(6000);
      $("input#guestname").focus();
	  $("#label_guestname").css({borderBottom: "1px dashed red"});
      return false;} 
    
	
	
	
		var email = $("input#email").val();
		var atpos=$("input#email").val().indexOf("@");
        var dotpos=$("input#email").val().lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length){		 
      $("#email_error").show().fadeOut(6000);
      $("input#email").focus();
	  $("#label_email").css({borderBottom: "1px dashed red"});
      return false;
    }
	
	var phone = $("input#phone").val();
		if (phone == "") {
      $("#phone_error").show().fadeOut(6000);
      $("input#phone").focus();
	  $("#label_phone").css({borderBottom: "1px dashed red"});
      return false;
    }
		var note = $("textarea#note").val();
		if (note == "") {
      $("#note_error").show().fadeOut(6000);
      $("textarea#note").focus();
	  $("#label_note").css({borderBottom: "1px dashed red"});
      return false;
    }
		//send data to process
		var dataString = 'guestname='+ guestname  +'&phone=' + phone + '&email=' + email + '&note=' + note + '&device=' + device + '&dtam=' + dtam + '&ip_ad=' + ip_ad ; 
		
		$("#pmFormProcessGif").show();
		
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/mailer.php",
      data: dataString,
      success: function(data) {
        $('.contactform').html("<div id='message'></div>");
        $('#message').html("<h2>Contact Form Submitted!</h2>")
        .append("<p>Thank you, we will be in touch soon.</p>")
		.fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='images/check.png' style='float:left'/> ").append(data);
		   
        });
      }
     });
    return false;
	});
});
