function toBeLogged(el){
	return hs.htmlExpand(el, { objectType: 'ajax'} );
}

function displayVideoPersonaggi(){
	var video_pers = document.getElementById('personaggi-video');
	return hs.htmlExpand(video_pers, {
		objectType: 'iframe',
		allowSizeReduction: false,
		wrapperClassName: 'no-footer',
		preserveContent: true, width: 500, height:332
	});
}

function displayVideoModal(id){
	var video = document.getElementById(id);
	return hs.htmlExpand(video, {
		objectType: 'iframe',
		allowSizeReduction: false,
		wrapperClassName: 'no-footer',
		preserveContent: true, width: 500, height:385
	});
}

// flash header
function displayError(error){
	jQuery("#" + error).show(function callback(){
		jQuery(document).click(function(){
			jQuery("#" + error).hide(200);
		});
	});
}

//shoutbox
function checkShout(){
	
	var tobefiltered = Array('@','_at_','(at)',' at ','-at-','.at.');
	var maxlength = 15;
	
	if(document.formaef._AEFShoutBox_WAR_AEFShoutBox_INSTANCE_F1eF_messaggio.value.length > 0){
		var typedText = document.formaef._AEFShoutBox_WAR_AEFShoutBox_INSTANCE_F1eF_messaggio.value;
		jQuery("#link-send-msg").css("visibility","visible");
		
		for(i=0;i<tobefiltered.length;i++){
			if(typedText.indexOf(tobefiltered[i]) != -1)
			jQuery("#link-send-msg").css("visibility","hidden");
		}
		var words = typedText.split(" ");
		for(i=0;i<words.length;i++){
			if(words[i].length > maxlength)
				jQuery("#link-send-msg").css("visibility","hidden");
		}
		
	}
	else
		jQuery("#link-send-msg").css("visibility","hidden");
}
function sendShout(){
	if(document.formaef._AEFShoutBox_WAR_AEFShoutBox_INSTANCE_F1eF_messaggio.value.length > 0)
		document.formaef.submit();
		
}

if(swfobject.hasFlashPlayerVersion("6.0.0")) {
    var fn = function(){
        var att = {
            data: "/angelsfriends/resources/swf/header.swf",
            width: "958",
            height: "300"
        };
        var par = {
            allowScriptAccess: "always",
			wmode: "transparent"
        };
        var id = "header-flash";
        var myObject = swfobject.createSWF(att, par, id);
    };
    swfobject.addDomLoadEvent(fn);
	swfobject.createCSS("#header-flash","outline:none");
}

function validateRegistration(form){
	var nicknameAllowedChars = /^[a-zAZ0-9\-\_]{4,15}$/;
	if (!(nicknameAllowedChars.test(form.nickname.value))) {
		jQuery("#td-nickname-reg").prepend('<div class="wrap-box-error"><div class="box-error-reg" id="reg-err-nickname2"><p><b>Attenzione:</b> il nickname inserito contiene caratteri non validi</p></div></div>');
		jQuery("#reg-err-nickname2").show(function callback(){
			jQuery(document).click(function(){
				jQuery("#reg-err-nickname2").hide(200);
			});
		});
		return false;
	}
	
	form.submit();
}


// onload scripts
jQuery(document).ready(function(){
	
	//var linkTrailer = 'http://www.youtube.com/v/' + trailerYouTubeCode + '&hl=it&fs=0&rel=0&color1=0x006699&color2=0x54abd6&autoplay=1';
	//jQuery("a#link-trailer").attr("href",linkTrailer);
	
	//displayError("log-home-err-nickname");
	
	jQuery('#privacy-accept').click(function(){
		if(jQuery('#privacy-accept:checked').val() != undefined)
			jQuery('#sbmt-registration').show(300);
		else
			jQuery('#sbmt-registration').hide(250);
	});
	
	
	// change pwd
	jQuery("#but-chng-pwd").click(function(){
		
		if(jQuery("#chngpwd1").val() != jQuery("#chngpwd2").val()){
			jQuery("#changepwd-err-pwd").show();
			return false;
		}else{
			jQuery("#changepwd-err-pwd").hide();
			document.formpwd.submit();
		}
		
	});
	
	// chiusura alert errore
	jQuery(".box-fumetto-down,.box-fumetto-up").click(function(){
		jQuery(this).hide(200);
	});
	
	// switch avatar terreno/sempiterno
	jQuery("#link-avatar-sempiterno").click(function(){
		jQuery("#link-avatar-terreno").removeClass("tab-on");
		jQuery(this).addClass("tab-on");
		jQuery("#b-b-p-c-a-terreno").hide();
		jQuery("#b-b-p-c-a-sempiterno").show();
		var link_sempiterno = jQuery("#link-avatar-sempiterno").attr("rel");
		jQuery("#link-modifica-avatar").attr("href",link_sempiterno);
	});
	jQuery("#link-avatar-terreno").click(function(){
		jQuery("#link-avatar-sempiterno").removeClass("tab-on");
		jQuery(this).addClass("tab-on");
		jQuery("#b-b-p-c-a-sempiterno").hide();
		jQuery("#b-b-p-c-a-terreno").show();
		var link_terreno = jQuery("#link-avatar-terreno").attr("rel");
		jQuery("#link-modifica-avatar").attr("href",link_terreno);
	});
	
});
