/*----------------------------------------------------------------
  This JavaScript was generated by PolyPager 
  see http://polypager.nicolashoening.de
  ----------------------------------------------------------------*/
  
var n_6=(window.sidebar);

function getElementsByClass(classname){
	var elements = new Array();
	var inc = 0;
	var alltags = document.all? document.all : document.getElementsByTagName("*");
	for (i = 0; i < alltags.length; i++){
		if (alltags[i].className == classname)
			elements[inc++] = alltags[i];
	}
	return elements;
}

function toggleVisibility(theElementID, theLinkID, text_invis, text_vis) {
	el = get(theElementID);
	theLink = get(theLinkID);
	theLinkNester = get(theLinkID+'_nester');
	if (el.style.display == 'none' || el.style.display == '') {
		el.style.display = 'block';
		theLink.innerHTML = text_vis;
		if(theLinkNester) theLinkNester.className = 'clicked';
	} else {
		el.style.display = 'none';
		theLink.innerHTML = text_invis;
		if(theLinkNester) theLinkNester.className = '';
	}
}

function toggle_ability(theClass) {
	var inputs = getElementsByClass(theClass);
	var l = inputs.length;
	for (var i = 0; i < l; i++) {
		var e = inputs[i];
		if (e.disabled == true) {
			e.disabled = false;
		} else {
			e.disabled = true;
		}
	}
	var link = document.getElementById(theClass + "_link");
		if (link.style.backgroundImage.match('.*ok.*'))
		link.style.backgroundImage = "url(/style/pics/no.gif)";
	else link.style.backgroundImage = "url(/style/pics/ok.gif)";
}


// get an element - the function is similar to "$()" used in prototype.js
function get(e_name) {
	var the_element;
	if (document.getElementById) {                            // W3C DOM
		the_element = document.getElementById(e_name);
	} else if (document.all) {                                // IE4
		the_element = document.all[e_name];
	} else if (document.layers) {                             // NS4
		the_element = document.layers[e_name];
	}
	return the_element;
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }
Array.prototype.contains = function (element) {
    for (var i = 0; i < this.length; i++) 
            if (this[i] == element) return true;
    return false;
};
  
var hidden_links = new Array();

function showLink(parent_id, tindex, source_id, sindex) {
    var link_id = parent_id + String(tindex);
    var tlink = get(link_id);
    // if it was hidden, make it visible
    if (link_id in hidden_links){
        tlink.style.display = 'inline';
        hidden_links[link_id] = false;
    // if it doesnt exist yet, create it
    } else if (!tlink){
        target_element = document.getElementById(parent_id);
        source_link = document.getElementById(source_id  + String(sindex));
        var sep = ''; if(target_element.innerHTML.trim() != "") sep = "&nbsp;";
        var cl = ''; if (source_link.getAttribute('class') != null) cl = 'class="' + source_link.getAttribute('class') + '"';
        target_element.innerHTML = target_element.innerHTML + sep + '<a ' + cl + ' id="' + link_id + '" style="display:inline;" onclick="moveContent(\'' + source_id + '\', ' + sindex + ', \'' + parent_id + '\', ' + tindex + ')">' + String(source_link.innerHTML) + '</a>';
    }
    else alert('I know about tlink, it is not hidden and I didnt create it: ' + link_id);
}

function hideLink(parent_id, link_index){
    hlink = get(parent_id + String(link_index));
    if(hlink) {
        hlink.style.display = 'none';
        hidden_links[parent_id + String(link_index)] = true;
    }
}

// appends "," + indexed link from source
// to target and makes source link invisible
var initial_states = new Array();
function moveContent(target, tindex, source, sindex) {
	var target_element = get(target);
    var source_element = get(source);
    // just remembering what had been
	if (!(target in initial_states)) initial_states[target] = target_element.innerHTML;
    if (!(source in initial_states)) initial_states[source] = source_element.innerHTML;
    
    // add source content to target content, hide source link
    showLink(target, tindex, source, sindex);
    hideLink(source, sindex);
}

function reset(inputfieldname){
    if (inputfieldname in initial_states) {
        for (key in hidden_links) {
            if (hidden_links[key] == true) {
                l = get(key);
                l.style.display = 'inline';
            }
        }
        hidden_links = Array();
        infield = get(inputfieldname);
        infield.innerHTML = initial_states[inputfieldname];
    }
}

function getMetric(num) {
	if(n_6) { return parseInt(num) + 'px';}
	else return parseInt(num);
}

