/*
** This was created by Ujeen
*/


/* --==:: Search Box Animation ::==-- */
$(function(){
  $(document).ready(function(){


    var l_w = $('.loupe').width();
    var l_h = $('.loupe').height();
    var lb_w = $('.loupebox').width();
    var lb_h = $('.loupebox').height();
    var l_left = (lb_w-l_w)/2;
    var l_top = (lb_h-l_h)/2;


    $('.loupebox').css({
      width:lb_w,
      height:lb_h,
      textAlign:'left',
      verticalAlign:'top'
    })
    $('.loupe').css({
      margin:0,
      marginLeft:l_left,
      marginTop:l_top,
      padding:0
    });
    var action = 1;
    var stoped = false;
    var loupe = $('.loupe').eq(0);

    $('.custom-box-1').mouseover(function (){
      function amimate_loupe() {
        if (action == 0) {
          //console.log(circle);
          loupe
          .animate({
            marginTop:(l_top-4),
            marginLeft:(l_left-4)
          },400)
          .animate({
            marginTop:(l_top+4)
          },400)
          .animate({
            marginLeft:(l_left+4)
          },400)
          .animate({
            marginTop:(l_top-4)
          },400)
          .animate({
            marginTop:(l_top-4),
            marginLeft:(l_left-4)
          },400)
          .animate({
            marginTop:(l_top+4)
          },400)
          .animate({
            marginLeft:(l_left+4)
          },400)
          .animate({
            marginTop:(l_top-4)
          },400)
          .animate({
            marginTop:(l_top),
            marginLeft:(l_left)
          },400);
        }
      }
      if (action == 1) {
        action = 0;
        stoped = false;
        amimate_loupe();
      }
    //console.log(action)
    });
    $('.templates_box, .header, .left, .text_block').mouseover(function (e){
      action = 1;
      //if (!stoped) {
      loupe.stop()
      .animate({
        marginTop:(l_top),
        marginLeft:(l_left)
      },400);
    //stoped = true;
    //}
    })
    $('.custom-box-1 option').mouseover(function (e){
      loupe.stop()
      if (!stoped) {
        loupe.stop()
        .animate({
          marginTop:(l_top),
          marginLeft:(l_left)
        },400);
        stoped = true;
      }
    })

  })
});

/*  --==:: Slide Background ::==-- */
$(document).ready(function(){
  if(!($.browser.msie && ($.browser.version == '6.0'))) {
    $('#header').css({
      'background-position': 'left +158px'
    });
    $('#content .content_topbg').css({
      'background-position': 'left -219px'
    });
    $.timer(1500, function (timer) {
      $('#header').animate({
        backgroundPosition: '(0 -23px)'
      },300)
      timer.stop();
    });
    $.timer(2000, function (timer) {
      $('#content .content_topbg').animate({
        backgroundPosition: '(0 -19px)'
      },300)
      timer.stop();

    });

  }
});




