function check_email(str) {
at=str.indexOf('@');
dot=str.indexOf('.',at);
last_at=str.lastIndexOf('@');
last_dot=str.lastIndexOf('.');
if(at>0 && dot>0 && (dot-at)>1 && str.length-dot>1 && last_dot==dot && last_at==at && str.length>5) { valid='1' }
else { valid='0'; }
return valid
}
function show_and_hide(id1,id2) {
	document.getElementById(id1).style.display='block';
	document.getElementById(id2).style.display='none';
}
function pop_up(url,name,width,height) {  
	w = (document.body.clientWidth - width)/2;
  h = (document.body.clientHeight)/2;
	window.open(url,name,'width=' + width + ',height=' + height + ',menubar=no,left='+w+',top='+h+',screenX='+w+',screenY='+h+'');
}
function write_editor(text_to_write) {
	parent.frame_editor.document.write(text_to_write);
}
function show_hide(id) {
	if(document.getElementById(id).style.display == 'none') { document.getElementById(id).style.display = 'block'; }
	else { document.getElementById(id).style.display = 'none'; }
}
function show_hide_check(id) {
	
	alert('You must login to add a review.');
	}
function increase_height(id) {
	var h = parseInt(document.getElementById(id).style.height);
	var h = h + 50;
	document.getElementById(id).style.height = h + 'px';
}
function decrease_height(id) {
	var h = parseInt(document.getElementById(id).style.height);
	if(h > 50) {
	var h = h - 50;
	document.getElementById(id).style.height = h + 'px';
	}
	else {
		alert('Minimum height reached');
	}
}
function add_emot(id_t,emot) {
	document.getElementById(id_t).value = document.getElementById(id_t).value + emot;
	document.getElementById(id_t).focus();
}
function over(id,color) {
	document.getElementById(id).style.backgroundColor = "#" + color;
}
function out(id) {
	document.getElementById(id).style.backgroundColor = '';
}
function over_u(id) {
	document.getElementById('usermenu' + id).style.backgroundColor = "#83c274";
	document.getElementById('usermenu' + id).style.padding = "2";
	document.getElementById('userlink' + id).style.color="#ffffff";
	document.getElementById('userlink' + id).style.fontWeight="bold";
}
function out_u(id) {
	document.getElementById('usermenu' + id).style.backgroundColor = "";
	document.getElementById('usermenu' + id).style.padding = "2";
	document.getElementById('userlink' + id).style.color="#000000";
	document.getElementById('userlink' + id).style.fontWeight="normal";
}
function show(id) {
	document.getElementById(id).style.display='block';
}
function hide(id) {
	document.getElementById(id).style.display='none';
}
function click_search(s_element) {
	if(s_element == 'all') {
	document.getElementById('quizz').value='yes';
	document.getElementById('shopping').value='yes';
	document.getElementById('answers').value='yes';
	document.getElementById('tips').value='yes';
	document.getElementById('my_looks').value='yes';
	}
	else {
	document.getElementById('quizz').value='';
	document.getElementById('shopping').value='';
	document.getElementById('answers').value='';
	document.getElementById('tips').value='';
	document.getElementById('my_looks').value='';
	
	document.getElementById(s_element).value='yes';
	}
}
function browser_detection() {
	browser_version = parseInt(navigator.appVersion);
	browser_type = navigator.appName;
	if (browser_type == "Microsoft Internet Explorer" && (browser_version >= 4)) {
   var type='ie';
	} 
	else {
   var type='other';
	}
	return type;
}
function hover_star(nr,star) {
	for(i=1;i<=nr;i++) {
  	document.getElementById("star"+i).src='/images/over_'+star+'.gif';
  }
}
function out_star(nr,star) {
	for(i=1;i<=nr;i++) {
  	tp=document.getElementById('star'+i).name;
  	document.getElementById("star"+i).src='/images/'+tp+'_'+star+'.gif';
  }
}
function search_type(type) {
	types = new Array('web','encyclopedia','store','all','videos');
  for(i=0;i<types.length;i++) {
		document.getElementById('search_'+types[i]).style.cursor='pointer';
		document.getElementById('search_'+types[i]).style.fontWeight='';
		document.getElementById('search_'+types[i]).onClick='search_type("'+types[i]+'")';
  }  
	document.getElementById('search_'+type).style.cursor='';
	document.getElementById('search_'+type).style.fontWeight='bold';
	document.getElementById('search_'+type).onClick='';
  
  document.getElementById('search_type').value=type;
}
function check_search() {
	if(document.getElementById('search_type').value=='web') {
  	document.getElementById('search_form').target='_blank';
  }
  else {
  	document.getElementById('search_form').target='';
  }
	el=document.getElementById('search_keyword');
	if(el.value.length<3) {
  	alert('Your keyword has to be at least 3 characters');
    el.focus();
    return false;
  }
}

function changeValue(id) {
	d=document; el=d.getElementById(id);
	if(!el.oldValue) {
  	el.oldValue=el.value;
  }
  val=el.oldValue;
  if(el.value==el.oldValue) {
    el.focus();
  	el.value='';
    el.onblur=function() { returnValue(id) };
  }
}
function returnValue(id) {
	d=document; el=d.getElementById(id);
  if(el.value=='') el.value=el.oldValue;
}