var collectChildArtId;
var collectChildArtName;
var collectParentArtId;
var collectParentArtName;
var collectInsertFileId;
var collectInsertFileName;
var useFacebookLike, twitterShareAccount, twitterJS;
var movedArticleModule;
var manageEditModuleId;
// screensize to link

var addScreensize2Link;
getParam = {
	SCREEN_BW: 			0,
	SCREEN_BH: 			0,
	RLInterval: 		1000,
	splitter: 			'therestoftheurlistobereplaced',
	formSep:			function(sep) { return sep || '&'; },
	formEq:				function(eq) { return eq || '='; },

	screenDim:			function (sep,eq) { return this.formSep(sep)+'screenwidth'+this.formEq(eq)+screen.availWidth+this.formSep(sep)+'screenheight'+this.formEq(eq)+screen.availHeight; },
	browserDim:			function (sep,eq) { return this.formSep(sep)+'scrw'+this.formEq(eq)+windowMeasure().width+this.formSep(sep)+'scrh'+this.formEq(eq)+windowMeasure().height; },
	isXierpaUrl:		function (u) {
							if (u.indexOf('/-/')>-1) return true;
							if (u.indexOf('//')>-1) return true;
							return false;
							},
	seps:				function(u) {
							if (this.isXierpaUrl(u)) return ['/-/','/','-']
							else return ['?','&','=']
							},
	build:				function(u,addwin) {
							sep = this.seps(u);
							u = u.split(this.splitter)[0];
							if (u.indexOf(sep[0])<0) u = u+sep[0]+this.splitter+sep[2]+'1';
							else u = u + sep[1]+this.splitter+sep[2]+'1';
							u += this.browserDim(sep[1],sep[2]);
							return u
							}
			}
function addScreen2Links() {
	var anchors = document.getElementsByTagName('a')
	for (var i in anchors) {
		if (!anchors[i].href) continue;
		if ((hrf = anchors[i].getAttribute('href'))!=null) {
			if (!(hrf.split(':')[0] in {'http':1,'https':1,'javascript':1,'mailto':1,'ftp':1})) {
				anchors[i].href = getParam.build(hrf);
				}
			}
		}
	}
	
// var SCREEN_BW = 0;
// var SCREEN_BH = 0;
// var RLInterval = 1000;
// var splitter = 'therestoftheurlistobereplaced=1'
// function getScreenParam(sep,eq) { return formSep(sep)+'screenwidth'+formEq(eq)+screen.availWidth+formSep(sep)+'screenheight'+formEq(eq)+screen.availHeight; }
// //function getBrowserParam() { return '/browserwidth-'+windowMeasure().width+'/browserheight-'+windowMeasure().height; }
// function getBrowserParam(s,t) { return s+'scrw'+t+windowMeasure().width+s+'scrh'+t+windowMeasure().height; }
// function formSep(s) { return s || '&'; }
// function formEq(eq) { return eq || '='; }
// function isXierpaUrl(u) {
// 	if (u.indexOf('/-/')>-1) return true;
// 	if (u.indexOf('//')>-1) return true;
// 	return false;
// 	}
// function addScreen2Links() {
// 	//alert(addScreensize2Link)
// 	//if (!addScreensize2Link) return;
// 	SCREEN_BW = windowMeasure().width
// 	SCREEN_BH = windowMeasure().height
// 	var anchors = document.getElementsByTagName('a')
// 	for (var i in anchors) {
// 		if (!anchors[i].href) continue;
// 		if ((hrf = anchors[i].getAttribute('href'))!=null) {
// 			if (!(hrf.split(':')[0] in {'http':1,'https':1,'javascript':1,'mailto':1,'ftp':1})) {
// 				sep = ['?','&','=']
// 				if (isXierpaUrl(hrf)) sep = ['/-/','/','-']
// 				anchors[i].href = hrf+sep[0]+splitter+getBrowserParam(sep[1],sep[2]);//+getScreenParam();
// 				}
// 			}
// 		}
// 	}
//addObjectEventListener('load', addScreen2Links);


