
function put_link_to_the_top() {
 document.write("<p style='border-bottom: 1px dotted #cccccc; text-align: right; margin: 0px; margin-top: 5px;'><a href='#top' class=bottom_nav>az&nbsp;oldal&nbsp;tetejére&nbsp;<img src='img/menu/arrow_top.jpg' width=10 height=10 hspace=5 vspace=0 border=0>&nbsp;</a></p>");  
}

function put_link_to_the_top_in_admin_area() {
 document.write("<p style='border-bottom: 1px dotted #cccccc; text-align: right; margin-right: 10px; margin-bottom: 10px;'><a href='#top' class=bottom_nav>az&nbsp;oldal&nbsp;tetejére&nbsp;<img src='../../img/menu/arrow_top.jpg' width=10 height=10 hspace=0 vspace=0 border=0>&nbsp;</a></p>");  
}


function EmailValidation(email) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
return (true)
}
alert("A beírt e-mail cím nem helyes!")
return (false)
} // end of EmailValidation

/*
// E-MAIL VALIDATOR

Copyright 2005, 4word systems
All rights reserved.

This software may not be reproduced or distributed in any form without the express 
written consent of 4word systems or it's designee.

Revision 1.1:  20050729 Added underscore to list of valid characters
*/


function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
	return false;
    }
    return true;
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}

//end of e-mail validation functions

function CheckFormMandatoryFields(formobj){

//a következő két változót abban a file-ban kell deklarálni, ahonnan meghívjuk a függvényt
						// Enter name of mandatory fields
	//	var fieldRequired = Array("name", "email", "question");
						// Enter field description to appear in the dialog box
	//	var fieldDescription = Array("Név", "E-mail cím", "A kérdés szövege");
						// dialog message

	var alertMsg = "A következő mezők kitöltése kötelező:\n";

	var l_Msg = alertMsg.length;

	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
} //end of CheckFormMandatoryFields()

/*
//ezt a függyvént szerintem már sehol nem használjuk:
function open_info_window(file_name) { //annak a fájlnak a neve, aminek a tartalmát meg kell jeleníteni az ablakban
 popup = window.open('php/open_info_window.php?file_name='+file_name,'',"toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=yes, resizable=1, width=700, height=520");
}

//ezt a függyvént szerintem már sehol nem használjuk:
function open_info_window_from_info_window(file_name) { //annak a fájlnak a neve, aminek a tartalmát meg kell jeleníteni az ablakban
 popup = window.open('open_info_window.php?file_name='+file_name,'',"toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=yes, resizable=1, width=700, height=520");
}
*/

function gallery(gal_title, gal_dir, pic_name) {
 var modify_dir = '';
 if (aldomain==true) modify_dir='../';
 popup = window.open(modify_dir+'php/gallery.php?gal_title='+gal_title+'&gal_dir='+gal_dir+'&pic_name='+pic_name,'',"toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=1, width=600, height=520");
}

function put_picture_with_gallery(pic_src,gal_title,gal_dir,pic_name) {
/*
egy képet rak az oldalra, ami klikkelhető, és a paramétereknek megfelelő galéria nyitható meg vele
a galériában először megjelenő kép a pic_name fájlnevű a gal_dir könyvtárban,
a pic_name paraméter elhagyható, akkor a galéria könyvtárában lévő első kép jelenik meg először a galéria elindulásakor
*/
document.write("<table cellpadding=0 cellspacing=0 border=0 class=gallery_illustration><tr align=left><td>");
document.write("<a href=\"javascript:gallery('"+gal_title+"', '"+gal_dir+"', '"+pic_name+"')\">");
document.write("<img src='img/magnifier.jpg' width=12 height=13 hspace=0 vspace=0 border=0 style='position: relative; top:9px; left:-3px;'><br><img src='"+pic_src+"' hspace=0 vspace=0 border=0 class=gallery_illustration>");
document.write("</a></td></tr></table>");
}

function used_machine_gallery(used_machine_id) {
 var modify_dir = '';
 if (aldomain==true) modify_dir='../';
 popup = window.open(modify_dir+'php/used_machine_gallery.php?machine_id='+used_machine_id,'',"toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=1, width=600, height=520");
}

