﻿// JScript File
var menuBook;
var menuCategory;
var menuRoomSelected="";
var currentSub;
var currentBook;
var currentChild;
var currentBorder;
var mydel="";
var myUpdatePart="";
var myUpdateQty="";

//** Menu **//
function replaceMenu() {
  if (document.documentElement.clientWidth>990) {
    document.getElementById('menuBook').style.left=((document.documentElement.clientWidth/2-405))+"px";
  }
  else {
    document.getElementById('menuBook').style.left="88px";
  }
  document.getElementById('menuBook').style.top="134px";
}

function showMenuBook(obj) {
  clearTimeout(menuBook);
  if (document.getElementById('CurrentRoom')) {
    menuRoomSelected=document.getElementById('CurrentRoom');
  } 
  if (menuRoomSelected != "") {
    menuRoomSelected.style.position='static';
    menuRoomSelected.style.backgroundColor='Transparent';
    menuRoomSelected.style.paddingTop='0px';
  }
  document.getElementById('menuBook').style.visibility='visible';
  
  previousSub=currentSub;
  
  if (obj.id.indexOf("menuItem")>=0) {
    obj.style.backgroundColor='#cfcfcf';
  }
}

function hideMenuBook(obj) {
   if (obj.id.indexOf("menuItem")>=0) {
    obj.style.backgroundColor='#f2f2f2';
  }
  clearTimeout(menuBook);
  menuBook=setTimeout("realHideMenuBook();",1000);
}
function realHideMenuBook() {
  if (menuRoomSelected != "") {
    menuRoomSelected.style.position='relative';
    menuRoomSelected.style.backgroundColor='White';
    menuRoomSelected.style.paddingTop='13px';
  }
  if (currentBook) {
    currentBook.style.backgroundColor='Transparent';
    currentBook.style.backgroundImage=currentSub.style.backgroundImage;
  }

  document.getElementById('menuBook').style.visibility='hidden';
  if (currentSub) {
    currentSub.style.visibility='hidden';
  }
}

//** Fin menu **//


function moveRoom() {
  if (document.getElementById('Flash')) {
    if( typeof( window.pageYOffset ) == 'number' ) {
      var scrollTop=window.pageYOffset;
    }
    else {
      var scrollTop=document.documentElement.scrollTop;
    }
    if (scrollTop<65) {
      document.getElementById('Flash').style.marginTop="0px";
    }
    else if (scrollTop>150) {
      document.getElementById('Flash').style.marginTop=(scrollTop-150)+"px";
    }
  }
}

function reload(child) {
  document.getElementById('ctl00_ContentPlaceHolder1_child').value=child;
  document.getElementById('ctl00_ContentPlaceHolder1_mytype').value="sidewall";

  doClick(document.getElementById('ctl00_ContentPlaceHolder1_btnReloadFlash'));
  if (currentChild) {
    document.getElementById(currentChild).className="PatternBoxDefault";
  }
  document.getElementById(child).className="PatternBoxSelected";
  currentChild=child
}

function reloadBorder(child) {
  document.getElementById('ctl00_ContentPlaceHolder1_child').value=child;
  document.getElementById('ctl00_ContentPlaceHolder1_mytype').value="border";
  doClick(document.getElementById('ctl00_ContentPlaceHolder1_btnReloadFlash'));
  if (currentBorder) {
    document.getElementById(currentBorder).className="PatternBoxDefault";
  }
  document.getElementById(child).className="PatternBoxSelected";
  currentBorder=child
}

function doClick(button) {
  if (button) {
    if (button.dispatchEvent)
    {
        // FireFox
        var e = document.createEvent("MouseEvents");
        e.initEvent("click", true, true);
        button.dispatchEvent(e);
    }
    else
    {
          // IE
        button.click();
    }
  }
}

function del(child) {
  if (mydel!="") {
    mydel+=";"+child;
  }
  else {
    mydel=child;
  }
}

function update(child,obj) {
  if (myUpdatePart!="") {
    myUpdatePart+=";"+child;
    myUpdateQty+=";"+obj.value;
  }
  else {
    myUpdatePart=child;
    myUpdateQty=obj.value;
  }
}

function clickInfoOk() {
  $find('MPEinfo').hide();
}
function clickStoreOk() {
  $find('MPEstore').hide();
}

function clickCalculatorOk() {
  $find('MPEcalculator').hide();
}

function showStore(){
  $find('MPEstore').show();
}

function checklen(len,obj,newbox) {
  if (obj.value.length==len) {
    document.getElementById(newbox).focus();
  }
}