function pop_up (pagina) {
var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=855, height=420, top=185, left=200";
window.open(pagina,"",opciones);
}
//This function get the value of the cookie
function getCookie(name){
  var cname = name + "=";               
  var dc = document.cookie;
  if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
    if (begin != -1) {           
      begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}

//This function set the value of the coockie
function setCookie(name, value, expires) {
  document.cookie= name + "=" + escape(value) + 
  ((expires == null) ? "" : "; expires=" + expires);
}

function lanzar_pop_up () { 
//The variable tiempo contains a time in seconds. After this time expires, the cookie will be deleted. By default we´ve put 1 year using:(60*60*24*365).
var tiempo= (new Date( )).getTime( ) + (60*60*24*365); 
//The variable caduca contains exactly the same value that tiempo, but in a different format, in order to internet explorer recognice it.
var caduca= (new Date(tiempo)).toUTCString( );
//num_visitas is the name of the cookie.
//n is a variable that takes the value of the cookie for the rest of the function.
var n = getCookie('num_visitas'); 

//alert("hola");

	if ( n == null ) {
		n = 1; 
	}
	else{
		n++;
	}
	setCookie ('num_visitas', n, caduca);
	//In the following condition, if the user of the website, has enter less than 3 times, the pop-up will be shown.
	if ( n < 3 ){
		//pop_up('http://www.artyco.com/Fiat/GestorEncuestas/asp/GuardarEncuesta.asp?idMarca=3 ');

		return n;		

		//$("#encuesta").overlay({});
	}else{
		//alert("HEY");
		return 20;

		}
}
