
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-10186286-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

var main = {
  "active":{
    "number":false
  },
  "hook":{},
  "timer":{}
};


$(document).ready(function(){

  $("li.submenu-item").css({
    "height":"0"
  });

  $("a.link-new-page").click(function(event){
    $(this).attr("target","_blank");
    return true;
  });
  
  $("a.submenu-hook, a.submenu-item, .menu-link, a").click(function(event){
    
    //return $(this).attr("href") ? linkTransition( $(this).attr("href") ) : true;
    });

  $("a.menu-link").mouseover(function(event){
    main.active = $(this).parent().parent().attr("class");
    $(this).parent().parent().attr("class", main.active == "menu-btn-hook-active" ? main.active : "menu-btn-hook-over");
  }).mouseout(function(event){
    $(this).parent().parent().attr("class", main.active);
  });

  $("a.button-link").mouseover(function(event){
    main.active = $(this).parent().parent().attr("class");
    $(this).parent().parent().attr("class", main.active == "page-btn-hook-active" ? main.active : "page-btn-hook-over");
  }).mouseout(function(event){
    $(this).parent().parent().attr("class", main.active);
  });



  $("a.showthem").mouseover(function(event){
    $("#showman").attr("class", "dissOn");
  }).mouseout(function(event){
    $("#showman").attr("class", "dissOff");
  });

  $("li.submenu-hook").mouseover(function(event){
    $("li#" + $(this).attr("id") + " li.submenu-item").css({
      "height":"auto"
    });
    $("li#" + $(this).attr("id") + " li.submenu-item").parent().css({
      "padding":"0 0 6px 0"
    });
  //$("li#" + $(this).attr("id") + " li.submenu-item").animate( { opacity:0.8 }, 600);
  }).mouseout(function(event){
    $("li#" + $(this).attr("id") + " li.submenu-item").css({
      "height":"0"
    });
    $("li#" + $(this).attr("id") + " li.submenu-item").parent().css({
      "padding":"0"
    });
  });

  $("#callback-toggle").mouseover(function(event){
    $("#callback-steps").css({
      "display":"block"
    });
    $(this).html("click to close");
  }).click(function(event){
    $("#callback-steps").css({
      "display":"none"
    });
    $(this).html("open");
  });

  $("#quickimail-toggle").mouseover(function(event){
    $("#quickimail-steps").css({
      "display":"block"
    });
    $(this).html("click to close");
  }).click(function(event){
    $("#quickimail-steps").css({
      "display":"none"
    });
    $(this).html("open")
  });


  $(".bgOver").mouseover(function(event){
    main.active = $(this).attr("src");
    $(this).attr("src", "http://www.strip.ie/images/pix.gif");
  }).mouseout(function(event){
    $(this).attr("src", main.active);
  });


  $(".faq-icon-answer").each(function (i) {
    $(this).html("<img width=\"24px\" alt=\"Answer\" class=\"middle\" src=\"http://www.strip.ie/images/pink-icons/info_32x32.png\">");
  });

  $("#search-content-input").attr({
    "autocomplete":"off"
  });

  $("#autohint-toggle").click(function(){
    $("#search-content-hint").css({
      "display":"none"
    });
  });
  $("#search-content-input").keyup(function() {
    
    if( $("#search-content-input").val() ){
      $.post("/-/autohint/ajax", {
        time: "2pm",
        input: $("#search-content-input").val()
      },
      function(data){
        if(data.length>0)
        {
          $("#search-content-hint").css({
            "display":"block"
          });
          $("#search-content-hint-container").html("<hr>"+autohint(data));
        }
        
      });
    
    }
  });

  $(".mobile-keys").mouseover(function(){
    main.active.mkLastPos = $(this).css("background-position");
    var pos = main.active.mkLastPos.split(" ");
    var posY = pos[1].replace("px","");
    var posX = Math.round(pos[0].replace("px",""))+(-137);

    $(this).css({
      "background-position":posX+"px "+posY+"px"
    });
  
  }).mouseout(function(){
    main.active.mkLastPos ? $(this).css({
      "background-position":main.active.mkLastPos
    }) : null;
  });

  $("#mk-send").click(function(){

    main.active.number = main.active.number == false ? "" : main.active.number;
    main.active.number && main.active.number.length == 10 || main.active.number.length == 9 ?
    sendAjaxNumber():null;
  });

  $("#mk-mailback-send").click(function(){
    $("#mailback-input").val().length > 3 ?
    sendAjaxMail():null;
  });

  $(".mobile-keys").click(function(){
    $("#mk-number-hook").removeClass("mk-number-hook-inactive").addClass("mk-number-hook");

    switch( $(this).attr("name").replace("mk-","") )
    {

      case "help":
        $("#mk-hint-hook").toggle("slow");
        break;
      case "del":
        $("#mk-number-hook").html( tappedDel( ) );
        break;
      case "1":
        $("#mk-number-hook").html( tappedNumber( "1" ) );
        break;
      case "2":
        $("#mk-number-hook").html( tappedNumber( "2" ) );
        break;
      case "3":
        $("#mk-number-hook").html( tappedNumber( "3" ) );
        break;
      case "4":
        $("#mk-number-hook").html( tappedNumber( "4" ) );
        break;
      case "5":
        $("#mk-number-hook").html( tappedNumber( "5" ) );
        break;
      case "6":
        $("#mk-number-hook").html( tappedNumber( "6" ) );
        break;
      case "7":
        $("#mk-number-hook").html( tappedNumber( "7" ) );
        break;
      case "8":
        $("#mk-number-hook").html( tappedNumber( "8" ) );
        break;
      case "9":
        $("#mk-number-hook").html( tappedNumber( "9" ) );
        break;
      case "0":
        $("#mk-number-hook").html( tappedNumber( "0" ) );
        break;
    }
  });


  $(".img_hunk_thumb").mouseover(function(event){
    main.hook.hunkthumb = $(this).attr("src");
    $(this).attr("src", "http://www.strip.ie/images/hse_hunk_expand_icon-pink.png");
  }).mouseout(function(event){
    $(this).attr("src", main.hook.hunkthumb);
  });

  $(".inter-active-png").mouseover(function(event){
    main.hook.hunkthumb = $(this).attr("src");
    $(this).attr("src", main.hook.hunkthumb.replace("-inactive",""));
  }).mouseout(function(event){
    $(this).attr("src", main.hook.hunkthumb);
  });


  $(".hunk-thumb").click(function(event){
    $("#hunk-main-pic").attr("src", "http://www.strip.ie/hunks_img/"+$(this).attr("alt")+".jpg" );
  });
  $(".dj-thumb").click(function(event){
    $("#dj-main-pic").attr("src", "images/"+$(this).attr("alt")+".jpg" );
  });

  main.hook.anotherGallery = false;
  main.hook.anotherGalleryHtml = $("#ng").html();
  main.hook.anotherGalleryBtnHtml = $(this).html();
  $(".btn-another-gallery").click(function(event){
    main.hook.anotherGallery = main.hook.anotherGallery == false ? true : false;
    var gallery_number = this.title.split("#")[1];
    
    if( gallery_number )
    {
      var gal = "gallery_"+gallery_number+".xml";
      var flid = "%3Cobject+classid%3D%22clsid%3Ad27cdb6e-ae6d-11cf-96b8-444553540000%22+width%3D%22550%22+height%3D%22400%22+id%3D%22viewer%22+align%3D%22middle%22%3E+%09%09%09%09%3Cparam+class%3D%22ng-src%22+name%3D%22movie%22+value%3D%22..%2Fswf%2Fviewer.swf%3FxmlURL%3Dimages%2Fgallery%2Fmodelling%2F"+gal+"%22+%2F%3E+%09%09%09%09%3Cparam+name%3D%22quality%22+value%3D%22high%22+%2F%3E+%09%09%09%09%3Cparam+name%3D%22bgcolor%22+value%3D%22%23242629%22+%2F%3E+%09%09%09%09%3Cparam+name%3D%22play%22+value%3D%22true%22+%2F%3E+%09%09%09%09%3Cparam+name%3D%22loop%22+value%3D%22true%22+%2F%3E+%09%09%09%09%3Cparam+name%3D%22wmode%22+value%3D%22window%22+%2F%3E+%09%09%09%09%3Cparam+name%3D%22scale%22+value%3D%22showall%22+%2F%3E+%09%09%09%09%3Cparam+name%3D%22menu%22+value%3D%22true%22+%2F%3E+%09%09%09%09%3Cparam+name%3D%22devicefont%22+value%3D%22false%22+%2F%3E+%09%09%09%09%3Cparam+name%3D%22salign%22+value%3D%22%22+%2F%3E+%09%09%09%09%3Cparam+name%3D%22allowScriptAccess%22+value%3D%22sameDomain%22+%2F%3E+%09%09%09%09%3C!--%5Bif+!IE%5D%3E--%3E+%09%09%09%09%3Cobject+class%3D%22ng-src-data%22+type%3D%22application%2Fx-shockwave-flash%22+data%3D%22..%2Fswf%2Fviewer.swf%3FxmlURL%3Dimages%2Fgallery%2Fmodelling%2F"+gal+"%22+width%3D%22550%22+height%3D%22400%22%3E+%09%09%09%09%09%3Cparam+class%3D%22ng-src%22+name%3D%22movie%22+value%3D%22..%2Fswf%2Fviewer.swf%3FxmlURL%3Dimages%2Fgallery%2Fmodelling%2F"+gal+"%22+%2F%3E+%09%09%09%09%09%3Cparam+name%3D%22quality%22+value%3D%22high%22+%2F%3E+%09%09%09%09%09%3Cparam+name%3D%22bgcolor%22+value%3D%22%23242629%22+%2F%3E+%09%09%09%09%09%3Cparam+name%3D%22play%22+value%3D%22true%22+%2F%3E+%09%09%09%09%09%3Cparam+name%3D%22loop%22+value%3D%22true%22+%2F%3E+%09%09%09%09%09%3Cparam+name%3D%22wmode%22+value%3D%22window%22+%2F%3E+%09%09%09%09%09%3Cparam+name%3D%22scale%22+value%3D%22showall%22+%2F%3E+%09%09%09%09%09%3Cparam+name%3D%22menu%22+value%3D%22true%22+%2F%3E+%09%09%09%09%09%3Cparam+name%3D%22devicefont%22+value%3D%22false%22+%2F%3E+%09%09%09%09%09%3Cparam+name%3D%22salign%22+value%3D%22%22+%2F%3E+%09%09%09%09%09%3Cparam+name%3D%22allowScriptAccess%22+value%3D%22sameDomain%22+%2F%3E+%09%09%09%09%3C!--%3C!%5Bendif%5D--%3E+%09%09%09%09%09%3Ca+href%3D%22http%3A%2F%2Fwww.adobe.com%2Fgo%2Fgetflash%22%3E+%09%09%09%09%09%09%3Cimg+src%3D%22http%3A%2F%2Fwww.adobe.com%2Fimages%2Fshared%2Fdownload_buttons%2Fget_flash_player.gif%22+alt%3D%22Get+Adobe+Flash+player%22+%2F%3E+%09%09%09%09%09%3C%2Fa%3E+%09%09%09%09%3C!--%5Bif+!IE%5D%3E--%3E+%09%09%09%09%3C%2Fobject%3E+%09%09%09%09%3C!--%3C!%5Bendif%5D--%3E+%09%09%09%3C%2Fobject%3E";

      $("#ng").html( urldecode(flid) );

    }

  });

var hunks_steps_max = 3;
var hunk_step = 0;
var hunk_styles_left = ["0px","-76px","-152px"];

$("#hunk_prev").click(function(event){

  if( hunk_step <= 0 )
    {
      hunk_step = 0;
    }
    else{
      hunk_step = hunk_step-1;
    }
  $(".hunks-hook").css({left:hunk_styles_left[hunk_step]});
});
$("#hunk_next").click(function(event){

    if( hunk_step >= hunk_styles_left.length-1 )
    {
      hunk_step = hunk_styles_left.length-1;
    }
    else{
      hunk_step = hunk_step+1;
    }
  $(".hunks-hook").css({left:hunk_styles_left[hunk_step]});
});






  animateNews();
  main.hook.starsTimer = setInterval(shineStars, 250);


});