/*
//ezt a függvényt szerintem nem használjuk sehol:
function put_zoomable_picture(pic_src, pic_src_big) {

//egy képet rak az oldalra, ami klikkelhető. ha ráklikkelünk, akkor egy felugró ablakban a kép nagyobb változata jelenik meg

document.write("<table cellpadding=0 cellspacing=0 border=0 class=gallery_illustration><tr align=left><td>");
document.write("<a href=\"javascript:zoom_in_a_picture('"+pic_src_big+"')\">");
document.write("<img src='img/magnifier.jpg' width=12 height=13 hspace=0 vspace=0 border=0 style='position: relative; top:9px; left:-3px;'><br><img src='"+pic_src+"' hspace=0 vspace=0 border=0 class=gallery_illustration>");
document.write("</a></td></tr></table>");
}

//ezt a függvényt szerintem nem használjuk sehol:
function zoom_in_a_picture(pic_src) {
 var modify_dir = '';
 if (aldomain==true) modify_dir='../';
 popup = window.open(modify_dir+'php/zoom_in_a_picture.php?pic_src='+pic_src,'',"toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=1, width=510, height=500");
}
*/

function gallery_with_scroller(gal_title, gal_dir) {
 var modify_dir = '';
 if (aldomain==true) modify_dir='../';
 popup_gal = window.open(modify_dir+'php/gallery_with_scroller.php?gal_title='+gal_title+'&gal_dir='+gal_dir,'',"toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=1, width=600, height=595");
}


function replaceDiv(container_div_1, div_1, container_div_2, div_2) {
/* div_1 tartalmát cseréli le div_2 tartalmával(és fordítva) úgy, hogy az id-jük az marad, ami a csere előtt volt(csak a tartalmuk változik) */
/* container_div_1 annak a div-nek az id-je, amelyik div a div_1-et tartalmazza*/

	var div_1_element = document.getElementById(div_1);
	var div_2_element = document.getElementById(div_2);
	var container_div_1_element = document.getElementById(container_div_1);
	var container_div_2_element = document.getElementById(container_div_2);
	
	var div_1_clone = div_1_element.cloneNode(true);
	var div_2_clone = div_2_element.cloneNode(true);
	div_2_clone.id = div_1;
	container_div_1_element.replaceChild(div_2_clone,div_1_element);
	div_1_clone.id = div_2;
	container_div_2_element.replaceChild(div_1_clone,div_2_element);
 
}


function mainMenuOver(tdElement_id)
{
   if (document.getElementById &&
         document.getElementById(tdElement_id) &&
            document.getElementById(tdElement_id).style)
   {
   document.getElementById(tdElement_id).style.backgroundColor="#c9e3bf";
   };  
  
}

function mainMenuOut(tdElement_id)
{
   if (document.getElementById &&
         document.getElementById(tdElement_id) &&
            document.getElementById(tdElement_id).style)
   {
   document.getElementById(tdElement_id).style.backgroundColor="#fcfdbd";
   };  
  
}

function changePic(pic_id, new_src)
{
   if (document.getElementById &&
         document.getElementById(pic_id) &&
            document.getElementById(pic_id).src)
   {
   document.getElementById(pic_id).src=new_src;
   };  
  
}

function trim(stringToTrim) { //a string elejéről és végéről eltávolítja a space-eket.
  return stringToTrim.replace(/^\s+|\s+$/g,"");
}

//---------------- eddig nem használt függvények


function showElement(id_attribute_value)
{
   if (document.getElementById &&
         document.getElementById(id_attribute_value) &&
            document.getElementById(id_attribute_value).style)
   {
   document.getElementById(id_attribute_value).style.visibility="visible";
   };
}

function hideElement(id_attribute_value)
{
   if (document.getElementById &&
         document.getElementById(id_attribute_value) &&
            document.getElementById(id_attribute_value).style)
   {
   document.getElementById(id_attribute_value).style.visibility="hidden";
   };
}