	/*
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lib.js
Script library for Stroeck

[[[ completion of clib integration still missing ]]]

Version:             1.22
Last Changed:        2008-09-18

manfred.schneiderbauer@world-direct.at
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*/

// Framer
var loc=location.href.toLowerCase();

var tloc=top.location.href.toLowerCase();
if(loc.indexOf('frameset.html')==-1&&loc.indexOf('popup.aspx')==-1&&location.href.indexOf('popup=true')==-1) // if it's not the frameset or a popup,...
	{
	if(tloc.indexOf('frameset.html')==-1&&(tloc.indexOf('.html')!=-1||tloc.indexOf('.aspx')!=-1)) //... and there is no frameset atop of us...
		{ // ...load the frameset and put the current page name into a parameter
		top.location.replace('frameset.html?page='+loc.substring(loc.lastIndexOf('/'),loc.length).replace('/',''));
		}
	}
if(loc.indexOf('topnav.aspx')!=-1) // if it's the top navigation,...
	{
	if(tloc.indexOf('page=')!=-1) // ...see if there has a page parameter been set...
		{ // ...replace the main frame by its value
		top.frames.main.location.replace(tloc.substring(tloc.lastIndexOf('page=')+5,tloc.length));
		} else {
		top.frames.main.location.replace('start_frame.aspx');
		}
	}

//
// centerNews
// positions the navigation area which must have the id 'fitHeaderPos'
//

function fitHeaderPos() {
if (isGecko||isOpr||isSafari)
	{
	try{
	  if(!isSafari)
	    { // Opera/Gecko method
      var iW = parent.frames.main.window.innerWidth;
		  var oW = parent.frames.main.document.documentElement.offsetWidth;
		  var dW=oW-iW;
		  if(dW!=-oW&&dW!=0&&oW!=0)
			  {
			  document.getElementById('fitHeaderPos').style.left=dW/2+'px';
			  } else {
			  document.getElementById('fitHeaderPos').style.left='0px';
			  }
			}else{ // Safari method
			var navW=parent.frames.nav.document.documentElement.offsetWidth;
			var thisW=parent.frames.main.document.documentElement.offsetWidth;
			var diffW=navW-thisW;
	    document.getElementById('fitHeaderPos').style.left='-'+(diffW/2)+'px';
			}
		} catch (error) {}
	}
window.setTimeout("fitHeaderPos();",250);
}

//opens a new popup window

function popUp(fileName,windowName,properties) {
         window.open(fileName,windowName,properties);
}


// Change Cell Backgrounds for the SUB NAVIGATION PRODUCT CATEGORY
function bgOn(td){
	if(document.getElementById||(document.all && !(document.getElementById))){
		td.style.backgroundColor="#FBEDBF";
	}
}

function bgOff(td){
	if(document.getElementById||(document.all && !(document.getElementById))){
		td.style.backgroundColor="#FBE292";
	}
}

// Change Cell Backgrounds for the FILIALE OVERVIEW
function bgFilOn(td){
	if(document.getElementById||(document.all && !(document.getElementById))){
		td.style.backgroundColor="#F8F7ED";
	}
}

function bgFilOff(td){
	if(document.getElementById||(document.all && !(document.getElementById))){
		td.style.backgroundColor="#FCFBF1";
	}
}

// breadcrumbs
function writeBreadcrumbs() {

	if(location.search.indexOf('breadcrumb=')!=-1)
		{
		if(location.search.indexOf('backskip=true')==-1)
			{
			document.getElementById('breadcrumb').innerHTML = '<a href="javascript:history.back();" class="breadcrumbs">'+location.search.substring(location.search.indexOf('breadcrumb=')+11,location.search.length)+'</a>';
			} else {
			document.getElementById('breadcrumb').innerHTML = '<a href="javascript:history.go(-	2);" class="breadcrumbs">'+location.search.substring(location.search.indexOf('breadcrumb=')+11,location.search.lastIndexOf('&'))+'</a>';
			}
		}
}

