
var AreaOpened = new Array();
AreaOpened['middle']  = false;

function AjaxContent(URL) {
    // parsujeme Ajax parameter
    AjaIndex = URL.indexOf("&Ajax");
    if (AjaIndex == -1) {
	URL = URL + "&Ajax=ajax_content";
    } else { 
    }
    // 
    Ajax(URL, { TargetId: 'ajax_content', NoProgress: true });
}

function ThemeOpenArea(TargetId, URL, Options) {
    if (TargetId != "light_news") 
        if (TargetId != "mainmenu") {
//	    Ajax(URL + "&Ajax=mainmenu", { TargetId: 'mainmenu', NoProgress: true });
	}
    if ((URL.indexOf("product/") != -1) && (URL.indexOf("View") != -1)) {
        AreaOpen('middle');
        return "middle_area_container";
    }
    return TargetId;
}

function ThemeInit() {
    $('Loading').style.display = "none";
    $('Screen').style.display = "block";
}

function ThemeResize() {

    // height
    var theHeight = 0;
    if (window.innerHeight) {
      theHeight=window.innerHeight;
    } else {
      if (document.documentElement && document.documentElement.clientHeight) {
         theHeight=document.documentElement.clientHeight;
      } else {
        if (document.body) {
          theHeight=document.body.clientHeight;
        }
      }
    }
    WindowHeight = theHeight;

    // width
    var theWidth = 0;
    if (window.innerWidth) {
      theWidth=window.innerWidth;
     } else {
        if (document.documentElement && document.documentElement.clientWidth) {
           theWidth=document.documentElement.clientWidth;
      } else {
        if (document.body) {
          theWidth=document.body.clientWidth;
        }
      }
    }
    WindowWidth = theWidth;

    Left = parseInt((theWidth - 713) / 2);
    Main = parseInt((theHeight - 602) / 2);
    $('Screen').style.width = theWidth + 'px';
    $('Screen').style.height = theHeight + 'px';
    $('ThemeTop').style.left = Left + 'px';
    $('ThemeMain').style.left = Left + 'px';
    $('ThemeBottom').style.left = Left + 'px';
    $('ThemeMain').style.top = ((Main < 0) ? 0 : Main) + 'px';
    $('ThemeTop').style.top = ((Main < 0) ? 0-90 : Main-90) + 'px';
    $('ThemeBottom').style.top = ((Main < 0) ? 0+602 : Main+602) + 'px';
    $('ThemeLine').style.top = ((Main < 0) ? 0+232 : Main+232) + 'px';
    $('ThemeLine').style.width = theWidth + 'px';
    $('middle_area_shadow').style.top  = ((Main < 0) ? 0 + 67 : Main + 67) + 'px';
    $('middle_area_shadow').style.left = ((WindowWidth - 664) / 2) + 'px';
}

// area = left, right
function AreaOpen(AreaName) {
  if (AreaOpened[AreaName])
    return;
  AreaOpened[AreaName]    = true;
  if (AreaName == "left") {
    $j('#left_area_container').fadeIn("fast");
    $('left_area_shadow').style.left  = "185px";
  }
  if (AreaName == "middle") {
    $j('#middle_area_container').fadeIn();
    $j('#middle_area_shadow').fadeIn();
    $j('#middle_area_close').fadeIn();
  }
  if (AreaName == "right") {
    $j('#right_area_container').fadeIn("fast");
    $('right_area_shadow').style.right  = "185px";
  }
  if (AreaName == "info") {
    $j('#info_box').fadeIn("fast");
    $j('#info_box_close').fadeIn("slow");
  }
  ThemeResize();
}

// area = left, right
function AreaClose(AreaName) {
  if (AjaxIsRunning) {
    return;
  }
  if (!AreaOpened[AreaName])
     return;
  AreaOpened[AreaName]    = false;
  if (AreaName == "left") {
    $('left_area_shadow').style.left  = "0px";
    $j('#left_area_container').fadeOut("slow");
  }
  if (AreaName == "right") {
    $('right_area_shadow').style.right  = "0px";
    $j('#right_area_container').fadeOut("slow");
  }
  if (AreaName == "middle") {
    $j('#middle_area_container').fadeOut();
    $j('#middle_area_shadow').fadeOut();
    $j('#middle_area_close').fadeOut();
  }
  if (AreaName == "info") {
    $j('#info_box').fadeOut("slow");
    $j('#info_box_close').fadeOut("slow");
  }
  ThemeResize();
}

// delayed close
function AreaCloseDelayed(AreaName) {
  if (AreaOpened[AreaName]) {
    AreaOpened[AreaName] = false;
    var t = setTimeout("if (AreaOpened['"+AreaName+"'] === false) { AreaOpened['"+AreaName+"'] = true; AreaClose('"+AreaName+"'); } ",2000);
  }
}

function LayoutGallery(URL) {
    $('layout1image').src=URL;
}