/* open link in a new window */
function openWindow(adress, title, width, height, top, left, scrollbars) {
	fenster = window.open(adress, title, "width="+width+",height="+height+",left="+left+",top="+top+",scrollbars="+scrollbars);
	fenster.focus();
}

//asks if deleting is really wanted
function checkDelete(multiple){
	if (multiple) agree = confirm("Are you sure you want to delete the selected entries?");
    else agree = confirm("Are you sure you want to delete this entry?");
	if (agree) {
		return true;
	}
	else {
   		return false;
	}
} 

function submit_form_by_selection(command) {
	agree = confirm('a change this field is important for other fields in this form. I therefore would like to reload this page. OK?');
	if (agree) {
		document.forms[0].submit();
	}
}

//checks input values of forms
function checkValues(pageName) {
	var results = "";
	var tmp = "";
	
	/*if (pageName=="_sys_singlepages") {
		if (isNaN(document.forms[0].menue_index_input.value)) {
			results = results + "The field menue_index contains a non-numeric value!\n\n";
		}
	}*/
	if (pageName=="_sys_sections") {
		if (isNaN(document.forms[0].order_index_input.value)) {
			results = results + "The field order_index contains a non-numeric value!\n\n";
		}
	}
			if (pageName=="A La Carte") {
			//alert('I AM HERE for page ' + pageName);
								
									
									
									
									
									
						}
		
			if (pageName=="Bienvenue") {
			//alert('I AM HERE for page ' + pageName);
								
									
									
									
									
									
									
									
										if (isNaN(document.forms[0]._formfield_order_index_input.value)) {
							results = results + 'The field "order index" contains a non-numeric value!\n\n';
						}
										
									
						}
		
			if (pageName=="Conversations") {
			//alert('I AM HERE for page ' + pageName);
								
									
									
									
									
									
									
									
										if (isNaN(document.forms[0]._formfield_order_index_input.value)) {
							results = results + 'The field "order index" contains a non-numeric value!\n\n';
						}
										
									
						}
		
			if (pageName=="Impressum") {
			//alert('I AM HERE for page ' + pageName);
								
									
									
									
									
									
									
									
										if (isNaN(document.forms[0]._formfield_order_index_input.value)) {
							results = results + 'The field "order index" contains a non-numeric value!\n\n';
						}
										
									
						}
		
			if (pageName=="Recettes") {
			//alert('I AM HERE for page ' + pageName);
								
										if (isNaN(document.forms[0]._formfield_id_input.value)) {
							results = results + 'The field "id" contains a non-numeric value!\n\n';
						}
										
									
									
									
						}
		
			if (pageName=="z") {
			//alert('I AM HERE for page ' + pageName);
								
									
									
									
									
									
									
									
										if (isNaN(document.forms[0]._formfield_order_index_input.value)) {
							results = results + 'The field "order index" contains a non-numeric value!\n\n';
						}
										
									
						}
		
			if (pageName=="zBibliography") {
			//alert('I AM HERE for page ' + pageName);
									if (isNaN(document.forms[0]._formfield_id_input.value)) {
							results = results + 'The field "id" contains a non-numeric value!\n\n';
						}
										
									
									
									
									
									
									
									
									
									
						}
		
			if (pageName=="zClub Litteraire") {
			//alert('I AM HERE for page ' + pageName);
									if (isNaN(document.forms[0]._formfield_id_input.value)) {
							results = results + 'The field "id" contains a non-numeric value!\n\n';
						}
										
									
									
									
									
									
									
									
									
									
									
									
									
						}
		
			if (pageName=="zCookbook") {
			//alert('I AM HERE for page ' + pageName);
									if (isNaN(document.forms[0]._formfield_id_input.value)) {
							results = results + 'The field "id" contains a non-numeric value!\n\n';
						}
										
									
									
										
						var field = document.forms[0]._formfield_country_input;
						if (field) {
							tmp = field.value;
							regex = '/.+/';
							var erg = tmp.match(/.+/); 
							if (!erg) {
								results = results + "country: please specify some text here.\n\n";
								results = results + "In detail: the content \"" + tmp + "\" of the field \"country\" does not match the Regular Expression \"" + regex + "\"!\n";
								results = results + "\n\n";
							}
						}
										
									
									
						}
		
			if (pageName=="zCreme Anglaise") {
			//alert('I AM HERE for page ' + pageName);
								
									
									
									
									
									
						}
		
			if (pageName=="zEn Promotion") {
			//alert('I AM HERE for page ' + pageName);
								
									
									
									
									
									
									
									
										if (isNaN(document.forms[0]._formfield_order_index_input.value)) {
							results = results + 'The field "order index" contains a non-numeric value!\n\n';
						}
										
									
						}
		
			if (pageName=="zMelange Viennois") {
			//alert('I AM HERE for page ' + pageName);
									if (isNaN(document.forms[0]._formfield_id_input.value)) {
							results = results + 'The field "id" contains a non-numeric value!\n\n';
						}
										
									
									
									
									
									
						}
		
			if (pageName=="zPlat du Jour") {
			//alert('I AM HERE for page ' + pageName);
								
									
									
									
									
									
						}
		
			if (pageName=="zWhom I Know") {
			//alert('I AM HERE for page ' + pageName);
									if (isNaN(document.forms[0]._formfield_id_input.value)) {
							results = results + 'The field "id" contains a non-numeric value!\n\n';
						}
										
									
									
									
									
									
									
									
						}
		
			if (pageName=="_sys_singlepages") {
			//alert('I AM HERE for page ' + pageName);
									if (isNaN(document.forms[0]._formfield_id_input.value)) {
							results = results + 'The field "id" contains a non-numeric value!\n\n';
						}
										
										
						var field = document.forms[0]._formfield_name_input;
						if (field) {
							tmp = field.value;
							regex = '/.+/';
							var erg = tmp.match(/.+/); 
							if (!erg) {
								results = results + "name: please specify some text here.\n\n";
								results = results + "In detail: the content \"" + tmp + "\" of the field \"name\" does not match the Regular Expression \"" + regex + "\"!\n";
								results = results + "\n\n";
							}
						}
										
									
										if (isNaN(document.forms[0]._formfield_menue_index_input.value)) {
							results = results + 'The field "menue-index" contains a non-numeric value!\n\n';
						}
										
									
									
									
									
									
									
									
						}
		
			if (pageName=="_sys_multipages") {
			//alert('I AM HERE for page ' + pageName);
									if (isNaN(document.forms[0]._formfield_id_input.value)) {
							results = results + 'The field "id" contains a non-numeric value!\n\n';
						}
										
										
						var field = document.forms[0]._formfield_name_input;
						if (field) {
							tmp = field.value;
							regex = '/.+/';
							var erg = tmp.match(/.+/); 
							if (!erg) {
								results = results + "name: please specify some text here.\n\n";
								results = results + "In detail: the content \"" + tmp + "\" of the field \"name\" does not match the Regular Expression \"" + regex + "\"!\n";
								results = results + "\n\n";
							}
						}
										
										
						var field = document.forms[0]._formfield_tablename_input;
						if (field) {
							tmp = field.value;
							regex = '/.+/';
							var erg = tmp.match(/.+/); 
							if (!erg) {
								results = results + "tablename: please specify some text here.\n\n";
								results = results + "In detail: the content \"" + tmp + "\" of the field \"tablename\" does not match the Regular Expression \"" + regex + "\"!\n";
								results = results + "\n\n";
							}
						}
										
									
										if (isNaN(document.forms[0]._formfield_menue_index_input.value)) {
							results = results + 'The field "menue-index" contains a non-numeric value!\n\n';
						}
										
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
									
						}
		
			if (pageName=="_sys_comments") {
			//alert('I AM HERE for page ' + pageName);
									if (isNaN(document.forms[0]._formfield_id_input.value)) {
							results = results + 'The field "id" contains a non-numeric value!\n\n';
						}
										
									
										if (isNaN(document.forms[0]._formfield_pageid_input.value)) {
							results = results + 'The field "pageid" contains a non-numeric value!\n\n';
						}
										
									
										
						var field = document.forms[0]._formfield_name_input;
						if (field) {
							tmp = field.value;
							regex = '/.+/';
							var erg = tmp.match(/.+/); 
							if (!erg) {
								results = results + "name: please specify some text here.\n\n";
								results = results + "In detail: the content \"" + tmp + "\" of the field \"name\" does not match the Regular Expression \"" + regex + "\"!\n";
								results = results + "\n\n";
							}
						}
										
									
									
									
									
						}
		
	
		if (results != "") {
		results = "The following of the data you entered do not meet the given specifications:\n\n" + results;
		alert(results);
		return false;
	}
	return true;
}

