function showLogin(){
	body_height=document.getElementById('page').offsetHeight;
	//alert(body_height);
	document.getElementById('boxLogin').style.display = 'block';
	document.getElementById('cover').style.display = 'block';
	//document.getElementById('log').focus();
	if(body_height<768){
		document.getElementById('cover').style.height = 1024+'px';
	} else {
		document.getElementById('cover').style.height = body_height+'px';
	}
}

function showLogin1(){
	body_height=document.getElementById('page').offsetHeight;
	//alert(body_height);
	document.getElementById('boxLogin').style.display = 'block';
	document.getElementById('cover').style.display = 'block';
	//document.getElementById('log').focus();
	if(body_height<768){
		document.getElementById('cover').style.height = 1024+'px';
	} else {
		document.getElementById('cover').style.height = body_height+'px';
	}
}
function showWrapperFromLogin(){
	document.getElementById('boxLogin').style.display = 'none';
	document.getElementById('cover').style.display = 'none';
}
function showWrapperFromRegister(){ 
	document.getElementById('boxSendtofriend').style.display = 'none';
	document.getElementById('cover').style.display = 'none';
}

function showSendtofriend(){
	body_height=document.getElementById('page').offsetHeight;
	//alert(body_height);
	document.getElementById('boxSendtofriend').style.display = 'block';
	document.getElementById('cover').style.display = 'block';
	document.getElementById('your_email').focus();
	if(body_height<768){
		document.getElementById('cover').style.height = 1024+'px';
	} else {
		document.getElementById('cover').style.height = body_height+'px';
	}
}

function recommend_this_link(my_text){
	body_height=document.getElementById('page').offsetHeight;
	//alert(body_height);
	document.getElementById('boxSendtofriend1').style.display = 'block';
	document.getElementById('cover').style.display = 'block';
	//document.getElementById('message_ok').style.display="none;"
	document.getElementById('your_email').focus();
	new_text = my_text.split("<br />");
	var new_text1 = '';

	for(i=0;i<new_text.length;i++){
		if(i > 0){
			new_text1  = new_text1 + "\n" + new_text[i];
		}else{
			new_text1  = new_text[i];
		}
	}
	document.getElementById('message').value = new_text1;
	if(body_height<768){
		document.getElementById('cover').style.height = 1024+'px';
	} else {
		document.getElementById('cover').style.height = body_height+'px';
	}
}
function clean_input(my_value){
	if(my_value == "email@fai.fr"){
		document.getElementById('email_feed').value = "";
	}
}

function display_badge(user_nicename){
	var array_fields = new Array('badge_name', 'amount', 'title_length', 'description_length', 'sort_order', 'show_rating', 'show_thumbnail', 'css_style');
	for(i=0;i<array_fields.length;i++){
		field = array_fields[i];
		if(i == 0){
			var badge_name = document.getElementById(field).value;
		}
		if(i == 1){
			var amount = document.getElementById(array_fields[i]).value;
		}
		if(i == 2){
			var title_length = document.getElementById(array_fields[i]).value;
		}
		if(i == 3){
			var description_length = document.getElementById(array_fields[i]).value;
		}
		if(i == 4){
			var sort_order = document.getElementById(array_fields[i]).value;
		}
		if(i == 5){
			if(document.getElementById(array_fields[i]).checked == true){
				var show_rating = 1;
			}else{
				var show_rating = 0;
			}
		}
		if(i == 6){
			if(document.getElementById(array_fields[i]).checked == true){
				var show_thumbnail = 1;
			}else{
				var show_thumbnail = 0;
			}
		}
		if(i == 7){
			var css_style = document.getElementById(array_fields[i]).value;
		}
	}
	
badge_value = '<div class="favoris_badge">'+"\n"+'<div class="favoris_badge_body">'+"\n"+'<div id="favoris_badge_header" class="favoris_badge_header"><a href="http://www.charme.com/favoris/user/'+user_nicename+'/">'+badge_name+'</a></div>'+"\n"+'<div id="favoris_badge_item">&nbsp;</div><script type="text/javascript" src="http://www.charme.com/favoris/badge/admin/badge.jss&amount='+amount+'&title='+title_length+'&description='+description_length+'&thumbnail='+show_thumbnail+'&rating='+show_rating+'&order='+sort_order+'"></script>'+"\n"+'<div class="favoris_badge_footer"><a href="http://www.charme.com/favoris/">Powered by favoris</a></div>'+"\n"+'</div></div>'+"\n"+'<style type="text/css">'+"\n"+'<!--'+"\n"+css_style +"\n"+'--></style>';

document.getElementById('badge_textarea').value = "";
document.getElementById('badge_textarea').value = badge_value;
}

