﻿function ui_popup_close() {
  function __do_close(doc) {
    var j_pw = jQuery("#popup_window", doc);
    var j_pw_title = jQuery("#div_pw_title", doc);
    var j_pw_frame = jQuery("#frame_pw", doc);
    
    j_pw_title.html("&nbsp;")
    j_pw_frame.attr("src", "about:blank");
    j_pw.attr("class", "nop");

    return false;
  }
  __do_close(window.top.document);
}

$(document).ready(function() {
  var j_pw = jQuery("#popup_window");
  var j_pw_title = jQuery("#div_pw_title");
  var j_pw_frame = jQuery("#frame_pw");
  var j_pw_no_frame = jQuery("div.nf_content");

  function open_popup(j_this, attr) {
    var p_classes = j_this.attr("class").split(' ');

    var p_type = "type_1";
    for (var index = 0; index < p_classes.length; index++) {
        var p_class = p_classes[index];
        if (p_class.indexOf("size_")==0) {
          j_size = p_class.substr(5);
          j_size = j_size.split('x');
          j_x = parseInt(j_size[0],10);
          j_y = parseInt(j_size[1],10);
          jQuery("#popup_window .center .body").css("width", j_x).css("height", j_y).css("text-align", "left");
          jQuery("#popup_window .center").css("width", j_x+20).css("height",j_y+50);
          if (attr == "href") {
            j_pw_frame.css("width", j_x).css("height", j_y);
            jQuery("#popup_window .center .body").css("text-align", "left");
          }
        }
    }

    var p_href = j_this.attr(attr);
    j_pw_title.html(j_this.attr("title"))
    j_pw.attr("class", "act " + p_type);
      if ($.browser.msie && $.browser.version == 6) {
        var __fix_popup_position_ie6 = function() {
          scroll_position = jQuery("html").scrollTop();
          html_height = jQuery("html").height() - 4;
          jQuery("#popup_window").css("top", scroll_position).css("height", html_height);
          window.setTimeout(__fix_popup_position_ie6, 100);
        }
        window.setTimeout(__fix_popup_position_ie6, 100);
      }
    if (attr == "href") {
      j_pw_frame.show();
      j_pw_no_frame.hide();
      if (p_href.indexOf("?") > 0) {
        j_pw_frame.attr("src", p_href+"&type="+p_type);
      } else {
        j_pw_frame.attr("src", p_href+"?type="+p_type);
      }
    } else if (attr == "rel") {
      j_nf_content = "<img src='"+p_href+"'/>";
      j_pw_no_frame.html(j_nf_content);
      j_pw_frame.hide();
      j_pw_no_frame.show();
    }
    return false;
  };

  jQuery("a.popup").click(function() {
    open_popup(jQuery(this), "href");
    return false;
  });
  
  jQuery("a.popup_nf").click(function() {
    open_popup(jQuery(this), "rel");
    return false;
  });
  
  jQuery("#a_pw_close")
    .bind("click", ui_popup_close)
    .hover(
      function(){
        jQuery(this).addClass("close_popup_act");
      },
      function() {
        jQuery(this).removeClass("close_popup_act");
      }
    );
});

// -- NAV MENU (HIDE LIST) ------------------------------------------------------------------
jQuery(document).ready(function () {
  jQuery("div.header .nav .item").hover(
  function() {
    jQuery(this).find("div.list").show();
  },
  function() {
    jQuery(this).find("div.list").hide();
  })
});
  
jQuery(document).ready(function() {
  jQuery("div.header .nav li.item_last").prev().addClass("last");
});
// -->

// -- MODELS HEADER -------------------------------------------------------------------------
jQuery(document).ready(function () {
  j_sh_h = jQuery("div.info .sub_header").height();
  jQuery("div.info .sub_header .model_name").css("height",j_sh_h);
});
// -->
