<!-- //

	function getObj(div) {
		obj=bw.dom?document.getElementById(div):bw.ie4?document.all[div]:bw.ns4?nest?document[nest].document[div]:document[div]:0;
		return obj;
	}

    function changeHTML(p, html) {

        obj=bw.dom?document.getElementById(p):bw.ie4?document.all[p]:bw.ns4?nest?document[nest].document[p]:document[p]:0;
        obj.innerHTML = html;

        return true;

    }

    function editIt(comp_id) {

        var div = 'comp_' + comp_id;
        var control_div = 'control_' + comp_id;

        obj=bw.dom?document.getElementById(div):bw.ie4?document.all[div]:bw.ns4?nest?document[nest].document[div]:document[div]:0;
        control_obj=bw.dom?document.getElementById(control_div):bw.ie4?document.all[control_div]:bw.ns4?nest?document[nest].document[control_div]:document[control_div]:0;

        // set the line breaks
        edit_str = getEditText(comp_id);
        edit_str = edit_str.replace(/%%linebreak%%/g, '\n');

        // the control string
        control_str = getEditControl(comp_id);

        obj.innerHTML = edit_str;
        control_obj.innerHTML = control_str;

        return true;

    }


    function viewIt(comp_id) {

        try {

            var div = 'comp_' + comp_id;
            var control_div = 'control_' + comp_id;

            obj=bw.dom?document.getElementById(div):bw.ie4?document.all[div]:bw.ns4?nest?document[nest].document[div]:document[div]:0;
            control_obj=bw.dom?document.getElementById(control_div):bw.ie4?document.all[control_div]:bw.ns4?nest?document[nest].document[control_div]:document[control_div]:0;

            // set the line breaks
            view_str = getViewText(comp_id);
            view_str = view_str.replace(/%%linebreak%%/g, '<br />');

			if (view_str == '') {
				view_str = ' '; // non empty string
			}

            // the control string
            control_str = getViewControl(comp_id);

            if (!(obj.innerHTML = view_str))  {
                throw 'Error 1';
            }

            control_obj.innerHTML = control_str;

        } catch (er){

            alert('This page will not display due to invalid html or an \'form\' tag within a component! \nThe element at position ' + (comp_id + 1) + ' will therefore be displayed in edit mode if possible.');

            editIt(comp_id)

        }

        return true;

    }


    /********************************************************************************
    Copyright (C) 1999 Thomas Brattli
    This script is made by and copyrighted to Thomas Brattli at www.bratta.com
    Visit for more great scripts. This may be used freely as long as this msg is intact!
    I will also appriciate any links you could give me.
    ********************************************************************************/
    //Default browsercheck, added to all scripts!
    function checkBrowser(){
    	this.ver=navigator.appVersion
    	this.dom=document.getElementById?1:0
    	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
    	this.ie4=(document.all && !this.dom)?1:0;
    	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    	this.ns4=(document.layers && !this.dom)?1:0;
    	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
    	return this
    }
    bw=new checkBrowser();


	function validateForm(formname) {

		var errors='The following error(s) occurred:\n';
		var err = 0;
		var mand = false;
		var oneof = false;

		var f = eval("document."+formname)

		// check for mandatory fields
		if (typeof(comp_types_arr) != 'undefined' && typeof(f.type) != 'undefined' && typeof(comp_types_arr[f.type.value]['mandatory']) != 'undefined') {
			for (var mandatory in comp_types_arr[f.type.value]['mandatory']) {

				var f_input = eval("document."+formname + "." + comp_types_arr[f.type.value]['mandatory'][mandatory]);
				if (f_input.value == '' && mand != true) {
					errors += ' - required fields are marked with *\n';
					err++;
					mand = true;
				}

			}

		}

		// check for atleastoneof
		if (typeof(comp_types_arr) != 'undefined' && typeof(f.type) != 'undefined' && typeof(comp_types_arr[f.type.value]['atleastoneof']) != 'undefined') {
			for (var atleastoneof in comp_types_arr[f.type.value]['atleastoneof']) {

				var f_input = eval("document."+formname + "." + comp_types_arr[f.type.value]['atleastoneof'][atleastoneof]);
				if (f_input.value != '') {
					oneof = true;
				}

			}

			if (oneof == false && comp_types_arr[f.type.value]['atleastoneof'].length > 0 && mand != true) {
				errors += ' - required fields are marked with *\n';
				err++;
			}
		}

		if (err > 0) {
			alert(errors);
		}

	    return anyErrors = (err == 0);

	}


	function submitForm(formname, action) {

		// If an action has been supplied apply it
		if (action != '') {
			theaction = eval("document."+formname+".action");
			theaction.value = action;
		}

		//	If the form is valid
		if (validateForm(formname)) {
			var f = eval("document."+formname)
			f.submit();
			return true;
		}

		return false;
	}


	function openwin() {

        var newWin = window.open("","popUp",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=600,height=500,resizable=0');

        newWin.focus();

	} // end openWin

//-->