// prepare sub-breadcrumb links
function prepareBreadcrumbs(){
var linkColl=document.getElementsByTagName('span');
for (var i=0; i<linkColl.length; i++)
	{
	if (linkColl[i].id.indexOf('breadcrumbed')!=-1)
		{
		linkColl[i].childNodes[0].href+='&'+location.search.substring(location.search.indexOf('breadcrumb='),location.search.length)+'&backskip=true';
		}
	}
}


// searchfunction for filialfinder
function search() {
	document.location.href = 'filiale_searchresults.aspx?addr=' + document.getElementById('searchAddress').value;
}

// Scale the full view window to the image's size
//
function showPhoto_scaleWindow(){
var validSize=false;
var originalImage=document.getElementById('originalImage');
originalImage.src=location.search.replace('?image=','');
// get the image dimensions
var width=originalImage.width;
var height=originalImage.height;
if(width>99&&height>99){validSize=true;}
if(validSize)
         {
         // get the screen dimensions
         var screenWidth=window.screen.width;
         var screenHeight=window.screen.height;
         // size corrections
         width+=12;height+=90;
         // if the image is bigger than the screen, equal the window size with the screen size
		if(width>screenWidth){width=screenWidth;}
         if(height>screenHeight){height=screenHeight;}
         // resize the window
         window.resizeTo(width,height);
		 }
window.setTimeout("showPhoto_scaleWindow();",500);
}

function changepic(pic) {
//document.getElementById(id).src = pic;
document.filialMap.src = pic;
}

// preload filialmap images
function preloadFilialmap() {

img1_on = new Image();
img1_on.src = "img/filialmap_1.gif";
img1_off = new Image();
img1_off.src = "img/filialmap.gif";

img2_on = new Image();
img2_on.src = "img/filialmap_2.gif";
img2_off = new Image();
img2_off.src = "img/filialmap.gif";

img3_on = new Image();
img3_on.src = "img/filialmap_3.gif";
img3_off = new Image();
img3_off.src = "img/filialmap.gif";

img4_on = new Image();
img4_on.src = "img/filialmap_4.gif";
img4_off = new Image();
img4_off.src = "img/filialmap.gif";

img5_on = new Image();
img5_on.src = "img/filialmap_5.gif";
img5_off = new Image();
img5_off.src = "img/filialmap.gif";

img6_on = new Image();
img6_on.src = "img/filialmap_6.gif";
img6_off = new Image();
img6_off.src = "img/filialmap.gif";

img7_on = new Image();
img7_on.src = "img/filialmap_7.gif";
img7_off = new Image();
img7_off.src = "img/filialmap.gif";

img8_on = new Image();
img8_on.src = "img/filialmap_8.gif";
img8_off = new Image();
img8_off.src = "img/filialmap.gif";

img9_on = new Image();
img9_on.src = "img/filialmap_9.gif";
img9_off = new Image();
img9_off.src = "img/filialmap.gif";

img10_on = new Image();
img10_on.src = "img/filialmap_10.gif";
img10_off = new Image();
img10_off.src = "img/filialmap.gif";

img11_on = new Image();
img11_on.src = "img/filialmap_11.gif";
img11_off = new Image();
img11_off.src = "img/filialmap.gif";

img12_on = new Image();
img12_on.src = "img/filialmap_12.gif";
img12_off = new Image();
img12_off.src = "img/filialmap.gif";

img13_on = new Image();
img13_on.src = "img/filialmap_13.gif";
img13_off = new Image();
img13_off.src = "img/filialmap.gif";

img14_on = new Image();
img14_on.src = "img/filialmap_14.gif";
img14_off = new Image();
img14_off.src = "img/filialmap.gif";

img15_on = new Image();
img15_on.src = "img/filialmap_15.gif";
img15_off = new Image();
img15_off.src = "img/filialmap.gif";

img16_on = new Image();
img16_on.src = "img/filialmap_16.gif";
img16_off = new Image();
img16_off.src = "img/filialmap.gif";

img17_on = new Image();
img17_on.src = "img/filialmap_17.gif";
img17_off = new Image();
img17_off.src = "img/filialmap.gif";

img18_on = new Image();
img18_on.src = "img/filialmap_18.gif";
img18_off = new Image();
img18_off.src = "img/filialmap.gif";

img19_on = new Image();
img19_on.src = "img/filialmap_19.gif";
img19_off = new Image();
img19_off.src = "img/filialmap.gif";

img20_on = new Image();
img20_on.src = "img/filialmap_20.gif";
img20_off = new Image();
img20_off.src = "img/filialmap.gif";

img21_on = new Image();
img21_on.src = "img/filialmap_21.gif";
img21_off = new Image();
img21_off.src = "img/filialmap.gif";

img22_on = new Image();
img22_on.src = "img/filialmap_22.gif";
img22_off = new Image();
img22_off.src = "img/filialmap.gif";

img23_on = new Image();
img23_on.src = "img/filialmap_23.gif";
img23_off = new Image();
img23_off.src = "img/filialmap.gif";

img24_on = new Image();
img24_on.src = "img/filialmap_gerasdorf.gif";
img24_off = new Image();
img24_off.src = "img/filialmap.gif";

img25_on = new Image();
img25_on.src = "img/filialmap_schwechat.gif";
img25_off = new Image();
img25_off.src = "img/filialmap.gif";
}