// newsletter
var failMessages = {
				'sorry':{
								'da':'Beklager, vi har et problem:',
								'en':'Sorry, we’ve got a situation:',
								'nl':'Sorry, er is een probleem:'
							},
				'namefield':{
								'da':'Navn mangler.',
								'en':'Name must be filled.',
								'nl':'Naam mist.'
							},
				'emailfield':{
								'da':'E-mail adressen er ugyldig.',
								'en':'Not a valid email.',
								'nl':'Niet een geldig e-mail.'
							},
				'emailmatch':{
								'da':'E-mail er ikke ens.',
								'en':'Emails doesn’t match.',
								'nl':'De E-mails passen niet.'
							}
					}
function getFailMessages(k) {
	if (failMessages[k]) if (failMessages[k][pageLang]) return failMessages[k][pageLang];
	return k
	}
function validNewsLetter(f, o, n, e1, e2) {
	var failed = [getFailMessages('sorry')];
	if (!n.value) failed.push(getFailMessages('namefield'));
 	if (!mustBeEmail(e1.value)) failed.push(getFailMessages('emailfield'));
 	if (e1.value.replace(' ','')!=e2.value.replace(' ','')) failed.push(getFailMessages('emailmatch'));
 	ConsoleLog(['failed'],failed)
 	return failed
	}
function sendNewsLetter(f, o, n, e1, e2) {
	var failed = validNewsLetter(f, o, n, e1, e2)
	if (failed.length==1) {
		if (jQuery(jqId('newsletter.request')).length) {
			url = thisUrl + '/-/gethtmlupdate/build-SaveNewsletter'; ///value-'+value+'/t-art/f-parent_/id-' + thisPageId;
			getform2htmlpageupdate(url, o, f)
			}
		html = '<input type="hidden" name="newsletter.request" id="newsletter.request" value="'+parseInt(Math.ceil(Math.random() * 10000000))+'" size="4" />'
		jQuery(jqId('newsletter.submit')).animate({'opacity':0.2},100);
		jQuery('#confirmbutton').animate({'width':150},100,function(){
			jQuery(jqId('newsletter.confirmBox')).fadeIn(200);
			}).append(jQuery(html))
		}
	else {
		jQuery(jqId(o + 'Errm')).html(failed.join('<br/>'))
		}
	}

// organising and attaching and deleting parenta and children articles
function resetArtId() {
	collectInsertFileId = null;
	collectInsertFileName = null;
	}
function updateArtId(move2typeid) {
	var value = (collectParentArtId)?collectParentArtId:'';
	//alert(move2typeid + ' | ' + value + ' | ');
	if (!thisPageId) return;
	url = thisUrl + '/-/gethtmlupdate/build-setvalue/value-'+value+'/t-art/f-parent_/id-' + thisPageId;
	getform2htmlpageSetdata(url);
	var moveObject = findobject('manageNavArt_'+thisPageId);
	if (move2typeid) {
		var p = findobject('manageNavType_'+move2typeid) || findobject('manageNavArtChildren_'+move2typeid)
		if (p) p.appendChild(moveObject.cloneNode(true));
		moveObject.parentNode.removeChild(moveObject);
		}
	else if (value) {
		findobject('manageNavArt_'+collectParentArtId).appendChild(moveObject);
		//findobject('manageNavArt_'+collectParentArtId).appendChild(moveObject.cloneNode(true));
		//moveObject.parentNode.removeChild(moveObject);
		}
	}
function resetFileId() {
	collectParentArtId = null;
	collectParentArtName = null;
	}
function collectFileId(id,label) {
	collectInsertFileId = id;
	collectInsertFileName = label;

	}
function collectArtId(id,name,execute) {
	collectParentArtId = id;
	collectParentArtName = name;
	//alert(collectParentArtId);
	if (execute) placeArtId(execute+'.parent_')
	}
