// General Javascript functions for SwissPasses.com

//-------------------------------------------------------------
// Check if an element can be made transparent
//-------------------------------------------------------------
function supportsOpacity( el ) {
	if ( el.style.opacity != undefined )
		return true;
	if( el.style.MozOpacity != undefined )
		return true;
	if ( el.style.filter != undefined )
		return true;
	return false;
}
	
//-------------------------------------------------------------
// Set an element's transparency
//-------------------------------------------------------------
function setOpacity( el, opaciLevel ) {
	if ( el.style.opacity != undefined ) {
		el.style.opacity = opaciLevel;
	} else if( el.style.MozOpacity != undefined ) {
		el.style.MozOpacity = opaciLevel;
	} else if ( el.style.filter != undefined ) {
		var oplvl = Math.round(opaciLevel*100);
		el.style.filter="alpha(opacity=" + oplvl + ")";
	}
}


//-------------------------------------------------------------
// Add a CSS Class to an element.
//-------------------------------------------------------------
function addClassName (elem, className) {
    removeClassName (elem, className);
    elem.className = (elem.className + " " + className).trim();
}

//-------------------------------------------------------------
// Remove a CSS Class to an element.
//-------------------------------------------------------------
function removeClassName (elem, className) {
    elem.className = elem.className.replace(className, "").trim();
}

//-------------------------------------------------------------
// Used to trim whitespace from start/end of class names.
//-------------------------------------------------------------
String.prototype.trim = function() {
    return this.replace( /^\s+|\s+$/, "" );
}