function display_cloud(user_nicename){
	var array_fields = new Array('cloud_name', 'amount', 'font_size', 'Cloud.Fontcolor', 'Cloud.Shader_1', 'Cloud.Shader_2');
	for(i=0;i<array_fields.length;i++){
		if(i == 0){
			var cloud_name = document.getElementById(array_fields[i]).value;
		}
		if(i == 1){
			var amount = document.getElementById(array_fields[i]).value;
		}
		if(i == 2){
			var font_size = document.getElementById(array_fields[i]).value;
		}
		if(i == 3){
			exp_ = document.getElementById(array_fields[i]).value.split("#");
			var CloudFontcolor = exp_[1];
		}
		if(i == 4){
			exp_ = document.getElementById(array_fields[i]).value.split("#");
			var CloudShader_1 = exp_[1];
		}
		if(i == 5){
			exp_ = document.getElementById(array_fields[i]).value.split("#");
			var CloudShader_2 = exp_[1];
		}
	}
	
badge_value = '<div class="favoris_cloud"><div class="favoris_cloud_body"><div class="favoris_cloud_header"><b><a href="http://www.charme.com/favoris/user/'+user_nicename+'/">'+cloud_name+'</a></b></div><div class="favoris_cloud_item" id="favoris_cloud_item"><script type="text/javascript" src="http://www.charme.com/favoris/mycloud/'+user_nicename+'/cloud.js&amp;logo=0&amp;fontsize='+font_size+'&amp;cloudsize='+amount+'&amp;fontcolor='+CloudFontcolor+'&amp;colorbegin='+CloudShader_1+'&amp;colorend='+CloudShader_2+'"></script></div><div class="favoris_cloud_footer">I am <a href="http://www.charme.com/favoris/user/'+user_nicename+'/">'+user_nicename+'</a>  this is on <a href="http://www.charme.com/favoris/"><img src="http://www.charme.com/favicon.ico" /> Charme.com</a></div></div></div><style type="text/css">html .favoris_cloud,html .favoris_cloud *{background-color:transparent;background-image:none;border:0;float:none;font-family:arial, sans-serif;font-style:normal;font-variant:normal;font-weight:400;height:auto;line-height:1.3em;list-style:none;position:static;text-align:center;text-decoration:none;text-indent:0;text-transform:none;visibility:visible;white-space:normal;width:auto;word-spacing:normal;z-index:auto;margin:0;padding:0;}html .favoris_cloud{font-size:11px;text-align:center;}html .favoris_cloud .favoris_cloud_header *{font:bold 22px "trebuchet ms";}html .favoris_cloud .Small{font-family:Arial;font-size:100%;margin:8px 4px;}html .favoris_cloud .Medium{font-family:arial,sans-serif;font-size:170%;margin:8px 4px;}html .favoris_cloud .Large{font-family:"trebuchet ms",arial,sans-serif;font-size:240%;margin:1px 4px;}html .favoris_cloud .XLarge{font-family:"trebuchet ms",sans-serif;font-size:240%;margin:1px 4px;}html .favoris_cloud font{font-size:inherit !important;}html .favoris_cloud a,html .favoris_cloud a:hover{text-decoration:none;color:#'+CloudFontcolor+';}html .favoris_cloud_footer{font-weight:700;padding:15px 0;}html .favoris_cloud_footer img{border:0;vertical-align:bottom;}</style>';

document.getElementById('cloud_textarea').value = "";
document.getElementById('cloud_textarea').value = badge_value;
}

function search_href(s_value){
	document.location.href='/favoris/list/'+s_value+"/";
}

function readCookie() {
	name = "years18";
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function show18yearsBox(){
	myCookie = readCookie();
	if(myCookie == 1){
		document.getElementById('box18years').style.display = 'none';
		document.getElementById('cover').style.display = 'none';
		document.getElementById('page').style.display = 'block';
		var date = new Date();
		date.setTime(date.getTime()+(365*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}else{
		document.getElementById('box18years').style.display = 'block';
		body_height=document.getElementById('page').offsetHeight;
		document.getElementById('cover').style.display = 'block';
		if(body_height<768){
			document.getElementById('cover').style.height = 1024+'px';
		} else {
			document.getElementById('cover').style.height = body_height+'px';
		}
	}
}

function createCookie(name,value,days) {
	if(document.getElementById('checkbox18years').checked == true){
		if (days) {
			document.getElementById('box18years').style.display = 'none';
			document.getElementById('cover').style.display = 'none';
			document.getElementById('page').style.display = 'block';
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
}
