function trim(s){
	s = s.replace(/\s+/gi, ' '); //sacar espacios repetidos dejando solo uno
	s = s.replace(/^\s+|\s+$/gi, ''); //sacar espacios blanco principio y final
	return s;
}
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
function MM_preloadImages() { //v3.0
		var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
		var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
var intDelay=0;
function animaBG(iThis){
	var strTag='';
	if (iThis < 10)strTag='menu0'+iThis;
	else strTag='menu'+iThis;
	oThis = document.getElementById(strTag);
	oThis.style.backgroundImage="url(modules/templates/SMF_default/images/wave-anima.gif)";
}
function staticBG(iThis){
	var strIdMenu;
	var strIdSubMenu;
	if (iThis < 10){
		strIdMenu='menu0'+iThis;
		strIdSubMenu='submenu0'+iThis;
	}else{
		strIdMenu='menu'+iThis;
		strIdSubMenu='submenu'+iThis;
	}
	element = document.getElementById(strIdMenu);
	element.style.backgroundImage="none";
	if (document.getElementById(strIdSubMenu) != null)
		document.getElementById(strIdSubMenu).style.visibility='hidden';
	/*
	if (document.getElementById('subMenuBackIFrame') != null)
		document.getElementById('subMenuBackIFrame').style.visibility='hidden';
	*/
}
function getAbsoluteElementPosition(element) {
  if (typeof element == "string")
    element = document.getElementById(element)
    
  if (!element) return { top:0,left:0 };
  
  var y = 0;
  var x = 0;
  while (element.offsetParent) {
    x += element.offsetLeft;
    y += element.offsetTop;
    element = element.offsetParent;
  }
  return {top:y,left:x};
}

/*submenu*/
function SMF_browseDetect(){
	var navegador = navigator.appName
	if (navegador == "Microsoft Internet Explorer")	return true;
	else return false;
}

function SMF_subMenuSetXY(strId){  
  	var strIdMenu;
  	var strIdSubMenu;
  	var pos;
	
	if (strId < 10){
		strIdMenu='menu0'+strId;
		strIdSubMenu='submenu0'+strId;
	}else{
		strIdMenu='menu'+strId;
		strIdSubMenu='submenu'+strId;
	}
	pos = getAbsoluteElementPosition(strIdMenu);
	
	document.getElementById(strIdSubMenu).style.visibility='visible';
	
  	if (SMF_browseDetect()){
		if (typeof document.body.style.maxHeight != "undefined")
	  		document.getElementById(strIdSubMenu).style.top=pos.top-64;
		else
			document.getElementById(strIdSubMenu).style.top=pos.top-44;
		document.getElementById(strIdSubMenu).style.left='-4px';
	}else{
		document.getElementById(strIdSubMenu).style.top=(pos.top-4)+'px';
	  	document.getElementById(strIdSubMenu).style.left='140px';
	}
}
var intDelay=0;
function SMF_setDelay(strId){	
	intDelay=setTimeout('staticBG('+strId+')',10);//1200
}
function SMF_clearDelay(){
	if (intDelay > 0)
		clearTimeout(intDelay);
}

function SMF_managePopupOpen(urlOpen){	
	window.open(urlOpen, 'popReview','status=no,directories=no, toolbar=no, location=no, width=450, height=240');	
}

function SMF_manageProductMovie(strPathMovie){
	
	var strContent = '<object width="400" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">';
	strContent += '		<param value="'+strPathMovie+'" name="movie"/>';
	strContent += '		<param value="high" name="quality"/>';
	strContent += '		<embed width="400" height="400" name="plugin" src="'+strPathMovie+'" type="application/x-shockwave-flash"/>';
	strContent += '	  </object>';
	
	var SMF_CNT_DEFAULT_HEADER= '<html><head><script type="text/javascript" src="modules/templates/SMF_default/jscript/jscript_swfobject.js"></script><title>Can you Imagine</title></head><body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" onload="window.focus();">';
	var SMF_CNT_DEFAULT_FOOTER= '</body></html>';
	var printPopUp = window.open(' ', 'popimpr','status=no,directories=no, toolbar=no, location=no, width=400, height=400');	 
	printPopUp.document.write( SMF_CNT_DEFAULT_HEADER+strContent+SMF_CNT_DEFAULT_FOOTER);
	printPopUp.document.close();
}

function SMF_managePopupPrintProduct(strPathMovie){
	var printPopUp = window.open(strPathMovie, 'popimpr','status=no,directories=no, toolbar=no, location=no, width=650, height=1000');
	//printPopUp.print();
	void(0);
	//printPopUp.close();
}
