/*	sIFR 2.0.1 Official Add-ons 1.2
	Copyright 2005 Mark Wubben

	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/

if(typeof sIFR=="function")(function(){var j=document;var h=j.documentElement;sIFR.removeDecoyClasses=function(){function a(b){if(b&&b.className!=null)b.className=b.className.replace(/\bsIFR-hasFlash\b/,"")}return function(){a(h);a(j.getElementsByTagName("body")[0])}}();sIFR.preferenceManager={storage:{sCookieId:"sifr",set:function(a){var b=new Date();b.setFullYear(b.getFullYear()+3);j.cookie=[this.sCookieId,"=",a,";expires=",b.toGMTString(),";path=/"].join("")},get:function(){var a=j.cookie.match(new RegExp(";?"+this.sCookieId+"=([^;]+);?"));if(a!=null&&a[1]=="false")return false;else return true},reset:function(){var a=new Date();a.setFullYear(a.getFullYear()-1);j.cookie=[this.sCookieId,"=true;expires=",a.toGMTString(),";path=/"].join("")}},disable:function(){this.storage.set(false)},enable:function(){this.storage.set(true)},test:function(){return this.storage.get()}};if(sIFR.preferenceManager.test()==false){sIFR.bIsDisabled=true;sIFR.removeDecoyClasses()}sIFR.rollback=function(){function a(b){var c,d,e,f,g,h;var l=parseSelector(b);var i=l.length-1;var m=false;while(i>=0){c=l[i];l.length--;d=c.parentNode;if(c.getAttribute("sifr")=="true"){h=0;while(h<d.childNodes.length){c=d.childNodes[h];if(c.className=="sIFR-alternate"){e=c;h++;continue}d.removeChild(c)}if(e!=null){f=e.firstChild;while(f!=null){g=f.nextSibling;d.appendChild(e.removeChild(f));f=g}d.removeChild(e)}if(!sIFR.UA.bIsXML&&sIFR.UA.bUseInnerHTMLHack)d.innerHTML+="";d.className=d.className.replace(/\bsIFR\-replaced\b/,"")};m=true;i--}return m}return function(k){named.extract(arguments,{sSelector:function(a){k=a}});if(k==null)k="";else k+=">";sIFR.removeDecoyClasses();sIFR.bHideBrowserText=false;if(a(k+"embed")==false)a(k+"object")}}()})()


// ********************************************************************************
// *********** Functiones extra para poner en plantillas ***************************
// ********************************************************************************
function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}
function toHex(N) {
	if (N==null) return "00";
	N=parseInt(N); if (N==0 || isNaN(N)) return "00";
	N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
	return "0123456789ABCDEF".charAt((N-N%16)/16)
		+ "0123456789ABCDEF".charAt(N%16);
}


function getHexColor(sValue) {
	if (!sValue) return null;
	var a_sRGB, i;
	if (sValue.indexOf("#")!=-1) return sValue;
	sValue = sValue.replace("rgb(", "").replace(")","");
	a_sRGB = sValue.split(",");
	return "#" + RGBtoHex(a_sRGB[0],a_sRGB[1],a_sRGB[2]);
}
  
function getStyle(oObject, sPropIE, sPropFx) {
	var y;
	if (oObject.currentStyle)
			y = oObject.currentStyle[sPropIE];
		else if (window.getComputedStyle)
			y = document.defaultView.getComputedStyle(oObject,null).getPropertyValue(sPropFx);
	return y;
}

// ********************************************************************************
// Llamada principal que utliza sIFR recogiendo de la capa iDL los estilos de color
// recibe el resto de parámetros que necesita sFIR
// Ejemplo llamada: call_sIFR("prueba1", "#prueba1", "transparent", "/include/admin/sIFR/frenchscriptmt.swf", "textalign=left&offsetTop=0&offsetLeft=0");
// ********************************************************************************
function call_sIFR(idL, _sSelector, _sWmode, _sFlashSrc, _sCase, _sFlashVars) {
	var oL = document.getElementById(idL);
	var oProp;
	var _sSelector, _sWmode, _sFlashSrc, _sColor, _sLinkColor, _sBgColor, _sHoverColor, _nPaddingTop, _nPaddingBottom, _sFlashVars, _nPaddingRight, _nPaddingLeft;
	if (!oL) {/*alert("Debes definir la capa " + idL + " con los estilos sIFR.");*/return;}

	_sColor = (getHexColor(getStyle(oL, "color", "color")) || null);
	_sBgColor = (getHexColor(getStyle(oL, "backgroundColor", "background-color")) || null);
	_sLinkColor = (getHexColor(getStyle(oL, "borderTopColor", "border-top-color")) || null);
	_sHoverColor = (getHexColor(getStyle(oL, "borderBottomColor", "border-bottom-color")) || null);
	
	oProp = getStyle(oL, "paddingTop", "padding-top");
	_nPaddingTop = (oProp) ? oProp.replace("px","") : 0;
	oProp = getStyle(oL, "paddingBottom", "padding-bottom");
	_nPaddingBottom = (oProp) ? oProp.replace("px","") : 0;
	oProp = getStyle(oL, "paddingRight", "padding-right");
	_nPaddingRight = (oProp) ? oProp.replace("px","") : 0;
	oProp = getStyle(oL, "paddingLeft", "padding-left");
	_nPaddingLeft = (oProp) ? oProp.replace("px","") : 0;

	sIFR.replaceElement(
		named({sSelector:_sSelector, sWmode:_sWmode, sFlashSrc:_sFlashSrc, sColor:_sColor,
			sLinkColor:_sLinkColor, sBgColor:_sBgColor, sHoverColor:_sHoverColor, nPaddingTop:_nPaddingTop,
			nPaddingBottom:_nPaddingBottom, nPaddingLeft:_nPaddingLeft, nPaddingRight:_nPaddingRight, sCase:_sCase, sFlashVars:_sFlashVars})
		);
}

