﻿/*
    Global functions. No Editar.
*/

/*
    Window Popper
*/
	function pop(url, name, width, height, centered, features) {
		if(window.screen)if(centered)if(centered=="1"){
			var l = (screen.width-width)/2;
			var t = (screen.height-height)/2;
			features+=(features!='')?',':'';
			features+='left='+l+',top='+t;
		}
		var flop=window.open(url, name, features+((features!='')?',':'')+'width='+width+',height='+height);
		flop.focus();
	}

/*
    Emular las pseudoclases de CSS con Javascript
*/
	function suckerfish(type, tag, parentId) {
		if (window.attachEvent) {
			window.attachEvent("onload", function() {
				var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag);
				type(sfEls);
			});
		}
	}
	// HOVER
	sfHover = function(sfEls) {
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
	// FOCUS
	sfFocus = function(sfEls) {
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onfocus=function() {
				this.className+=" sffocus";
			}
			sfEls[i].onblur=function() {
				this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
			}
		}
	}
	// ACTIVE
	sfActive = function(sfEls) {
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmousedown=function() {
				this.className+=" sfactive";
			}
			sfEls[i].onmouseup=function() {
				this.className=this.className.replace(new RegExp(" sfactive\\b"), "");
			}
		}
	}
	// TARGET
	sfTarget = function(sfEls) {
		var aEls = document.getElementsByTagName("A");
		document.lastTarget = null;
		for (var i=0; i<sfEls.length; i++) {
			if (sfEls[i].id) {
				if (location.hash==("#" + sfEls[i].id)) {
					sfEls[i].className+=" sftarget";
					document.lastTarget=sfEls[i];
				}
				for (var j=0; j<aEls.length; j++) {
					if (aEls[j].hash==("#" + sfEls[i].id)) aEls[j].targetEl = sfEls[i];
					aEls[j].onmousedown = function() {
						if (document.lastTarget) document.lastTarget.className = document.lastTarget.className.replace(new RegExp(" sftarget\\b"), "");
						if (this.targetEl) this.targetEl.className+=" sftarget";
						document.lastTarget=this.targetEl;
						return true;
					}
				}
			}
		}
	}
	
	// Soluciona las transparencias PNG para IE
	function fixPNG(myImage){
		if (document.all) {
			var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
			var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
			var imgTitle = (myImage.title) ? "title='" + myImage.title + "' " : "title='" + myImage.alt + "' "
			var imgStyle = "display:inline-block;" + myImage.style.cssText
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			strNewHTML += " style=\"" + "width:" + myImage.width + "px; height:" + myImage.height + "px;" + imgStyle + ";"
			strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			strNewHTML += "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>" 
			myImage.outerHTML = strNewHTML
		}
	}
