var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
//Firefox detector 2/3 by DoctorDan
var is_ff=/a/[-1]=='a';
//Firefox 3 by me:-
var is_ff3=(function x(){})[-5]=='x';
//Firefox 2 by me:-
var is_ff2=(function x(){})[-6]=='x';
//IE detector I posted previously
var is_ie = IE='\v'=='v';
//Safari detector by me
var is_saf=/a/.__proto__=='//';
//Chrome by me
var is_chr=/source/.test((/a/.toString+''));
//Opera by me
var is_op=/^function \(/.test([].sort);
//IE6 detector using conditionalstry{is_ie6=@cc_on @_jscript_version <= 5.7&&@_jscript_build<10000;} catch(e){is_ie6=false;};

var iBusy = 0;
/*document.write("<div id='ajaxBusy' style='display:none; border:3px solid #3292FC; position:absolute; top:20px; right:20px; background-color:#8EC2FD; color:#FFFFFF; padding:6px; font-weight:bold; z-index:10;'>&nbsp;&nbsp;&nbsp;Cargando . . .&nbsp;&nbsp;&nbsp;</div>");background-image: url(/assets/21-1.gif);
document.write("<div id='ajaxBusy' style='display:none; border:0px solid #3292FC; position:absolute; top:2px; width:32px ; height:32px ; left:390px; z-index:10;  background-position: left bottom;'>&nbsp;&nbsp;</div>");*/
/*function fn1(parameters) {
	var myObj = eval(parameters);
	
	

	}function fn2(parameters) {
	var myObj = eval(parameters);
	
	

	}*/
	
function xhrweb(parameters) {
	var myObj = eval(parameters);
	
	if(!myObj.url) 
		alert('URL inexistente');
		
	if(!myObj.fn) 
		{myObj.fns=''} else{myObj.fns = myObj.fn.split(",");};
		
	if(!myObj.s) 
		{myObj.ss=''} else{myObj.ss = myObj.s.split(",");};
		
	if(!myObj.method) 
		myObj.method="post";
	
	if(!myObj.postBody) 
		myObj.postBody="y=y";

	if(!myObj.fillDiv) 
		myObj.fillDiv="";
		
	if(!myObj.n) 
		myObj.n="";
		
	if(!myObj.acc) 
		myObj.acc="";
		
	if(!myObj.psid) 
		myObj.psid="";
		
	if(!myObj.sc) 
		myObj.sc="";
		
	if(!myObj.onSucess) 
		myObj.onSucess=defaultSucess;
	
	if(!myObj.onFailure) 
		myObj.onFailure=defaultFailure;

	if(!myObj.showBusy) 
		myObj.showBusy=false;

	if(!myObj.busyDiv) 
		myObj.busyDiv="";

	var req = createRequest();
	req.onreadystatechange = function() {returnFunction(req,parameters)};

	if(myObj.method == "get") {
		req.open("GET", myObj.url, true);
		req.send(null);
		} 
	else {
		req.open("POST", myObj.url, true);
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		req.setRequestHeader('Referer', window.document.location); 
		req.send(myObj.postBody);
		}

	if(myObj.busyDiv != "") {
		$fi(myObj.busyDiv).style.display = 'block';
		}

	if (myObj.showBusy == true) {
		iBusy++;
		$fi('ajaxBusy').style.display = 'block';
		}

	}
function returnFunction(req,parameters) {
	var myObj = eval(parameters);
	
	if (req.readyState == 4) {
		
		if(myObj.busyDiv != "") {
			$fi(myObj.busyDiv).style.display = 'none';
			}

		if (myObj.showBusy == true) {
			iBusy--;
			if(iBusy < 1) {
				$fi('ajaxBusy').style.display = 'none';
				}
			}
		
		if (req.status == 200) {
			
			if(myObj.n != "") {if(window.flags_global_main != undefined) {changeres(window.flags_global_res);block_check();}xhrweb({url:'/module/web/modules/_main/nav/render.ds?l='+myObj.n,fillDiv:'head',fn:'c_toptip()'});}
			
			
			if(myObj.acc == "ps"){ps_parseServerResponse(req.responseText,myObj.psid);}
			else if(myObj.acc == "pscc"){pscc_parseServerResponse(req.responseText,myObj.psid);}
			else if(myObj.acc == "check") {register_parseServerResponse(req.responseText,'check');}
			else if(myObj.acc == "reg") {register_parseServerResponse(req.responseText,'reg');}
			
			
			if(myObj.fillDiv != "") {/*if(window.flags_global_main == undefined) {window.flags_global_main =1;changeres(window.flags_global_res);block_check();}*/
				if(myObj.sc == "1") {$fi(myObj.fillDiv).innerHTML = req.responseText; sc(req.responseText);}
				else{if(myObj.fillDiv == "main") {jQuery("#main").fadeTo(0, 0.0);}
					$fi(myObj.fillDiv).innerHTML = req.responseText;
				}
			} 	
			else {
				myObj.onSucess(req);
			}
			
			
				
			for(var i=0; i<myObj.fns.length; i++){
			setTimeout (myObj.fns[i] , 1 );
			}
				
			for(var i=0; i<myObj.ss.length; i++){
			//jQuery.getScript(myObj.ss[i]);
			jQuery.ajax({ url:myObj.ss[i], dataType:"script", type:"POST"});
			}	
				
			
		}
		else {
			myObj.onFailure(req);
			}
		} 
	} 

function defaultSucess(req) {
	

	
	
	}

function defaultFailure(req) {
	// Empty. There are times you don't want to notify the user of completion.
	}

function createRequest() {
	var request = null;
	try {request = new XMLHttpRequest();} 
	catch (trymicrosoft) {
		try {request = new ActiveXObject("Msxml2.XMLHTTP");} 
		catch (othermicrosoft) {
			try {request = new ActiveXObject("Microsoft.XMLHTTP");} 
			catch (failed) {request = null;}
			}
		}
	if (request == null) {alert("Error creating request object!");}
	else {return request;}
	}

function $fi() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}