function deleteArtId(obj,c,move2typeid) {
	// onclick="deleteArtId('article.parent_',this,11)"
	reciever = findobject(obj);
	if (!c.checked) {
		if (reciever.value) {
			if (confirm('delete parent reference')) {
				reciever.value = '';
				recieverf = findobject(reciever.name+'name');
				recieverf.value = ''
				resetArtId();
				resetFileId();
				updateArtId(move2typeid);
				}
			}
		else c.checked=true
		}
	else {
		if (collectParentArtId) placeArtId(reciever);
		else { alert('pick up an item to place'); c.checked=false;}
		}
	}
function placeArtId(obj) {
	//alert(collectParentArtId);
	if (collectParentArtId) {
		reciever = findobject(obj);
		reciever.value = collectParentArtId;
		recieverf = findobject(reciever.name+'name');
		recieverf.value = collectParentArtName;
		recievercb = findobject(reciever.name+'cb');
		if (!recievercb.checked) {
			recievercb.checked = true;
			}
		updateArtId();
		}
	resetArtId();
	}
resetArtId();

function collectArtChildId(id,name,execute) {
	collectChildArtId = id;
	collectChildArtName = name;
	placeArtChildId('articlechildren', id, name);
	//alert(collectParentArtId);
	//if (execute) placeArtId(execute+'.parent_')
	}
/*
<div id="article.module_many.article.0div">
<input style="border:1px;background-color:#57bae4" name="article.module_many.article.0" value="0" readonly="1" type="text" id="article.module_many.article.0" size="4" alt="+"/>
<input type="checkbox" name="article.module_many.article.0cb" onclick="deleteArtId(this,4)" alt="+"/>
<input readonly="1" onmouseup="placeArtId('article.module_many.article.0')" style="font-style:italic;width:460px;border:1px;background-color:#2fa9de" name="article.module_many.article.0name" value="untitled article" alt="+"/>
</div>
*/
function placeArtChildId(container, id, name) {
	id = id || collectChildArtId;
	name = name || collectChildArtName;
	if (id) {
		//alert(collectChildArtName)
 		var c = jQuery('<div id="article.module_many.article.'+id+'div"></div>')
 		c.append('<input style="border:0px;background-color:rgba(255,255,255,0.2)" name="article.module_many.article" value="'+id+'" readonly="1" type="hidden" id="article.module_many.article" size="4" alt="+"/>')
 		c.append('<input type="checkbox" name="article.module_many.article.'+id+'cb" onclick="deleteArtChildId(\''+container+'\',this,'+id+')" checked="1" alt="+"/>')
 		c.append('<input readonly="1" class="relativeArticle" name="article.module_many.article.'+id+'name" value="'+name+'" alt="+"/>')
 		jQuery(jqId(container)).append(c)
 		}
	}
function deleteArtChildId(container, c, id) {
	if (!c.checked) {
		if (confirm('delete referenced article?')) {
			jQuery(jqId(container) + " " + jqId('article.module_many.article.'+id+'div')).remove()
			}
		else c.checked=true
		}
	}

function pickModule(id, name, src) {
	if (!document.getElementById('file.selectnew')) return;
	document.getElementById('file.selectnew').value=id;
	document.getElementById('file.selectnew_name').value=name;
	document.getElementById('file.selectnew_image').src=src;
	document.getElementById('file.selectnew_image').style.display='block';
	}
function pickModuleLink(src, d, title) {
	if ((d = jQuery(jqId(d))).length) {
		d.val(src);
		d.addClass('readonly');
		}
	}
function navigateList(o, container, start, r) {
	url = thisUrl + '/-/gethtmlupdate/build-NavigationModuleImages/start-'+start;
	o = (o.form)? o.form:o;
	getform2htmlpageupdate(url, container, o);
	if (r) return false;
	}

var insertImageCropDataModule = null;
var insertImageCropDataId = null;
function insertImageCropData(x,y,w,h) {
x = 'article.module_many.37.crop'
}
function openImageCropEditor(image,module) {
	insertImageCropDataModule = module;
	insertImageCropDataId = image;
}
function checkupload(form,obj){
	form['upload.filename'].value=obj.value;
	form['command'].value='upload';
	name = obj.value;
	names = name.split('.')
	ext = names[names.length-1]
	form['upload.filetype'].value=ext;
	}
