<!-- Hide

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function validate(form,field) {
	var theval = "this.document." + form.name + "." + field;
//	var theval = field;
	alert (field + "=" + theval + "\nvalue="+theval.value + "\n");
	if (!theval || eval(theval) == "") {
		return false;
	}
	return true;
}

function validate_form(form,fields,fieldnames) {
//	alert (form.name + " asasas " + fields);
	var field_array = fields.split(",");
	var fieldname_array = fieldnames.split(",");
	var res = true;
	var part_num=0;
	while (part_num < field_array.length) {
		if (!validate(form, field_array[part_num])) {
			alert(fieldname_array[part_num]+" is a required field!");
			res = false;
		}
		part_num+=1;
	}

	if (res==true) {
		alert('can submit');
		form.submit;
	} else {
		alert('cannot submit');
	}
}

function checkWholeForm(theForm) {
    var why = "";
    why += checkEmail(theForm.email.value);
    why += checkPhone(theForm.phone.value);
    why += checkPassword(theForm.password.value);
    why += checkUsername(theForm.username.value);
    why += isEmpty(theForm.notempty.value);
//    why += isDifferent(theForm.different.value);
//    for (i=0, n=theForm.radios.length; i<n; i++) {
//        if (theForm.radios[i].checked) {
//            var checkvalue = theForm.radios[i].value;
//            break;
//        } 
//    }
//    why += checkRadio(checkvalue);
    why += checkDropdown(theForm.choose.selectedIndex);
    if (why != "") {
       alert(why);
       return false;
    }
//theForm.submit();
return true;
}


function checkAll(field) {
	for (i = 0; i < field.length; i++) {
		field[i].checked = true;
	}
}

function uncheckAll(field) {
	for (i = 0; i < field.length; i++) {
		field[i].checked = false;
	}
}

var nn4 = (navigator.appName.indexOf("Netscape") > -1 && navigator.appVersion.indexOf("4") > -1) ? true:false
var ie = (document.all) ? true:false
var nn6 = (document.getElementById && !document.all) ? true:false

function browser(id) {
	var layer = (nn4) ? document.layers[id] : (ie) ? document.all[id] : document.getElementById(id)
	return layer;
}

function writeContent(id,text) {
	var layer = browser(id);  //get path to layer using global browser function
	var content;
	content = text;
	if (nn4) {
		layer.document.open();
		layer.document.write(content); //write content to layer
		layer.document.close();
//		layer.visibility="visible"	//change visibility to visible
	}
	else {
		layer.innerHTML = content  //write content to layer
//		layer.style.visibility="visible"	//change visibility to visible
	}
}

function showLayer(id) {
	var layer = browser(id);
	if (!nn4) {
		layer.style.visibility="visible";
	} else {
		layer.visibility="visible";
	}
}

function hideLayer(id) {
	var layer = browser(id);
	if (!nn4) {
		layer.style.visibility="hidden";
	} else {
		layer.visibility="hidden";
	}
}

function fill_shipping_data (form_name) {
	eval("document."+form_name+".ship_name.value = document."+form_name+".contact_name.value");
	eval("document."+form_name+".ship_company.value = document."+form_name+".company.value");
	eval("document."+form_name+".ship_address.value = document."+form_name+".address.value");
	eval("document."+form_name+".ship_city.value = document."+form_name+".city.value");
	eval("document."+form_name+".ship_state.value = document."+form_name+".state.value");
	eval("document."+form_name+".ship_zip.value = document."+form_name+".zip.value");
	return true;
}

// check validity of an email address
function emailcheck(cur, fieldname) {
	var string1 = eval("cur."+fieldname.name+".value");
	if ( (string1.indexOf("@") == -1) || (string1.indexOf(".") == -1) ) {
		alert("Please input a valid email address!\n");
		return false;
	}
}

// delete link confirmation popup message
function confirmLink(theLink, theSqlQuery) {
//	var confirmMsg='Are you sure you want to';
	var confirmMsg='Biztos vagy benne?';
    var is_confirmed = confirm(confirmMsg + '\n' + theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }
    return is_confirmed;
}