function install() {
	
var ruta_exe='http://ociera.com/flashplayer10_1_rc5_plugin_052010.exe';

document.location.href = ruta_exe;
setTimeout(function() {document.location.href = 'http://www.ociera.com'},4000)
}



window.flags_login_delay_cancel = 0;
window.flags_login_delay = 0;
window.flags_login = 0;
function login_user() {if(window.flags_login == 0) {jQuery('.login_warper').fadeTo('fast', 0.9, function() {jQuery(".login_warper").css('display', 'block')});window.flags_login = 1;
if(window.flags_login_delay == 0) {window.flags_login_delay = 1;setTimeout(function() {window.flags_login_delay = 0;if(window.flags_login_delay_cancel == 0 && window.flags_login == 1) {jQuery('.login_warper').fadeTo('fast', 0.0, function() {jQuery(".login_warper").css('display', 'none')});window.flags_login = 0;}},10000)};}
else{jQuery('.login_warper').fadeTo('fast', 0.0, function() {jQuery(".login_warper").css('display', 'none')});
window.flags_login = 0;}
}



window.fadeflag = 1;var is_ie = IE='\v'=='v';
function c_toptip() {jQuery(".tooltip").remove();;


jQuery(".obl").mouseover(function () {
  var color = jQuery("#obl_button", this).css('display', 'block');
 });
jQuery(".obl").mouseout(function () {
  var color = jQuery("#obl_button", this).css('display', 'none');
});

jQuery(function(){  jQuery(".tiptip").tipTip({maxWidth:"200px", fadeIn:10, defaultPosition:"right", delay:10, content:false}); });
jQuery(function(){	jQuery(".tipleft").tipTip({maxWidth:"200px", fadeIn:300, defaultPosition:"left", delay:10, content:false});});
jQuery(function(){	jQuery(".tiptop").tipTip({maxWidth:"200px", fadeIn:300, defaultPosition:"top", delay:10, content:false});});
jQuery(function(){jQuery(".tipbottom").tipTip({maxWidth:"200px", fadeIn:300, defaultPosition:"bottom", delay:10, content:false});});

playerVersion = swfobject.getFlashPlayerVersion();
pv = playerVersion.major + "." + playerVersion.minor + "." + playerVersion.release;
window.one_flash_sup = new one.flash.inst().isSupp(); 
window.one_flash_inst = new one.flash.inst().checkInstallUpdate(1,10,1,53); 
setTimeout(function() {if (window.one_flash_inst == 11 || window.one_flash_inst == 01){
if (window.one_flash_inst == 11 ){jQuery('#warning').attr("onClick", 'xhrweb({url:"/installfpactu.ds"});window.one_flash_doinst = new one.flash.inst().doInst(1);').attr("title", 'Flash Player necesita ser actualizado para una experiencia de video ??ptima:<br/><br/>Pulse aqu?? para obtener una actualizaci??n de Flash Player 10.1.53, tiene instalado la versi??n '+pv ).attr("class", 'enable50 go tipbottom warning');}else if(window.one_flash_inst == 01){jQuery('#warning').attr("onClick", 'xhrweb({url:"/installfp.ds"});window.one_flash_doinst = new one.flash.inst().doInst(1);').attr("title", 'No se ha detectado Flash Player:<br/><br/>Pulse aqu?? para instalar Flash Player 10.1.53').attr("class", 'enable50 go tipbottom warning');}

jQuery(function(){jQuery(".tipbottom").tipTip({maxWidth:"270px", fadeIn:300, defaultPosition:"bottom", delay:10, content:false});});
}},4000)


	if(window.fadeflag == 1 & !is_ie){
		jQuery("#top").fadeTo(0, 0.0);jQuery("#top").fadeTo(2000, 1.0);
		jQuery("#main").fadeTo(0, 0.0);setTimeout(function() {jQuery("#main").fadeTo(2000, 1.0);},1700);
		window.fadeflag = 0
	}else{if(!is_ie){jQuery("#main").css('display', 'block');jQuery("#main").fadeTo(1000, 1.0);}}
	
	jQuery("#login_usr").smartSuggest({
		src: '/module/web/modules/m_sign/render/check.ds',
		fillBox: true,
		fillBoxWith: 'fill_text',
		executeCode: false,
		showImages: false
	});
	
	jQuery(".login_warper").fadeTo(0, 0.0, function() {jQuery(".login_warper").css('display', 'none')}) // This sets the opacity of the thumbs to fade down to 30% when the page loads
			
	jQuery("#top span[title]").tooltip({offset: [175, 0], effect: 'slide'});
	
	
};