function sendAjaxMail()
{

  $.post("/-/mailback/ajax", {
    time: "2pm",
    input: $("#mailback-input").val()
  },
  function(data){
    if(data=="true"){
      $("#callback-hook").html("");
      $("#quickimail-hook").html("<hr>Thank you for your enquiry. We'll contact you soon.Have a nice day.");
    }else{
      alert(data);
    }
  });
}
function sendAjaxNumber()
{
  main.hook.ajaxParam = $("#mk-prefered-hours").val();
  if( main.active.number ){
    main.active.number == main.active.number ? $("#callback-hook").html("<hr>Thank you for your enquiry. We'll contact you soon.Have a nice day."): alert("We sorry, but we couldn't see your number\n\nplease refresh website manually and try again");
    $.post("/-/callback/ajax", {
      param: main.hook.ajaxParam,
      input: main.active.number
    },
    function(data){
      if(main.active.number == main.active.number)
      {
        if(data.indexOf("true")!=-1){
          $("#callback-hook").html("<hr>Thank you for your enquiry. We'll contact you soon.Have a nice day.")
          $("#quickimail-hook").html("");
        }
        else{
          alert(data);
        }
      }
      else{
        alert("We sorry, but we couldn't see your number\n\nplease refresh website manually and try again");
      }
    });
  }

}

