// Form validator
function checkform()
{
if (!document.MyForm.guest)
{
		var box = new Array()
		box[0] = document.MyForm.your_name;
		box[1] = document.MyForm.your_email;
		box[2] = document.MyForm.rec_name;
		box[3] = document.MyForm.rec_email;
		box[4] = document.MyForm.comments;
		if (!box[0].value) {alert('Nem adta meg a nevét!'); box[0].focus(); box[0].select();box[0].style.border='1px solid #EB7B7B'; return false;}
		if (!box[1].value) {alert('Nem adta meg az emailcímét!'); box[1].focus();	box[1].style.border='1px solid #EB7B7B'; return false;}		
		if (!box[4].value) {alert('Nem írt semmit a képeslapra!'); box[4].focus();	box[4].style.border='1px solid #EB7B7B'; return false;}		
	if (!document.MyForm.rec)
	{
		//if (!box[2].value) {alert('Nem adta meg a címzett nevét!'); box[2].focus();	box[2].style.border='1px solid #EB7B7B'; return false;}		
		//if (!box[3].value) {alert('Nem adta meg a címzett emailcímét!'); box[3].focus();	box[3].style.border='1px solid #EB7B7B'; return false;}		
	}
		apos=box[1].value.indexOf('@')
		dotpos=box[1].value.lastIndexOf('.')
		if (box[1].value == '' || apos<1 || dotpos-apos<2)
		{
		alert('Hibás a feladó emailcíme!')
		box[1].focus();
		return;
		}
		//apos=box[3].value.indexOf('@')
		//dotpos=box[3].value.lastIndexOf('.')
		//if (box[3].value == '' || apos<1 || dotpos-apos<2)
		//{
		//alert('Hibás a címzett emailcíme!')
		//box[3].focus();
		//return;
		//}
		/*if (document.MyForm.output.value)
		{
		document.MyForm.output.value = true;
		}*/
		return true;
}
}

function checkSignform()
{
		var box = new Array()
		box[0] = document.SignForm.username;
		box[1] = document.SignForm.email;
		box[2] = document.SignForm.password;
		box[3] = document.SignForm.password2;
		box[4] = document.SignForm.sum;
		if (!box[0].value) {alert('Nem adta meg a felhasználónevét!'); box[0].focus();	box[0].style.border='1px solid #EB7B7B'; return false;}		
		if (!box[1].value) {alert('Nem adta meg az emailcímét!'); box[1].focus();	box[1].style.border='1px solid #EB7B7B'; return false;}		
		if (!box[2].value) {alert('Üresen maradt a jelszómező!'); box[2].focus();	box[2].style.border='1px solid #EB7B7B'; return false;}		
		if (!box[3].value) {alert('Üresen maradt a jelszómező!'); box[3].focus();	box[3].style.border='1px solid #EB7B7B'; return false;}		
		if ((box[2].value) != (box[3].value)) {alert('Nem egyezik a két jelszó!'); box[2].focus();	box[2].style.border='1px solid #EB7B7B'; return false;}		
		if (!box[4].value) {alert('Nem végezte el az ellenőrző műveletet!'); box[4].focus();	box[4].style.border='1px solid #EB7B7B'; return false;}		
		apos=box[1].value.indexOf('@')
		dotpos=box[1].value.lastIndexOf('.')
		if (box[1].value == '' || apos<1 || dotpos-apos<2)
		{
		alert('Hibás az emailcím!')
		box[1].focus();
		return;
		}
		if (document.SignForm.output.value)
		{
		document.SignForm.output.value = true;
		}	
}


 function submit_confirm(txt,url)
 {
   var txt;
   var url;
   var confirmSub = confirm(txt);
   
   if (confirmSub)
   {
     window.location = url;
   }
   else
   {
     return false;
   }
 }
 
 //------------------------------
 // Function: no_favourites()
 // Desc: Pop up notification
 //------------------------------

 function no_favourites(txt)
 {
   var txt;
   alert(txt);
 }
 
 // Function: selectall()
 // Desc: Checks/unchecks boxes

 function selectAll()
 {
   for (var i=0;i<document.MyForm.elements.length;i++)
   {
     var e = document.MyForm.elements[i];

     if ((e.name != 'log') && (e.type=='checkbox'))
     {
       e.checked = document.MyForm.log.checked;
     }
   }
 }
 
 // Function: add_bb_code()
 // Desc: Adds BB code to comments

 function add_bb_code(code)
 {
   document.MyForm.comments.value=document.MyForm.comments.value+code;
   document.MyForm.comments.focus();
   return;
 }
 
 // Function: count_down()
 // Desc: Counts text in textarea
 
 function count_down(field,countfield,maxlimit)
 {
   if (field.value.length > maxlimit)
   {
     field.value = field.value.substring(0, maxlimit);
   }
   else
   {
     countfield.value = maxlimit - field.value.length;
   }
 }
 
 // Function: popWindow()
 // Desc: Pop up window

 function popWindow(URL,LEFT,TOP,WIDTH,HEIGHT,SCROLLBARS,RESIZE)
 {
   day = new Date();
   id = day.getTime();
	 URL = "http://www.regikepeslapok.hu/" + URL;
   
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=" + SCROLLBARS + ",location=0,statusbar=0,menubar=0,left=" + LEFT + ",top=" + TOP + ",screenX=0,screenY=0,resizable=" + RESIZE + ",width=" + WIDTH + ",height=" + HEIGHT + "');");
 }
 
 // Function: add_emoticon_window()
 // Desc: Adds emoticon to comments

 function add_emoticon_window(code)
 {
   opener.document.MyForm.comments.value += ' ' + code + ' ';
 }
 
 
 
 //headerből átemelve
var persistmenu="no" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<link href="inc/menu.css" rel="stylesheet" type="text/css">');
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate
