var previewElementDivObj = false;

function px(v) { return v+'px'; }
function previewPageElement(text) {

	measure = windowMeasure();
	
	if (!previewElementDivObj) previewElementDivObj = document.getElementById('previewElementDiv');
	if (text) {
		previewElementDivObj.innerHTML=text;
		previewElementDivObj.style.top=measure.scrollTop+'px';
		previewElementDivObj.style.height=measure.height+'px';
		previewElementDivObj.style.display='block';
		}
	else {
		previewElementDivObj.innerHTML='';
		previewElementDivObj.style.display='none';
		}
	}

var productionXname = 'x';
var productionYname = 'y';
var productionSizes = [];
var productionPopups = []
var productionSizeRadios = 'dea_workproductionsize';

function resetProductionSizes(field) {
	value = parseInt(field.value);
	radios = field.form[productionSizeRadios];
	select = 0
	if (typeof(value)=='number') for (i in productionSizes) if (value>=productionSizes[i][0]) select=i;
	radios[select].checked=true;
}
function clearDeaFields(form) {
	fieldelements = [productionXname,productionYname]
	for (i in fieldelements) {
		elements = form[fieldelements[i]]
		//cbuseelements = form['cb_use_'+fieldelements[i]]
		useelements = form['use_'+fieldelements[i]]
		if (elements.length) {
			for (j=0;j<elements.length;j++) {
				elements[j].value='';
				//cbuseelements[j].checked=false;
				useelements[j].value='0';
				}
			}
		else {
			elements.value='';
			//cbuseelements.checked=false
			useelements.value='0';
			}
		}
	clearDeaFieldsCompares(form);
	}
function clearDeaFieldsCompares(form) {
	for (i in productionPopups) form[productionPopups[i]].value=0;
	}
function checkColor(obj, c1, c2) {
	container = document.getElementById(obj.name + 'cont');
	container.style.backgroundColor=(obj.checked)?c2:c1;
	}
function GHU(obj,type,table,field,id) {
	if (typeof(baseurl)!='undefined') {
		url = baseurl + '/setvalues/-/t-' + table + '/f-' + field + '/i-' + id;
		if (type=='bool') getform2htmlpageSetdata(url + '/b-'+obj.checked);
		else getform2htmlpageSetdata(url + '/v-'+obj.value);
		}
	}	

function getDataIFrame(d,url,width,height,afterload,color) {
	//getDataObj = findobject(d);
	getDataObj = document.getElementById(d);
	getDataObj.style.width = px(width);
	getDataObj.style.height = px(height);
	if (getDataObj) {
		getDataObj.innerHTML='' ;
		
		FFxF = document.createElement('iframe');
		getDataObj.appendChild(FFxF);
		//FFxF.setAttribute('bgcolor','#'+color);
		FFxF.setAttribute('id','getDataIFrameID');
		FFxF.setAttribute('scrolling','auto');
		FFxF.setAttribute('width',px(width));
		FFxF.setAttribute('height',px(height));
		FFxF.frameBorder='0';
		alert(url + '//div-' + d);
		FFxF.setAttribute('src',url);
		}
	}

function showhidearrow(opt, image) {
 	url = kostbaseurl + '/apps/gethtmlupdate//method-showhidedeaform/opt-'+opt
 	getform2htmlpageupdate(url,'deaformcolumnarrow_text');
 	on = "/_root/_lib2/images/cms/arrow_left_on_blue.gif";
 	off = "/_root/_lib2/images/cms/arrow_right_on_blue.gif";
 	if (opt=='none') findobject(image).src=off;
 	else findobject(image).src=on;
	}
	
function setaltserver(h) {
	serv = h;
	}
function updateinstlogo(i) {
	document.images['instlogo'].src = i;
	//document.images['instlogo'].src = serv + i;
	}
deletevar = 0;
function testdate(f,d) {
	n = new Date();
	y=n.getFullYear();m=1+n.getMonth();if(m<10){m='0'+m;}w=n.getDate();if(w<10){w='0'+w;}
	dd = d.split('-');
	if ((dd.length != 3)||((dd[2]<y-100)||(dd[2]>y+100))||((dd[1]<1)||(dd[1]>12))||((dd[0]<1)||(dd[0]>31))) {
		alert('dato skal skrives DD-MM-YYYY,\nfx datoen for idag: '+w+'-'+m+'-'+y+'\nEller lad feltet tomt.'); f.value=''; }
	}
