
$(function(){
	//checkFilter();
});

var paramsURL = '';
function checkFilter(){
	if( comesFromDirectLink() || comesFromAgeFilter() ){		//viene directo o viene de filtro
		writeFlashMovie();
	}else{
		redirectToFilter();
	}
}


function comesFromDirectLink(){
	if( gup2('s') == false ) return false;
	return true;
}


function comesFromAgeFilter(){
	if( (gup('fs')=='true') ) return true;
	//if( (gup('fs')=='true') && (document.referrer.indexOf('filtro-edad.html') > -1)) return true;
	return false;
}




function redirectToFilter(){
	var url = location.href;
	url = url.split('?');
	var filterURL = 'filtro-edad.html';
	var loc = document.location.toString();
	
	
	if(loc.indexOf('fs=true') > -1){
		if (loc.indexOf('?fs=true&') > -1) loc = loc.replace('?fs=true&', '?');
		else {
			if (loc.indexOf('?fs=true') > -1) loc = loc.replace('?fs=true', '');
			else if (loc.indexOf('&fs=true') > -1) loc = loc.replace('&fs=true', '');
		}	
		url = loc.split('?');
	}
	
	if(url[1] != null){
		filterURL += '?'+url[1];	
	}
	location.href = filterURL;
	
}







function writeFlashMovie(){
	var vars = {};
	var params = {};
	var attributes = {};
	var movieName = "app/MainMojito.swf";
	
	params.scale = "noScale";
	params.salign = "lt";
	params.menu = "false";
	params.wmode = "normal";
	params.allowFullScreen = "true";
	params.bgcolor = "#FFFFFF";
	params.allowscriptaccess = "always";
	
	if(getParam('movie') != null){
		movieName = 'app/' + getParam('movie') + '.swf';
	}
	
	if(getParam('wm') != null){
		params.wmode = getParam('wm');
	}
	
	movieName += location.search;
	
	swfobject.embedSWF(movieName, "flashContent", "100%", "100%", "10.0.0", "js/lib/swfobject/expressInstall.swf", vars, params, attributes);
}



/********************
 * FLASH <-> JS COMM
 ********************/
function registro(){
	c = gup('c');
	f = gup('f');
	var params = (c == '' || c == null) ? '' : '?codeMGM='+c+'&fromMGM='+f;
	var _url = 'registro.html' + params;
	var _width = 660;
	var _height = 700;
	openWindow(_url , _width , _height);
}



function modificarDatos(){
	var _url = 'modificardatosIntro.html';
	var _width = 660;
	var _height = 721;
	openWindow(_url , _width , _height);
}

function confirmarDatos(){
	var _url = 'confirmardatos.html';
	var _width = 660;
	var _height = 721;
	openWindow(_url , _width , _height);
}


/*

function sendData(){
	var flashMovie = window.opener.location.flashContent;
	flashMovie.sendUser();
}*/