function setStreetNumberStyle(cb,id,style) {
	c=(cb.checked)?1:0;
	url = StreetNumberPath + '//edit/gethtmlupdate/id-' + id + '/select-' + c + '/style-' + style;
	getform2htmlpageSetdata(url);
	}
var previewElementDivObj = null;
function previewPageElement(text) {
	wm = windowMeasure();
	//alert(wm.scrollTop);
	if (!previewElementDivObj) previewElementDivObj = document.getElementById('previewElementDiv');
	if (text) {
		previewElementDivObj.innerHTML=text;
		previewElementDivObj.style.position='fixed';
		
		//previewElementDivObj.style.top=wm.scrollTop+'px';
		previewElementDivObj.style.display='block';
		}
	else {
		previewElementDivObj.innerHTML='';
		previewElementDivObj.style.display='none';
		}
	}
function openLogin(id) {
	d = document.getElementById(id);
	d.style.display = (d.style.display=='block')?'none':'block';
	}
function getPostsOnLoad(id) {
	d = document.getElementById('postcomments');
	if (!d) return
	u = thisUrl + '/-/gethtmlupdate/comm';
	if (iPhoneUi) u += '/iphone';
	if (thisPageId) u = u + '/debug/id-' + thisPageId;
	ConsoleLog(['wil2.js','getPostsOnLoad -> getform2htmlpageupdate url:',u]);
	if (d.style.width) u = u + '/w-' + parseInt(d.style.width);
	if (d) getform2htmlpageupdate(u,'postcomments');
	}
function link2Manage(e) {
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
	//alert(targ);
	if (targ) {
		cns = targ.className.split('_');
		document.location = manageUrl+'/-/parent_-'+cns[1]+'/type_-'+cns[2]+'/cmd-edit/t-mod/id-'+cns[3];
		//alert(u);
		}
	}
function buildManageLinks() {
	tags = ['h3','img'];
	for (j in tags) {
		o = document.getElementsByTagName(tags[j]);
		for (i in o) if (o[i].className) {
			if (o[i].className.split('_')[0]=='manage') {
				addObjectEventListener('click',link2Manage,o[i]);
				o[i].style.cursor = 'pointer';
				}
			}
		}
	}
	
function showhidenav(obj,field,id,t) {
	obj = findobject(obj);
	field = findobject(field);
	showhide(obj);
	field.value = (obj.style.display=='block') ? 1:0;
	setOpenClose(id,field.value,t);
	}
function loadCalendarPopup() {
	
	}
function setBool(n,im1,im2,t,f,id) {
	op = boolbuts(n,im1,im2);
	if (!op) op = 0;
	url = thisUrl + '/-/gethtmlupdate/build-setval/value-'+op+'/t-'+t+'/f-'+f+'/id-' + id;
	getform2htmlpageSetdata(url);
	}
function delBool(n,im1,im2,t,f,id) {
	op = boolbuts(n,im1,im2,t,f,id);
	url = thisUrl + '/-/gethtmlupdate/build-setval/value-'+op+'/t-'+t+'/f-'+f+'/id-' + id;
	alert(url)
	getform2htmlpageSetdata(url);
	}
function moveBool(n,im1,im2,t,f,id) {
	op = boolbuts(n,null,null,t,f);
	if (confirm('move this item from this article?')) {
		document.getElementById(t+'.sort.postrow.'+id).style.display='none';
		url = thisUrl + '/-/gethtmlupdate/build-setval/value-0/t-'+t+'/f-article_id/id-' + id;
		movedArticleModule = id
		getform2htmlpageSetdata(url);
		jQuery('.movedModuleCatch').toggle();
		}
	}
function moveModule2Art(id, head, art) {
	if (movedArticleModule) {
		url = thisUrl + '/-/gethtmlupdate/build-setval/value-'+id+'/t-mod/f-article_id/id-' + movedArticleModule;
		getform2htmlpageSetdata(url);
		movedArticleModule = null;
		jQuery('.movedModuleCatch').toggle();
		}
	}
