//<![CDATA[


function strtrim(str) {
	return str.replace(/^\s+/,'').replace(/\s+$/,'');
}

/*
function form_f(field) {
	field.style.background='#FCFCFC'
}

function form_b(field) {
	if(strtrim(field.value) == '') {field.style.background='#F2F2F2'}
}
*/


var field_data = new Array();
var field_counter = 0;

function form_f(field) {
	if(!field.linker) {
		field_data[field_counter + "dat"] = field.value;
		field.linker = "ID:" + field_counter;
		field_counter++;
	}
	field.style.background='#FCFCFC';
}

function form_b(field) {
	if(strtrim(field.value) == field_data[field.linker.substring(3) + "dat"]) {field.style.background='#F2F2F2'; }
}

var field_data_hd = new Array();
var field_counter_hd = 0;

function form_f_hd(field) {
	if(!field.linker_hd) {
		field_data_hd[field_counter_hd + "dat"] = field.value;
		field.linker_hd = "ID:" + field_counter_hd;
		field_counter_hd++;
	}
	field.style.background='#FFECEB';
}

function form_b_hd(field) {
	if(strtrim(field.value) == field_data_hd[field.linker_hd.substring(3) + "dat"]) {field.style.background='#E3AAA8'; }
}


function popUp(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=430,height=300,left = 150,top = 150');");
}

function teade(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=1,width=500,height=500,left = 150,top = 70');");
}

function highlight(item,colour) {
    if(document.all){
        //thisbrowser="ie"
          document.all[item].style.background="#" + colour;
    }
    if(!document.all && document.getElementById){
        //thisbrowser="NN6/7"
          var bas = eval("document.getElementById(\""+item+"\")");
          bas.style.background="#" + colour;
	}
}

function placeFocus() {

	var found_set = false;
	if (document.forms.length > 0) {
		for (j = 0; j < document.forms.length; j++) {
			if(!found_set) {
				var field = document.forms[j];
				for (i = 0; i < field.length; i++) {
					if (
					(field.elements[i].type == "text") || 
					(field.elements[i].type == "textarea")) {
						field.elements[i].focus();
						found_set = true;
						break;
					}
				}
			}
		}
	}
	
	if(document.forms['reg_form']) {
		document.forms['reg_form'].elements[0].focus();
	}

}


var help_wnd;
function open_help(topic) {
	help_wnd=window.open('cip_loadpage.php?load=cip_help_wnd&topic_id='+topic,'help_window','height=420,width=380,left=200,top=300,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no');
	help_wnd.focus();
}

function timer() {
	date = new Date();
	return date.getTime();
}

function pick_up_res(res_url) {
	var image = new Image();
	s_time = timer();
	image.src = res_url + "&reso=" + screen.width + "x" + screen.height + "&dummy=" + s_time;
}

//]]>