
document.createElement('header');
document.createElement('nav');
document.createElement('article');
document.createElement('footer');

$(document).ready(function(){

if($.browser.msie && $.browser.version>8){
  Cufon.set('engine', 'canvas');
}
if($.browser.msie && $.browser.version<9){
  document.body.className = 'lt9';
}

   Cufon.replace('.title, .widget-title, .tagcloud a, #portfolio_content_in .main_link', {hover: true});

   $("#portfolio_content_in article:last").css("border", "none");

     $(".TheForm").validate({
    valid:function(){

        var data = getData(this);
        Global.maildata = data;
        var form = this;

        $.post(url + "mailsend.php", data, function(){
//'<center><h1>Your request has been sent. We will contact you shortly.</h1></center>'.popup();

var msg = "<div class='fmsg'>Thank you "+ Global.maildata.Name.capitalize() +", for your message. I'll shortly respond you.</div>";

msg.popup();
form.reset();

        });

      return false;
    },
    error:function(){
      //"Please complete every field".alert();
    },
    preventSubmit:true
});




  $(".action-submit").click(function(){


  $(this).parents("form").submit();

  return false;
  })



  $(".input input").focus(function(){
     $(this).parent().addClass("input_focus");
  });
  $(".input input").blur(function(){
     $(this).parent().removeClass("input_focus");
  });
  $(".area textarea").focus(function(){
     $(this).parent().addClass("area_focus");
  });
  $(".area textarea").blur(function(){
     $(this).parent().removeClass("area_focus");
  });

  $(".tags a").removeAttr("href");



  if(window.location.hash =='#water'){
    $.cookie("water", "true");
  }

  if(window.location.href.indexOf('/contacts/')!=-1){
    //$.cookie("water", "false");
  }

  water();


  $("#dive").click(function(){
    if(!$(this).hasClass("active")){
      $.cookie("water", "true");
      water();
    }
    else{
      $.cookie("water", "false");
      $("#water").remove();
      $("#dive").html("Dive");
      $(this).removeClass("active")
    }
       return false;
  });

});

water = function(){
  if($.cookie("water")=='true' && $("#water").length==0){
    $("#dive").html("Back to the surface.. :)").addClass("active");
    $(document.body).prepend('<iframe width="100%" scrolling="no" height="100%" src="'+url+'water" id="water" frameborder="0" allowfullscreen></iframe>');
    if($("body").height()>$(window).height()){
      $("#water").height($("body").height())
    }
  }
}


$.cookie = function(key, value, options) {

        // key and at least value given, set cookie...
        if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
            options = $.extend({}, options);

            if (value === null || value === undefined) {
                options.expires = -1;
            }

            if (typeof options.expires === 'number') {
                var days = options.expires, t = options.expires = new Date();
                t.setDate(t.getDate() + days);
            }

            value = String(value);

            return (document.cookie = [
                encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
                options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
                options.path ? '; path=' + options.path : '',
                options.domain ? '; domain=' + options.domain : '',
                options.secure ? '; secure' : ''
            ].join(''));
        }

        // key and possibly options given, get cookie...
        options = value || {};
        var decode = options.raw ? function(s) { return s; } : decodeURIComponent;

        var pairs = document.cookie.split('; ');
        for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) {
            if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined
        }
        return null;
    };