function boolbuts(n,im1,im2,t,f,del,move) {
	//alert(n)
	inp = document.getElementById(n);
	im = document.getElementById(n+'image');
	if (inp.value) {
		inp.value = '';
		if (im2) im.src = im2;
		if (del) document.getElementById(t+'.sort.postrow.'+del).style.opacity=1;
		}
	else {
		inp.value = '1';
		if (im1) im.src = im1;
		if (del) {
			if (confirm('delete this')) document.getElementById(t+'.sort.postrow.'+del).style.opacity=0.3;
			else {
				inp.value = '';
				if (im2) im.src = im2;
				}
			}
		}
	return inp.value
	} 
function boolbutscolor(n,col1,col2,col3,col4) {
	inp = document.getElementById(n);
	im = document.getElementById(n+'image');
	alert(im)
	if (inp.value) {
		inp.value = '';
		im.style.color = col1;
		im.style.backgroundColor = col2;
		}
	else {
		inp.value = '1';
		im.style.color = col3;
		im.style.backgroundColor = col4;
		}
	}
function setOpenClose(id,op,t) {
	url = thisUrl + '/-/gethtmlupdate/build-openclose/openclose-'+op+'/t-'+t+'/id-' + id;
	getform2htmlpageSetdata(url);
	}
function showfinds(close){
	if (gethtmlupdateTarget) findres = document.getElementById(gethtmlupdateTarget);
 	else findres = document.getElementById('searchresult');
 	if (close) {
 		findres.style.display='none';
 		prevobj = document.getElementById('elementEditorDiv');
 		prevobj.style.innerHTML='';
 		prevobj.style.display='none';
		gethtmlupdateTarget = null;
 		}
 	else if (findres.innerHTML) {
 		findres.style.bottom='0px'; 
 		findres.style.display='block'; 
 		}
	}
function previewFound(open, obj) {
	if (typeof(findPreviewBackColor)=='undefined') findPreviewBackColor = '#cccccc';
 	w = 300;
 	pos = objectPos('searchresult')
 	x = pos[0]-w-18;
 	y = pos[1];
 	prevobj = document.getElementById('elementEditorDiv');
 	findres = document.getElementById(obj);
 	
 	prevobj.style.left=px(x);
 	prevobj.style.top=px(y);
 	prevobj.style.width=px(w);
 	prevobj.style.bottom=px(0);
 	prevobj.innerHTML = findres.innerHTML;
 	prevobj.style.display = 'block';
 	prevobj.style.backgroundColor = findPreviewBackColor;
 	//alert(objectPos('searchresult'));
 	//alert(prevobj.style.left + ' - ' + prevobj.style.top + ' - ' + prevobj.style.width + ' - ' + prevobj.style.display + ' - ' + prevobj.style.zIndex)
 	
 	}
function gettags2show(k,t) {
	url = baseUrl + k + '/' + t + '//gethtmlupdate/build-tagfloat'
	getform2htmlpageupdate(url,'tagresult',null,false,false,'showtags');
	}
function showtags(close){
 	findres = document.getElementById('tagresult');
 	if (close) {
 		findres.style.display='none';
 		prevobj = document.getElementById('elementEditorDiv');
 		prevobj.style.innerHTML='';
 		prevobj.style.display='none';
 		}
 	else if (findres.innerHTML) {
 		findres.style.bottom='0px'; 
 		findres.style.display='block'; 
 		}
	}
function unifySiblings(o,c,f1,f2){
	if (o.form[c].checked) {
		if (o.id==f1) copyFieldValue(f1,f2);
		else copyFieldValue(f2,f1);
		}
	}
function unifyFields(o,f1,f2,cls){
	if (o.checked) {
		copyFieldValue(f1,f2);
		//jQuery(jqClass(cls)).addClass('readonly')
		}
	//else jQuery(jqClass(cls)).removeClass('readonly')
	}
function copyFieldValue(f1, f2) {
	jQuery(jqId(f2)).val(jQuery(jqId(f1)).val());
	}
