//___________________________________________________________________[ROLLOVER]
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'rollover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}


//___________________________________________________________________[TOGGLE]
var infoToggleDuration = 200;
function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
//  } else {
//    alert("Sorry! This website requires a modern web browser like Firefox, Safari or IE6.");
//    location.href = "100.htm";
  }
};

var infoPanes = function() {	
	document.getElementsByClassName('hiddenBlock').each( 
		function(element){ 	
			element.fx = new fx.Height(element, {duration: 200, onComplete: function(){
			if (element.offsetHeight > 0) element.style.height = "auto";}});
			element.fx.hide();			
		}
	);

	document.getElementsByClassName('titleQuestion').each(
		function(element){ 
			element.onclick = function() {
				Element.find(element, 'nextSibling').fx.toggle();
			}
		}
	);

	document.getElementsByClassName('btnOpenAnswerArea').each(
	function(element){ 
		element.onclick = function() {
			Element.find(element, 'nextSibling').fx.toggle();
			if(element.style.backgroundImage == 'url(../../with_wsi/img/btn_close_answer_area.gif)') 
				{
				element.style.backgroundImage = 'url(../../with_wsi/img/btn_open_answer_area.gif)';
				}
			else
				{
				element.style.backgroundImage = 'url(../../with_wsi/img/btn_close_answer_area.gif)';
				}
		  }
	}	
);


};

var supaInit = function() {
	infoPanes();
};
addEvent(window, 'load', supaInit, false);



////___________________________________________________________________[SCROLL]
var ScrollLinks = {
    currentHash: false,
    start: function(){
        this.scroll = new fx.Scroll({duration: 300, onComplete: function(){ScrollLinks.end();}});
        this.allinks = document.getElementsByTagName('a');
        for (i=0; i<this.allinks.length; i++){
            var lnk = this.allinks[i];
            if ((lnk.href && lnk.href.indexOf('#') != -1) && ( (lnk.pathname == location.pathname) || ('/'+lnk.pathname == location.pathname) ) && (lnk.search == location.search)) {
                lnk.onclick = function(){
                    ScrollLinks.scroll.clearTimer();
                    this.initialHref = this.href;
                    this.initialHash = this.hash;
                    this.href = "javascript:void(0)";
                    setTimeout(function(){this.href = this.initialHref;}.bind(this), 200);
                    ScrollLinks.click(this);
                }
            }
        }
    },

    click: function(link){
        this.currentHash = link.initialHash.substr(1);
        if (this.currentHash) {
            for (j=0; j<this.allinks.length; j++){
                if (this.allinks[j].id == this.currentHash){
                    if (!window.opera) this.scroll.scrollTo(this.allinks[j]);
                    else this.scroll.scrollTo(this.allinks[j].parentNode);
                    break;
                }
            }
        }
    },

    end: function(){
        window.location.href = "#"+this.currentHash;
        this.currentHash = false;
    }
}

window.onload = function(){
    ScrollLinks.start();
	initRollovers();
}



//___________________________________________________________________[POPUP WINDOW]

function openAccessMapWin(wUrl){
	var wObj;
	wWidth = 541;
	wHeight = 600;
	scWidthCenter = screen.availWidth / 2;
	scHeightCenter = screen.availHeight / 2;
//	wOption = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + wWidth + ",height=" + wHeight;
	wOption = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + wWidth + ",height=" + wHeight + ",left=" + (scWidthCenter - (wWidth / 2)) + ",top=" + (scHeightCenter - (wHeight / 2));
	wObj = window.open(wUrl,'Style',wOption);
	wObj.focus();
}


function openIdealOfficeWin(wUrl){
	var wObj;
	wWidth = 620;
	wHeight = 410;
	scWidthCenter = screen.availWidth / 2;
	scHeightCenter = screen.availHeight / 2;
//	wOption = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + wWidth + ",height=" + wHeight;
	wOption = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + wWidth + ",height=" + wHeight + ",left=" + (scWidthCenter - (wWidth / 2)) + ",top=" + (scHeightCenter - (wHeight / 2));
	wObj = window.open(wUrl,'Style',wOption);
	wObj.focus();
}


//___________________________________________________________________[PULL DOWN MENU]

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}