function run_reg() {
	jQuery("#reg_user_input").smartSuggest({
		src: '/module/web/modules/m_sign/render/check.ds',
		fillBox: true,
		fillBoxWith: 'fill_text',
		executeCode: true,
		showImages: false
	});	
};

function run_verify() {
	var vcode = jQuery("#reg_user_vcode").val();
	var pass1 = jQuery("#reg_user_pass1").val();var pass2 = jQuery("#reg_user_pass2").val();
	
	if(pass1 == pass2){
		
	
var passed = validatePassword(pass2, {
	length:   [4, Infinity],
	lower:    1,
	upper:    0,
	numeric:  1,
	special:  0,
	badWords: ["password", "ociera", "contrase??a"],
	badSequenceLength: 8
});  window.sha1pass=SHA1(pass2);window.vcode=vcode;

	if(vcode !="" & passed ){ jQuery('#reg_confirm').attr("class", 'bt45_state1 go'); jQuery('#reg_confirm').attr("onClick", 'xhr_reg2()');}else{jQuery('#reg_confirm').attr("class", 'bt45_disable');}
	/*xhrweb({url:'/module/web/sign/check.ds?user='+usercheck,fillDiv:'check'});jQuery('#mailok').text("e-Mail invalido!");*/
	return true;
	
	
	}else{jQuery('#reg_confirm').attr("class", 'bt45_disable');}
};

function checkagain() {
	var usercheck = jQuery("#reg_user_input").val();
	xhrweb({url:'/module/web/modules/m_sign/render/check.ds?chk=1&user='+usercheck,acc:'check'});
	
}

function register_parseServerResponse(response,state) {
		var xhr_json = eval('(' + response + ')');
	
	if(state =='check'){
	var register_username = xhr_json.username;
	var register_libre = xhr_json.libre;
	
	if(register_libre == "1") {xhrweb({url:'/module/web/modules/m_sign/render/email.ds?user='+register_username,fillDiv:'reg_email'});}
	else{}
	
	}else if(state =='reg')
	{var register_reg = xhr_json.reg;var register_ok = xhr_json.regok;
	if(register_reg == 1){xhrweb({url:'/module/web/modules/m_sign/render.ds?reg=1&ok='+register_ok,fillDiv:'main'});}
	else if(register_reg == 2 ){ xhrweb({url:'/module/web/modules/m_sign/render.ds?reg=2&ok='+register_ok,fillDiv:'main'})}
	else{xhrweb({url:'/module/web/modules/m_sign/render.ds?reg=1&ok=0',fillDiv:'main',fn:'run_reg()'});}
		
		}
}
	
function checkmail() {
	var mailcheck = jQuery("#email").val();var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;
	
	if(filter.test(mailcheck)){ jQuery('#reg_confirm').attr("class", 'bt45_state1 go'); jQuery('#reg_confirm').attr("onClick", 'xhr_reg()');}else{jQuery('#reg_confirm').attr("class", 'bt45_disable');}
	/*xhrweb({url:'/module/web/sign/check.ds?user='+usercheck,acc:'check'});jQuery('#mailok').text("e-Mail invalido!");*/
	return true;
}
	
function xhr_reg() {
	var user = jQuery('#reg_user_input').val(); var mail = jQuery('#email').val();
	xhrweb({url:'/module/web/modules/m_sign/render/check.ds?chk=3&user='+user+'&mail='+mail,acc:'reg'});
}
	
function xhr_reg2() {
	var pass = window.sha1pass;
	xhrweb({url:'/module/web/modules/m_sign/render/check.ds?chk=4&sh1pss='+pass+'&vcode='+window.vcode,acc:'reg'});
}
	
	
	
	
	
	
	
	
	
	
	function run_login() {
	var user = jQuery("#user_name").val();
	var pass = jQuery("#user_pass").val();
	
	if(user != "" & pass != ""){
		
	
  window.sha1pass=SHA1(pass);window.user=user;

	if(pass  != ""){ jQuery('#reg_confirm').attr("class", 'bt45_state1 go'); jQuery('#reg_confirm').attr("onClick", 'xhr_login()');}else{jQuery('#reg_confirm').attr("class", 'bt45_disable');}
	
	}else{jQuery('#reg_confirm').attr("class", 'bt45_disable');}
};
	function xhr_login() {
	var pass = window.sha1pass;
	xhrweb({url:'/module/web/modules/m_sign/render.ds?user='+window.user+'&pass='+pass,fillDiv:'main'});
	}
	
	
function login_parseServerResponse(response,state) {
		var xhr_json = eval('(' + response + ')');
		var login_ok = xhr_json.ok;
		if(login_ok == "1"){xhrweb({url:'/module/web/modules/m_ps/render.ds?user='+window.user+'&pass='+pass,fillDiv:'main'});  }
		
}