function setArticleType(name,id,recid) {
	rds = document.getElementById('sqlformid')[name];
	if (rds.length) {
		for (i=0;i<rds.length;i++) {
			//alert((rds[i].value==id) + ' ' +rds[i].value+' '+id);
			if (rds[i].value==id) {
				rds[i].checked = true;
				setRadioVal(id,'art','type_',recid)
				}
			}
		}
	jQuery('.articleSubmit').show()
	}
function setRadioVal(val,t,f,id) {
	if (!id) return;
	url = thisUrl + '/-/gethtmlupdate/build-setvalue/value-'+val+'/t-'+t+'/f-'+f+'/id-' + id;
	getform2htmlpageSetdata(url);
	}

// ========================================
// jQuery based functions for:
// Cropping images
// Sorting table rows
// and others

function updateSelectValueDisplay(select, div){	
	var result = []
	jQuery(jqId(select.id) + ' option:selected').each(function() {result.push(jQuery(this).text())});
	jQuery(jqId(div)).text(result.join(', '));
		}

function stopSortableLocal(tr) {
	var c, id, ids, action, field, x = 'no tr'
	var result = []
	if (tr) {
		x = tr.attr('id')
		c = tr.attr('class')
		//alert(c);
		//alert(tr.parent().children('tbody#sortsortsort tr').length)
		//alert(jQuery("tbody#sortsortsort tr"+jqClass(c)).length)
		count = 1
		sortedrows = tr.parent().children('tbody#sortsortsort tr')
		sortedrows.each(
			function() { 
				if ((i = jQuery(this).attr('id'))) {
					ids = i.split('.')
					id = ids.pop()
					field = ids.pop()
					action = ids.pop()
					table = ids[0]
					result.push(id)
					ids.push(field)
					ids.push(id)
					jQuery(jqId(ids.join('.'))).val(count)
					count += 1
					}
				}
			);
		//alert(jqId(ids.join('.')));
		
		//alert(result.join('/id-') + ' | ' + field + ' | ' + action + ' | ' + table)
		url = thisUrl + '/-/gethtmlupdate/build-setpriority/value-'+action+'/t-'+table+'/f-priority/i-' + result.join('/i-');
		//alert(url);
		getform2htmlpageSetdata(url);
		}
	}

//Remember to invoke within jQuery(window).load(...)
//If you don't, Jcrop may not initialize properly
var cropIni;
var cropId;
var cropInputFieldBase;
var cropObjects = []

jQuery(document).ready(function(){
	var id, o
	jQuery('.cropbox').each(
		function() {
			var o = jQuery(this).attr('id')
			id = parseInt(o.split('.').pop());
			if (cropObjects[id]) {
				if (cropObjects[id].crop) {
					jQuery(this).Jcrop({
						onChange: showCoords,
						onSelect: showCoords,
						setSelect: cropObjects[id].crop,
						});
					}
				else {
					jQuery(this).Jcrop({
						onChange: showCoords,
						onSelect: showCoords,
						});
					}
				}
			});
	jQuery('.fadeinout').mouseenter(function(){
		jQuery(this).animate({opacity:1},100)
	}).mouseleave(function(){
		jQuery(this).animate({opacity:0.85},100)
	});
	if (twitterShareAccount&&jQuery('.twitter-share-button').length&&twitterJS) {
		jQuery.getScript(twitterJS)
		}
	if (useFacebookLike&&document.getElementById('fb-root')) {
		(function(d, s, id) {
			var js, fjs = d.getElementsByTagName(s)[0];
			if (d.getElementById(id)) {return;}
			js = d.createElement(s); js.id = id;
			js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
			fjs.parentNode.insertBefore(js, fjs);
			}(document, 'script', 'facebook-jssdk'));
		}
	//alert(addScreensize2Link)
	if (addScreensize2Link) addScreen2Links();
	});
function setCropId(i) { cropId = i; }
function showCoords(c) {
	//alert(cropId)
	if (!cropId) return
	val = [c.x,c.y,c.x2,c.y2]
	if ((c.x==c.x2)&&(c.y==c.y2)) val = []
	cropObjects[cropId].crop = val
	jQuery(jqId(cropInputFieldBase + cropId)).val(cropObjects[cropId].crop.join(','))
	jQuery(jqId(cropInputFieldBaseChange + cropId)).val(1)
	}
