/*
 * mefiblog
 * globális javascript
 * Mefi (c) 2009
 */ 

//
// addLoadEvent - Simon Willison ötlete alapján
//
function addLoadEvent(func) {	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		  oldonload();
		  func();
		}
	}
}

//
// kommmentelési dolgok
//
function ShowName(){
  document.getElementById("name_t").style.display = "";
  document.getElementById("name_c").style.display = "none";
  document.getElementById("name_c_1").style.display = "";
}
function HideName(){
  document.getElementById("name_t").style.display = "none";
  document.getElementById("name_c").style.display = "";
  document.getElementById("name_c_1").style.display = "none";
}
function ShowCodes(){
  document.getElementById("codes_t").style.display = "";
  document.getElementById("codes_c").style.display = "none";
}
function HideCodes(){
  document.getElementById("codes_t").style.display = "none";
  document.getElementById("codes_c").style.display = "";
}
function bigFonts(){
  document.getElementById("komm_form").style.fontSize = "36px";
}
function bigArea(){
  document.getElementById("komm_form").rows = document.getElementById("komm_form").rows+5;
}
function TextStyle(style){
  document.newkomm.komm.value+='<'+style+'></'+style+'>';
}
function Email(){
  var email  = prompt("Add meg az e-mail címet (a @ [kukac]-ként jelenik meg!):","");
  var szoveg = prompt("Add meg a nevet:","");
  document.newkomm.komm.value+='[email='+email+']'+szoveg+'[/email]';
}
function commentYouTube(){
  var youTubeWWW = prompt("Add meg a YouTube-videó linkjét (http://-rel):","");
  var youTubeURL = youTubeWWW.replace("www.","");
  var youTubeWID = youTubeURL.substring(27);
  var youTubeCID = youTubeWID.substring(0,11);  
  document.newkomm.komm.value+='[youtube='+youTubeCID+']';
}
function ReplyComment(kommentid,kommentname){
  document.newkomm.komm.value+='[re='+kommentid+']'+kommentname+'[/re]: ';
  document.newkomm.komm.focus();
}
function submitForm(){
  if((document.newkomm.name.value.length > 1) && (document.newkomm.email.value.length > 1) && (document.newkomm.email.value.indexOf("@") > -1) && (document.newkomm.komm.value.length > 1)){
    document.getElementById("post_btn").style.display = "none";
    document.getElementById("post_img").style.display = "block";
	return true;
    } else {
  	alert("Egy szükséges mezőt nem töltöttél ki!");
	return false;
    }
}
 function saveComment(id,comm,exp){
    document.cookie = 'komment_'+id+'='+encodeURIComponentNew(comm)+'; expires='+exp+' UTC; path=/'
 }
 
function makeGravatarBigger(gravatarID){
	document.getElementById(gravatarID).style.width = "80px";
	document.getElementById(gravatarID).style.height = "80px";
}

function makeGravatarSmaller(gravatarID){
	document.getElementById(gravatarID).style.width = "40px";
	document.getElementById(gravatarID).style.height = "40px";
}