/*
 * Funciones de pupups
 */

var popup_actual= 'popupw';
var popup_context= 'popupcontext';
var dgris = 'dgris'; 


function show_popup(id ,w, h, posX, posY, medidaPos, context){
   	try {              
   		popup_actual= id; 
        popup_context = context;
        // Habilitamos el modal
        putModal();
        
        if (medidaPos == '%')
        {
        	var y = document.documentElement.clientHeight;
            var x = document.documentElement.clientWidth;            
        	posX = ((x * posX) / 100).round(); 
        	posY = ((y * posY) / 100).round();
        }
                        
        $(id).setStyles({
        	opacity: 100,
    		height: h, 
    		width: w,  
    		left: posX,
    		zIndex: 800,
    		top: posY
        });       
        	
	    } catch(e){	
	        alert('Error JavaScript: ' + e.message);	
	    }
}

function close_popup() {
	
	    try {           
	    	var size =  $(popup_actual).getSize();
	    	var pos = $(popup_actual).getPosition(); 
	    	var dura = 500;
	    	if (Browser.Engine.gecko) dura = 300;
	    	var myEffect = new Fx.Morph(popup_actual, 
	    				{
	    					duration: dura, 
	    					transition: Fx.Transitions.Sine.easeOut,
	    					onComplete: function() 
	    					 {
	    						$(popup_context).innerHTML = '';
	    						popModal();
	    					 }
	    				}
	    	); 
			myEffect.start({
				'opacity': 0,
				'height': [size.y,0], 
				'width': [size.x,0],  
				'left': [pos.x,0],				
				'top': [pos.y,0]
			});
        	
        	
	    }catch(e){	
	        alert('Error JavaScript: ' + e.message);	
	    }	
}


function putModal(){
    try {
      	
       if (document.documentElement.clientHeight < document.documentElement.scrollHeight){
            var y = document.documentElement.scrollHeight;
            var x = document.documentElement.scrollWidth;
        }// no hi ha scroll
        else{
            var y = document.documentElement.clientHeight;
            var x = document.documentElement.clientWidth;
        }	
       
	    $('dgrisIframe').style.height = y + 'px';
	    $('dgrisIframe').style.width = x + 'px';
	    $('dgrisIframe').style.zIndex = 500;	    
       	$(dgris).style.height = y + 'px';
        $(dgris).style.width = x + 'px';
        $(dgris).style.display = 'block';
        $(dgris).setOpacity(0.7); // dgrisIframe
        $(dgris).style.zIndex = 500;
        
    }catch(e){
        alert('Error JavaScript: ' + e.message);
    }
}
	
function popModal(){
    try{    	
    	$(dgris).style.display = 'none'; 
    }catch(e){
       alert('Error JavaScript: ' + e.message);
    }
}

function _nnEventTrack(_nnClickURL)
{
	var _nnCI = "es-neonoticias";
	var _nnCG = "0";
	var _nnCC = "uk"; /* country code */
	var _nnLP = location.protocol.indexOf('https')>-1?'https:':'http:';
	var _nnRP = escape(window.location);
	var _nnND = _nnLP + '//secure-' + _nnCC + '.imrworldwide.com/';
	var _nnPixel = new Image(1,1);
	var _nnParams = "rnd=" + (new Date()).getTime() + "&ci=" + _nnCI + "&cg=" + _nnCG;
	_nnParams += "&si=" + escape(_nnClickURL) + "&rp=" + _nnRP;
	_nnPixel.src = _nnND + "cgi-bin/m?" + _nnParams;
	
	/*
	 * Agregamos el google analytics pageTracker._trackPageview("/pagefilename1");
	 * */
	try {		
		pageTracker._trackPageview(_nnClickURL);
	} catch(err) {}
	
}