OptionClicked = "";
defaultOption = "";

$(document).ready(function() {

   	var options = {
    	beforeSubmit: onProcessing,
	    success: onSuccess,
	    dataType: 'json'
    };

    $('#salesleadForm').ajaxForm(options);

	  var geoPlayer = "/videoproduction/flash/VideoPlayer.swf";

    var flashvars = {
        file: "production_page_the_grand_pizzeria_vi.flv",
        autoStart: "false",
        pagetype: "geo_production",
        aspectratio: "HD_16X9",
        img: "http://www.geobeats.com/videoproduction/img/vi_big_grand.jpg"
    };

    var params = {
      bgcolor: "#ffffff",
      wmode: "window",
      menu: "false",
      allowscriptaccess: "always"
    };

    var attributes = {
      id: "geoVideoPlayer",
      name: "geoVideoPlayer"
    };

    var flashvars_bv = {
        file: "production_page_calle_ocho_10bit_bv.flv",
        autoStart: "false",
        pagetype: "geo_production",
        aspectratio: "HD_16X9",
        img: "http://www.geobeats.com/videoproduction/img/bv_big_calle.jpg"
    };

    var flashvars_vv = {
        file: "production_page_holiday_inn_buena_park_vo.flv",
        autoStart: "false",
        pagetype: "geo_production",
        aspectratio: "HD_16X9",
        img: "http://www.geobeats.com/videoproduction/img/vo_big_buena.jpg"
    };

    bv_1 = {
      flvName: "production_page_calle_ocho_10bit_bv.flv",
      img: "http://www.geobeats.com/videoproduction/img/bv_big_calle.jpg",
    };

    bv_2 = {
      flvName: "production_page_just_trash_it_bv.flv",
      img: "http://www.geobeats.com/videoproduction/img/bv_big_just.jpg"
    };

    bv_3 = {
      flvName: "production_page_beehive_salon_bv.flv",
      img: "http://www.geobeats.com/videoproduction/img/bv_big_bee.jpg"
    };

    vi_1 = {
      flvName: "production_page_the_grand_pizzeria_vi.flv",
      img: "http://www.geobeats.com/videoproduction/img/vi_big_grand.jpg"
    };

    vi_2 = {
      flvName: "production_page_studio_1_on_1_vi.flv",
      img: "http://www.geobeats.com/videoproduction/img/vi_big_studio.jpg"
    };

    vi_3 = {
      flvName: "production_page_storyopolis_vi",
      img: "http://www.geobeats.com/videoproduction/img/vi_big_storyopolis.jpg"
    };

    vo_1 = {
      flvName: "production_page_holiday_inn_buena_park_vo.flv",
      img: "http://www.geobeats.com/videoproduction/img/vo_big_buena.jpg"
    };

    vo_2 = {
      flvName: "production_page_le_mani_day_spa_vo.flv",
      img: "http://www.geobeats.com/videoproduction/img/vo_big_mani.jpg"
    };

    vo_3 = {
      flvName: "production_page_video_with_vo_2.flv",
      img: "http://www.geobeats.com/videoproduction/img/vo_big_aloft.jpg"
    };

    $.swfobject.embedSWF(geoPlayer, "flash_example_player", "463", "299", "8.0.0","expressInstall.swf", flashvars, params, attributes);

    $('.Play').click(function(){
      //play modes

      $('div > #whitebox').css('background-color', 'white'); //reset currently playing
      $(this).parents('#whitebox').css('background-color', '#CE932C'); //set currently playing border color

      playerObject = $.swfobject.getObjectById("geoVideoPlayer"); //get Video player object

      videoNumber = $(this).attr('id'); // <a id> Id from link and play that associated video

      switch (videoNumber) {
        case '1':
          playerObject.play_video(bv_1);
        break;

        case '2':
          playerObject.play_video(bv_2);
        break;

        case '3':
          playerObject.play_video(bv_3);
        break;

        case '4':
          playerObject.play_video(vi_1);
        break;

        case '5':
          playerObject.play_video(vi_2);
        break;

        case '6':
          playerObject.play_video(vi_3);
        break;

        case '7':
          playerObject.play_video(vo_1);
        break;

        case '8':
          playerObject.play_video(vo_2);
        break;

        case '9':
          playerObject.play_video(vo_3);
        break;
      }

    });

  //Top Navigation; mouse over

  $('#videoProducts img').hover(function() {
	  $(this).attr("src","img/video_products_pricing_over.png");
		  }, function() {
	  $(this).attr("src","img/video_products_pricing_normal.png");
  });

  $('#precess img').hover(function() {
	  $(this).attr("src","img/production_process_over.png");
		  }, function() {
	  $(this).attr("src","img/production_process_normal.png");
  });

  $('#whyGeobeats img').hover(function() {
	  $(this).attr("src","img/why_geobeats_over.png");
		  }, function() {
	  $(this).attr("src","img/why_geobeats_normal.png");
  });

  $('#faqpage img').hover(function() {
	  $(this).attr("src","img/faq_over.png");
		  }, function() {
	  $(this).attr("src","img/faq_normal.png");
  });


  //Product Pricing; mouse over
  $(".rollOver").hover(
    function () {
      $("#rollOvers div").removeClass("roll-over-default");
      $(this).addClass("roll-over-default");
    },
    function () {
      $("#rollOvers div").removeClass("roll-over-default");
      //When clicked
      if (OptionClicked == ""){
         if(defaultOption == ""){
           //No last selected video #video_interview
           $("#rollOvers #video_interview").addClass("roll-over-default");
          }else{
           //set the last selected video
           $("#" + defaultOption).addClass("roll-over-default");
          }
      }else{
         defaultOption = OptionClicked;
         $("#" + defaultOption).addClass("roll-over-default");
      }
      OptionClicked = ""
    }
  );

  //Product Click; Package details

	 $('#rollOvers #basic_video').click(function(){
     OptionClicked = "basic_video";
     $('#rollOvers #basic_video').addClass("roll-over-default");

		 $('#respectiveText div').hide();
		 $("#respectiveText  #basic_video").show();

		 $('.flash_player_title div').hide();
		 $('.flash_player_title #ex_base_video').show();

		 $("#videoNav .nav").hide();
		 $("#videoNav #bv_nav").show();

     $('#geoVideoPlayer').remove();
     $('#flashExampleContainer').append('<div id="flash_example_player"></div>');
     $.swfobject.embedSWF(geoPlayer, "flash_example_player", "463", "299", "8.0.0","expressInstall.swf", flashvars_bv, params, attributes);

	 });

	 $('#rollOvers #video_interview').click(function(){
     OptionClicked = "video_interview";
     $("#rollOvers #video_interview").addClass("roll-over-default");

		 $('#respectiveText div').hide();
     $("#respectiveText  #video_interview").show();

		 $('.flash_player_title div').hide();
		 $('.flash_player_title #ex_interview_video').show();

		 $("#videoNav .nav").hide();
		 $("#videoNav #vi_nav").show();

     $('#geoVideoPlayer').remove();
     $('#flashExampleContainer').append('<div id="flash_example_player"></div>');
     $.swfobject.embedSWF(geoPlayer, "flash_example_player", "463", "299", "8.0.0","expressInstall.swf", flashvars, params, attributes);

	 });

	 $('#rollOvers #video_voiceover').click(function(){
     OptionClicked = "video_voiceover";
     $("#rollOvers #video_voiceover").addClass("roll-over-default");

		 $("#respectiveText div").hide();
		 $("#respectiveText  #video_voiceover").show();

		 $(".flash_player_title div").hide();
		 $(".flash_player_title #ex_voiceover_video").show();

		 $("#videoNav .nav").hide();
		 $("#videoNav #vo_nav").show();

     $('#geoVideoPlayer').remove();
     $('#flashExampleContainer').append('<div id="flash_example_player"></div>');
     $.swfobject.embedSWF(geoPlayer, "flash_example_player", "463", "299", "8.0.0","expressInstall.swf", flashvars_vv, params, attributes);

	 });

});

	 //Contact submit

  function onProcessing(XMLHttpRequest){

    if (ValidateSalesContactUs() == true){
        $("#contactForm  #loading").show("fast");
    }else{
      return false
    }
  }

  function onComplete(XMLHttpRequest, textStatus){
    $("#contactForm #loading").hide("fast");
  }

  function onSuccess(data, textStatus){
    $('#contactForm').html("<div style='height:120px;padding:180px 22px;'>Thank you for submitting your contact information. <br /><br />We will contact within 1 business day to get you started on your online video.</div>");
  }

  function ValidateSalesContactUs(){

   var business_name = document.saleslead.saleslead_business_name
   var contact_name = document.saleslead.saleslead_contact_name
   var email = document.saleslead.saleslead_email
   var phone	=	document.saleslead.saleslead_phone

   if(business_name.value == '' || business_name.value == null) {
	  alert("Please enter your business name");
	  return false
   }

   if(contact_name.value == '' || contact_name.value == null) {
      alert("Please enter your contact person");
	  return false
   }

   if(email.value == '' || email.value == null) {
      alert("Please enter your email address");
	  return false
   }

   if(email.value != '') {
      var msg = "Please enter your valid  Email address";
      if (echeck(email.value,msg)==false){
        email.value=""
        email.focus()
        return false
    }
   }

	if((phone.value==null)||(phone.value=="")){
		alert("Please enter your phone")
		phone.focus()
		return false
	}

	return true

 }