var pageLanguage = 'en';
function getZIndex(o) { 
	var z, p=jQuery(o).parent(), zIndexes=[]
	while (p.get(0).nodeName!='BODY') {
		z = p.css('z-index')
		if (z!='auto') zIndexes.push(parseInt(z))
		if (p.parent()) p = p.parent();
		else p = null;
		}
	zIndexes.sort()
	m = zIndexes.pop()
	return m
	}
	
function initializeDatePicker() {
	jQuery.datepicker.setDefaults(jQuery.datepicker.regional[pageLanguage]);
	jQuery().ready(function() { 
	initializeDatePickerFields();
	})
	jQuery.datepicker.setDefaults({
		firstDay: 1,
		numberOfMonths: 2,
		showAnim: 'fadeIn', 
		dateFormat: 'yy-mm-dd', 
		showWeek: true, 
		selectMultiple: true,
		changeMonth: true, 
		changeYear: true, 
		showOtherMonths: true,
		showButtonPanel: true,
		dayNamesShort: weekDaynamesMin,
		dayNamesMin: weekDaynamesMin,
		monthNames: weekMonthnames,
		monthNamesShort: weekMonthnames,
		duration: 'fast',
		weekHeader: '',
		//beforeShow: function() { jQuery('#ui-datepicker-div').css({'z-index':9999999}); },
		//beforeShow: function() { jQuery(this).dialog("widget").css("z-index", 10000); },
	});
	jQuery( '#ui-datepicker' ).css({zIndex:2000});
	}
function initializeDatePickerFields() {
	jQuery( '.datepick' ).each(function() { 
		jQuery(this).css('z-index',getZIndex(this));
		//alert(jQuery(this).css('z-index'));
		jQuery(this).datepicker();
		//alert(jQuery(this).css('z-index'));
		jQuery(this).zIndex(3007)
		//alert(jQuery(this).zIndex());
		});
	}
function openModule(params) {
	if (!manageEditModuleId) return
	getform2htmlpageupdate(thisUrl,manageEditModuleId,params,'henter data','h3','updateModuleOn');
	jQuery(jqId(manageEditModuleId)).show();
	}
function openModuleInArticle(params) {
	if (!manageEditModuleId) return
	getform2htmlpageupdate(thisUrl,manageEditModuleId,params);
	jQuery(jqId(manageEditModuleId)).show();
	}
function updateModuleOn() {
	if (!manageEditModuleId) return
	feed = jQuery('#debugShowFormGT')
	cont = jQuery('#debugShowFormContent')
	if (feed.length&&cont.length) cont.html(feed.html())
	initializeDatePickerFields()
	if (window.tinyMCE) {
		jQuery('.tinymce').each( function() {
			var id = jQuery(this).attr('id');
			if (!tinyMCE.getInstanceById(id)) {
				tinyMCE.execCommand('mceAddControl', false, id);	
				}
			});
		}
	var div = jQuery(jqId(manageEditModuleId));
	var st = jQuery(window).scrollTop();
	y0 = div.parent().offset().top
	y1 = st-y0+80
	//wh = jQuery(window).height();
	div.animate({top:y1})
	}
function closeEditModule(x,y,v){
	if (window.tinyMCE) {
	jQuery('#manageEditModuleDiv .tinymce').each( function() {
		var id = jQuery(this).attr('id');
		if (tinyMCE.getInstanceById(id)) {
			tinyMCE.execCommand('mceRemoveControl', false, id);
			}
		});
		}
	jQuery(jqId('manageEditModuleDiv')).hide()
	}
function closeDebug(x,y,v){
	var fn = jqId(x)+' #'+y+'Field'
	var f = jQuery(fn)
	if (f.length) {
		jQuery(jqId(x)+' #'+y+'Field').val(v)
		}
	if (v) {
		jQuery(jqId('debugShowForm')).show();
		jQuery(jqClass('debugText')).removeClass('hidden');
		jQuery(jqClass('debugField')).removeClass('hidden');
		jQuery(jqClass('debugNav')).addClass('debugNavShow');
		}
	else {
		jQuery(jqId('debugShowForm')).hide();
		jQuery(jqClass('debugText')).addClass('hidden');
		jQuery(jqClass('debugField')).addClass('hidden');
		jQuery(jqClass('debugNav')).removeClass('debugNavShow');
		}
	}
