//___________________________________________________________________[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('btnAboutTrackback').each(
		function(element){ 
			element.onclick = function() {
				Element.find(element, 'nextSibling').fx.toggle();
			}
		}
	);

	document.getElementsByClassName('btnAboutBookmark').each(
		function(element){ 
			element.onclick = function() {
				Element.find(element, 'nextSibling').fx.toggle();
			}
		}
	);
};

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();
}



//___________________________________________________________________[HOVER FIX FOR IE]
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}



//___________________________________________________________________[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);
			}
		}
	}
}



////___________________________________________________________________[POPUP]
//LINK MOVIE
function openLinkPopup(wUrl){
	var wObj;
	wWidth = 950;
	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 + ",left=" + (scWidthCenter - (wWidth / 2)) + ",top=" + (scHeightCenter - (wHeight / 2));
	wObj = window.open(wUrl,'link',wOption);
	wObj.focus();
}

//STANDARD
function openStdPopup(wUrl){
	var wObj;
	wWidth = 520;
	wHeight = 715;
	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 + ",left=" + (scWidthCenter - (wWidth / 2)) + ",top=" + (scHeightCenter - (wHeight / 2));
	wObj = window.open(wUrl,'stdPopup',wOption);
	wObj.focus();
}

//MEMBER REGISTRATION
function openRegisterPopup(wUrl){
	var wObj;
	wWidth = 536;
	wHeight = 715;
	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 + ",left=" + (scWidthCenter - (wWidth / 2)) + ",top=" + (scHeightCenter - (wHeight / 2));
	wObj = window.open(wUrl,'stdPopup',wOption);
	wObj.focus();
}

function openModifyPopup(wUrl){
	var wObj;
	wWidth = 536;
	wHeight = 480;
	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 + ",left=" + (scWidthCenter - (wWidth / 2)) + ",top=" + (scHeightCenter - (wHeight / 2));
	wObj = window.open(wUrl,'stdPopup',wOption);
	wObj.focus();
}

//AFTER SALES SERVICE
function openRepairCostEstimatePopup(wUrl){
	var wObj;
	wWidth = 530;
	wHeight = 750;
	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 + ",left=" + (scWidthCenter - (wWidth / 2)) + ",top=" + (scHeightCenter - (wHeight / 2));
	wObj = window.open(wUrl,'repairEstimate',wOption);
	wObj.focus();
}

function openRepairCardPopup(wUrl){
	var wObj;
	wWidth = 900;
	wHeight = 200;
	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 + ",left=" + (scWidthCenter - (wWidth / 2)) + ",top=" + (scHeightCenter - (wHeight / 2));
	wObj = window.open(wUrl,'repairCard',wOption);
	wObj.focus();
}

//NEW CARRERA
function openNewCarreraPopup(wUrl){
	var wObj;
	wWidth = 520;
	wHeight = 712;
	scWidthCenter = screen.availWidth / 2;
	scHeightCenter = screen.availHeight / 2;
	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,'newCarrera',wOption);
	wObj.focus();
}

//BAHAMA
function openBahamasPopup(wUrl){
	var wObj;
	wWidth = 890;
	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 + ",left=" + (scWidthCenter - (wWidth / 2)) + ",top=" + (scHeightCenter - (wHeight / 2));
	wObj = window.open(wUrl,'bahama',wOption);
	wObj.focus();
}



////___________________________________________________________________[MAILTO]
function getMailto(user,domain){
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}