// Productfinder Search
function simple_search() {
	document.getElementById('txt_Action').value = 'simple_search';
	document.getElementById('debug').value = '0';
	document.getElementById('frm_ProductFinder').submit();
}
function advanced_search() {
	document.getElementById('txt_Action').value = 'advanced_search';
	document.getElementById('frm_ProductFinder').submit();
}

function _onload(funcCall){
if(window.clib_onloadHasDelayed==undefined||!window.clib_onloadHasDelayed){window.clib_onloadHasDelayed=0;}
if(document.body) // if body exists... (if not, do a delay)
  {
  if(document.body.innerHTML) // if HTML exists inside it... (if not, do a delay)
   {
   var ihLength=Number(document.body.innerHTML.length); // ...store its amount
   if(window.ihOldLength){var ihOldLength=Number(window.ihOldLength);}else{var ihOldLength=0;}
   if(ihLength>ihOldLength) // if amount of HTML is increasing...
    {
    // ...do a delay
    window.ihOldLength=ihLength;
    window.setTimeout("_onload('"+funcCall+"');",25);
    }else{ // if not, the DOM contents are created
    if(window.clib_onloadHasDelayed==0) // if the rendering delay has not yet been processed...
      {
      window.clib_onloadHasDelayed=1;
      window.setTimeout("_onload('"+funcCall+"');",1000); // ...do a delay
      }else{ // else, finally execute the function call
      eval(funcCall);
      }
    }
   }else{
   window.setTimeout("_onload('"+funcCall+"');",25);
   }
  }else{
  window.setTimeout("_onload('"+funcCall+"');",25);
  }
}

// Change all links to target the top frame
function modifyLinks(){
var allLinks=document.getElementsByTagName('a');
for(var i=0;i<allLinks.length;i++)
  {
   if(allLinks[i].href.indexOf('mailto:')==-1){allLinks[i].target='_top';}
  }
allLinks=document.getElementsByTagName('area');
for(i=0;i<allLinks.length;i++)
  {
   if(allLinks[i].href.indexOf('mailto:')==-1){allLinks[i].target='_top';}
  }
}
_onload("modifyLinks()");

// helper
function d(id){return(document.getElementById(id));}



function setHome()
  {
    if (document.all)
    {
     document.body.style.behavior='url(#default#homepage)';
     document.body.setHomePage('http://www.stroeck.at');

    }
    else if (window.sidebar)
     {
         if(window.netscape)
         {
          try
          {
          netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
          }
       catch(e)
      {
    alert("this action was aviod by your browser,if you want to enable,please enter        about:config in your address line,and change the value of     signed.applets.codebase_principal_support to true");
}
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage','http://url_of_page.com');
}
}