function cpw(k,f,v) {
	s = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	r = '';
	for (n=0;n<v.length;n++) {
		r = r + k.charAt(s.indexOf(v.charAt(n)));
		}
	f.value = r;
	}
function checkinstselection(v) {
	if (v=='0') { alert('Du har ikke valgt en institution!'); return false; }
	else { return true; }
	}
function testpw(k,f,pw,pc) {
	s = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

	r = '';
	for (n=0;n<pw.value.length;n++) {
		r = r + k.charAt(s.indexOf(pw.value.charAt(n)));
		}
	pw.value = r;
	
	r = '';
	for (n=0;n<pc.value.length;n++) {
		r = r + k.charAt(s.indexOf(pc.value.charAt(n)));
		}
	pc.value = r;

	if (pw.value.length < 8) {
		alert('Password skal have mindst 8 tegn');
		pw.value = '';
		pc.value = '';
		return false;
		}
	if (pw.value!=pc.value) {
		alert('Det to password er forskellige');
		pw.value = '';
		pc.value = '';
		return false;
		}
	return true;
	}
function setdeletevar() { deletevar = 1; }
function ifjobdelete() {
	if (deletevar==1) {
		if (!confirm('Du er ved at slette et stillingsopslag.\nDet kan ikke gendannes bagefter.')) { deletevar = 0;  return false; }
		}
	return true;
	}
function submitid(fo,f,v) {
	fo[f].value = v;
	}
function testdkpostcode(f) {
	v = f.value;
	for (n=0;n<v.length;n++) {
		if ((v.charCodeAt(n)>57)||(v.charCodeAt(n)<48)) {
			alert('Postnummer kan kun indeholde tal');
			f.value='';break;
	}}}
function testphone(f) {
	v = f.value;
	for (n=0;n<v.length;n++) {
		if ((v.charCodeAt(n)>57)||(v.charCodeAt(n)<48)) {
			if (v.charCodeAt(n)!=32) {
			alert('Telefonnummer kan kun indeholde tal');
			f.value='';break;
	}}}}

var getvalpopup = '';
var uplpopup = '';

function uploadpopup() {
	a		= uploadpopup.arguments;
	w		= a[0];
	h		= a[1];
	frm		= a[2];
	fi		= a[3];
	jo		= a[4];
	po		= a[5];
	if (a[6] = '10.0.0.1') { host = '10.0.0.2';	} else { host = '129.142.65.38'; }
	dato 	= new Date();						 
	name 	= (Math.round((dato.getTime())/60000))-10000000;

	l	= "insert_popup/-/j-"+jo+"/p-"+po+"/n-"+name+"/act-up";
	vars = 'width='+w+',height='+h+',toolbar=no,location=no,status=yes,menubar=no,scrollbars=auto,resizable=no';
	if (!uplpopup.closed && uplpopup.location) {
		uplpopup.location.href = l;
		}
	else {
		uplpopup = window.open(l,'',vars);
		if (!uplpopup.opener) uplpopup.opener = self;
		}
	if (window.focus) { uplpopup.focus(); }
	return false;

	}

function getvaluespopup() {
	a	= getvaluespopup.arguments;
	w	= a[0];
	h	= a[1];
	frm	= a[2];
	fi	= a[3];
	p	= a[4];
	jo	= a[5];
	l	= "insert_popup/-/getval-1/sendval-"+fi.value+"/putval-"+p+"/field-"+fi.name+"/job-"+jo+"/act-find";
	vars = 'width='+w+',height='+h+',toolbar=no,location=no,status=yes,menubar=no,scrollbars=auto,resizable=no';

	if (!getvalpopup.closed && getvalpopup.location) {
		getvalpopup.location.href = l;
		}
	else {
		getvalpopup = window.open(l,'',vars);
		if (!getvalpopup.opener) getvalpopup.opener = self;
		}
	if (getvalpopup.focus) { getvalpopup.focus(); }
	return false;
	}