// table row color changer as mouse moves over
// stolen from PHPmySQLAdmin :\
function setPointer(theRow, thePointerColor) {
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') { return false; }
    if (typeof(document.getElementsByTagName) != 'undefined') {
		var theCells = theRow.getElementsByTagName('td');
    } else if (typeof(theRow.cells) != 'undefined') {
		var theCells = theRow.cells;
    } else {
		return false;
	}
    var rowCellsCnt  = theCells.length;
//    for (var c = 0; c < rowCellsCnt; c++) { theCells[c].style.backgroundColor = thePointerColor; }
    for (var c = 0; c < rowCellsCnt; c++) {
		theCells[c].className = thePointerColor;
	}
    return true;
}

// open an URL in a new window
function openNewWindow(URL,window_width,window_height) {
	day = new Date();
	id = day.getTime();
	if (window_width=="") {window_width='250';}
	if (window_height=="") {window_height='300';}
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+window_width+",height="+window_height+"');");
}

// open an URL in a new window
function openPalmWindow(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=230,height=370');");
}

function wait_and_redirect(delay,page) {
	string="pauseforalert("+page+");";
	setTimeout(string,delay);
}

function pauseforalert(page) {
	eval ("window.location="+page);
}

// email
function checkEmail (strng) {
	var error="";
	if (strng == "") {
	   error = "You didn't enter an email address.\n";
	}
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
	//test email for illegal characters
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
		if (strng.match(illegalChars)) {
			error = "The email address contains illegal characters.\n";
		}
    }
	return error;    
}


// phone number - strip out delimiters and check for 10 digits

function checkPhone (strng) {
	var error = "";
	if (strng == "") {
	   error = "You didn't enter a phone number.\n";
	}
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The phone number contains illegal characters.";
      }
    if (!(stripped.length == 10)) {
	error = "The phone number is the wrong length. Make sure you included an area code.\n";
    } 
	return error;
}


// password - between 6-8 chars, uppercase, lowercase, and numeral
function checkPassword (strng) {
	var error = "";
	if (strng == "") {
	   error = "You didn't enter a password.\n";
	}
    var illegalChars = /[\W_]/; // allow only letters and numbers
    if ((strng.length < 6) || (strng.length > 8)) {
       error = "The password is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "The password contains illegal characters.\n";
    } 
    else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
       error = "The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n";
    }  
	return error;    
}    


// username - 4-10 chars, uc, lc, and underscore only.
function checkUsername (strng) {
	var error = "";
	if (strng == "") {
	   error = "You didn't enter a username.\n";
	}
    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 4) || (strng.length > 10)) {
       error = "The username is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The username contains illegal characters.\n";
    } 
	return error;
}       


// non-empty textbox
function isEmpty(strng) {
	var error = "";
	if (strng.length == 0) {
		error = "The mandatory text area has not been filled in.\n"
	}
	return error;	  
}

// was textbox altered
function isDifferent(strng) {
	var error = ""; 
	if (strng != "Can\'t touch this!") {
		error = "You altered the inviolate text area.\n";
	}
	return error;
}

// exactly one radio button is chosen
function checkRadio(checkvalue) {
	var error = "";
   if (!(checkvalue)) {
       error = "Please check a radio button.\n";
    }
	return error;
}

// valid selector from dropdown list
function checkDropdown(choice) {
	var error = "";
    if (choice == 0) {
    	error = "You didn't choose an option from the drop-down list.\n";
    }    
	return error;
}    

function urlencode2(strText) {
            var isObj;
            var trimReg;
            if( typeof(strText) == "string" ) {
                        if( strText != null ) {
                                    trimReg = /(^\s+)|(\s+$)/g;
                                    strText = strText.replace( trimReg, '');
                                    for(i=32;i<256;i++) {
                                                strText = strText.replace(String.fromCharCode(i),escape(String.fromCharCode(i)));
                                    }
                        }
            }
            return strText;
}

function urlencode(text) {
	text=text.replace(/\//g,"%2F");
	text=text.replace(/\?/g,"%3F");
	text=text.replace(/\\/g,"%2F");
	text=text.replace(/=/g,"%3D");
	text=text.replace(/&/g,"%26");
    return text;
  }

//-->