function showhideTab(id, w, dir) {
	var o = jQuery(jqId(id));
	if (o.position().left==0) o.animate({left:-w-4},100)
	else o.animate({left:0},100)
	}
function showhideTabFront(id, w, dir) {
	var c, contid, o = jQuery(jqId(manageTabContainer));
	jQuery(jqClass(manageTabContainerClass)).each( function() {
		c = {'z-index': (jQuery(this).attr('id')==id)?3:2 }
		contid = jqId(jQuery(this).attr('id')+'Cont')
		listid = jqId(jQuery(this).attr('id')+'_list')
		if (jQuery(this).attr('id')==id) {
			if (jQuery(contid).is(":visible")) {}
			else jQuery(contid).fadeIn(100)
			jQuery(listid).addClass('boxShS');
			}
		else { 
			if (jQuery(contid).is(":visible")) jQuery(contid).fadeOut(100) 
			jQuery(listid).removeClass('boxShS');
			}
		jQuery(this).css(c)
		});
	if (o.position().left<-20) showhideTab(manageTabContainer,w,dir);
	}
var tablists;
function equalizeTabHeights() {
	if (!tablists) return;
	var h = [];
	for (i in tablists) h.push(parseInt(jQuery(jqId(tablists[i])).height()));
	h.sort(function(a,b){return b - a}); //http://www.javascriptkit.com/javatutors/arraysort.shtml
	h.reverse();
	h = h.pop();
	for (i in tablists) jQuery(jqId(tablists[i])).css({'height':h});
	}
function setOpacity(id, op, op1) {
	//var o = jQuery(jqId(id))
	//o.animate({opacity:op},100)
	}
function shInline(o) {
	jQuery(jqId(o)).toggle()
	//lyObj = document.getElementById(o);
	//lyObj.style.display=(lyObj.style.display&&lyObj.style.display=='inline')?'none':'inline';
	}
function shObj(o) {
	jQuery(o).toggle()
	//lyObj = document.getElementById(o);
	//lyObj.style.display=(lyObj.style.display&&lyObj.style.display=='inline')?'none':'inline';
	}
function closeGallery(gi) {
	jQuery(jqId(gi)).fadeOut(200,function(){jQuery(document).remove(jQuery(jqId(gi)));});
	}
function showGallery(p,image) {
	var top = jQuery(document).scrollTop() + 80;
	var gi = 'galleryImage'
	var pos = jQuery(jqId(p)).offset();
	var left = pos.left - 8
	var w = jQuery(jqId(p)).width() + 16;
	var h = jQuery(window).height() - 90;
	html = '<div id="'+gi+'" style="position:absolute;z-index:2000;display:none;text-align:center;" onclick="closeGallery(\''+gi+'\')"></div>';
	url = thisUrl + '/-/gethtmlupdate/build-ShowGallery/id-'+image+'/w-'+w+'/h-'+h;
	jQuery('body').append(html);
	getform2htmlpageupdate(url,'galleryImage',{},false,false,'showGalleryDo');
	jQuery(jqId(gi)).css({'left':left,'top':top,'width':w,'background-color':'white'});
	}
function showGalleryDo() {
	var gi = 'galleryImage';
	jQuery(jqId(gi)).fadeIn(200);
	}
var full = 0;
fullarr = new Array(1,0);
var curNumberimage
var numbersPath
function changeimage(f,img) {
	imagearr = new Array('_fullimages/','_images/');
	document.images[f].src = numbersPath +  imagearr[full] + curNumberimage;
	full = fullarr[full];
	}
function changenewimage(img,t) {
	curNumberimage = img;
	alert(numbersPath + '_images/' + img)
	document.images['theNumberimage'].src = numbersPath + '_images/' + img;
	full = 0;
	findobject('textdiv').innerHTML=t;
	}
re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