function allowSend( access )
{
  access == true ? $("#mk-send").addClass( "mobile-send" ).removeClass( "mobile-send-inactive" ) : $("#mk-send").addClass( "mobile-send-inactive" ).removeClass( "mobile-send" );
}

function tappedDel( )
{
  main.active.number = main.active.number ? (main.active.number.length >= 1 ? main.active.number.slice(0, -1)  : main.active.number) : digit;
  main.active.number.length == 10 || main.active.number.length == 9 ? allowSend(true) : allowSend(false);
  return main.active.number;
}
function tappedNumber( digit )
{
  hintToggleAllwaysClosed();
  main.active.number = main.active.number === false ? "" : main.active.number;
  main.active.number = main.active.number ? (main.active.number.length <= 9 ? main.active.number + digit : main.active.number) : digit;
  main.active.number.length == 10 || main.active.number.length == 9 ? allowSend(true) : allowSend(false);
  return main.active.number;
}
function hintToggleAllwaysClosed()
{
  $("#mk-hint-hook").css("display")!="none" ? $("#mk-hint-hook").toggle("slow") : null;
}
function hintToggleAllwaysOpen()
{
  $("#mk-hint-hook").css("display")=="none" ? $("#mk-hint-hook").toggle("slow") : null;
}

function autohint(data)
{

  return data;
}
function linkJump( loc )
{

  window.location = loc;
  return false;
}
function linkTransition( loc )
{

  var swf = "%3Cobject%20classid%3D%22clsid%3Ad27cdb6e-ae6d-11cf-96b8-444553540000%22%20codebase%3D%22http%3A%2F%2Fdownload.macromedia.com%2Fpub%2Fshockwave%2Fcabs%2Fflash%2Fswflash.cab%23version%3D10%2C0%2C0%2C0%22%20width%3D%22550%22%20height%3D%22320%22%20id%3D%22hse-click-transition%22%20align%3D%22middle%22%3E%3Cparam%20name%3D%22allowScriptAccess%22%20value%3D%22sameDomain%22%20%2F%3E%3Cparam%20name%3D%22allowFullScreen%22%20value%3D%22false%22%20%2F%3E%3Cparam%20name%3D%22movie%22%20value%3D%22swf%2Fhse-click-transition.swf%22%20%2F%3E%3Cparam%20name%3D%22quality%22%20value%3D%22high%22%20%2F%3E%3Cparam%20name%3D%22wmode%22%20value%3D%22transparent%22%20%2F%3E%3Cparam%20name%3D%22bgcolor%22%20value%3D%22%23ffffff%22%20%2F%3E%3Cembed%20src%3D%22swf%2Fhse-click-transition.swf%22%20quality%3D%22high%22%20wmode%3D%22transparent%22%20bgcolor%3D%22%23ffffff%22%20width%3D%22550%22%20height%3D%22320%22%20name%3D%22hse-click-transition%22%20align%3D%22middle%22%20allowScriptAccess%3D%22sameDomain%22%20allowFullScreen%3D%22false%22%20type%3D%22application%2Fx-shockwave-flash%22%20pluginspage%3D%22http%3A%2F%2Fwww.adobe.com%2Fgo%2Fgetflashplayer%22%20%2F%3E%3C%2Fobject%3E";
  $("#container").html( unescape(swf)+"<br>please wait..." ).css({
    "position":"relative",
    "top":"100px"
  });
  setTimeout(  linkJump, 1100, loc );
  return loc ? false : true;
}
function shineStars( )
{
  $(".top-star").each(function (i) {
    var posibility = Math.round(Math.random()*100);
    var opacityValue = Math.round(Math.random()*10)/10;
    var fadeValue = Math.round(Math.random()*250)*10;

    var isPngError = $.browser.msie || $.browser.chrome ? true : false;

    if( isPngError && posibility <= 3 )
    {
      $(this).css({
        "visibility":"hidden"
      });
    }
    else{
      $(this).css({
        "visibility":"visible"
      });
    }

    if( !isPngError && posibility < 10 ){
      $(this).animate({
        opacity: opacityValue
      }, fadeValue);
    }


  });
  
}
function getNews()
{
  main.hook.newsItem = new Array();  
  $(".menu-news-item").each(function (i) {
    main.hook.newsItem[i] = this;
  });
  return main.hook.newsItem;
}
function animateNews()
{
  getNews();
  main.hook.activeItem = 0;
  main.hook.newsPromoHTML = $("#menu-news-hook").html();
  getNewsSeparator();
  main.hook.newsTimer = setInterval(getNewsSeparator, 10000);
  
}
function getNewsSeparator()
{
  $("#menu-news-hook").html( main.hook.newsPromoHTML);
  setTimeout(switchNews, 1200);
}
function switchNews()
{

  if( main.hook.activeItem >= main.hook.newsItem.length )
  {
    //clearInterval(main.hook.newsTimer);
    main.hook.activeItem = 0;
  }
  else{
    $("#menu-news-hook").animate({
      opacity: 1.0
    }, 1000);
    $("#menu-news-hook").html(main.hook.newsItem[main.hook.activeItem].innerHTML);
    $("#menu-news-hook").delay(5000).animate({
      opacity: 0
    }, 4000);
    main.hook.activeItem++;
  }

}


function urlencode(str) {
  return escape(str).replace('+', '%2B').replace('%20', '+').replace('*', '%2A').replace('/', '%2F').replace('@', '%40');
}

function urldecode(str) {
  return unescape(str.replace(/\+/g, ' '));
}
