
	var publishBlog = "";
	var publishComment = "";
	var formVars = "";
	var changing = false;
	var hovering = false;
	var modifying_id = '';
	var is_wysiwyg = '';	
	var editing_content = '';
	var blogId = '';
	var postid = '';
	var textareareplace = '';
	var is_cancel = false; // allows X button to not re-generate WYSIWYG editor
	
	document.onmousedown = getClickLocation;	
	function msieversion()
// return Microsoft Internet Explorer (major) version number, or 0 for others
// This function works by finding the "MSIE " string and extracting the version number
// following the space, up to the decimal point for the minor version which is ignored.
{
	var ua = window.navigator.userAgent
	var msie = ua.indexOf ( "MSIE " )
	if ( msie > 0 )		// is Microsoft Internet Explorer; return version number
		return parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) )
	else
		return 0	// is other browser
}
window.IEVersion = msieversion();

	//get width of text element
	function widthEl(span){
		if (document.layers){		  	  
		  w=document.layers[span].clip.width;
		} else if (document.all && !document.getElementById){
		  w=document.all[span].offsetWidth;
		} else if(document.getElementById){		  
		  w=document.getElementById(span).offsetWidth;
		}
	return w;
	}
	
	//get height of text element
	function heightEl(span){
	
		if (document.layers){
		  h=document.layers[span].clip.height;
		} else if (document.all && !document.getElementById){
		  h=document.all[span].offsetHeight;
		} else if(document.getElementById){
		  h=document.getElementById(span).offsetHeight;
		}
	return h;
	}

	//edit field created
	function cambia(actual) {
		 
		 /* Checks to make sure that the function was not called accidently while closing WYSIWYG.
		  * See Mantis ID 1627
		  */
	    if (is_cancel) { return; }
	    
		if(!changing){
			actual.onclick = '';
			modifying_id = actual.id;
			
			width = widthEl(actual.id) + 20;
			height =heightEl(actual.id) + 2;
			innerHTML = actual.innerHTML;
			
			

//			innerHTML = actual.innerHTML.replace(/<br>\n/ig, "\n");
			innerHTML = innerHTML.replace(/onclick="lon\(\);"/ig, "");			
			
			editing_content = innerHTML;
//			innerHTML = innerHTML.replace(/<br>/ig, "\n");
			if((actual.innerHTML.length > 30) && (height < 40)) height = 40;
			//alert(actual.id);  //debug stmt
			if(width < 100)
				width = 150;
			if(innerHTML.match("_extended"))
                        {                            
                                innerHTML = innerHTML.replace(/_extended="true"/,"");
                        }
			//was height < 40, but now we just check for id fields ... with only 2 of them we have a text field, or if its a page label, the others textarea
			if(actual.id == "an" || actual.id == "agt" || actual.id == "wt" || actual.id == "pagehead1" ||actual.id == "mih"|| actual.id.search(/{label}/) != "-1")
			//if(actual.id == "agt" || actual.id == "wt" || actual.id == "pagehead1" ||actual.id == "mih"|| actual.id.search(/{label}/) != "-1")  //Use this one for allowing the user to modify font/color settings to the Agent Name line.
			{     				
				if(window.IEVersion > 0) {
					width = width - 20;
					height = height - 10;					
				}
				
				var strId = actual.id; //Added to limit the size of the offer text in the Fulton template  				
				var myTemp = checkTemplate();				
				strId = strId.substr(0,5);
				strId= strId.toLowerCase();												
				if((strId == "offer") && (myTemp)){  //This makes it so that only the fullton template is limited to 15 characters.  
					actual.innerHTML = "<input id=\""+ actual.id +"_field\" class=\"admin_text\" type=\"text\" maxlength=\"15\" value=\"" + innerHTML + "\" onkeypress=\"return fieldEnter(this,event,'" + actual.id + "')\" onfocus=\"highLight(this);\" onblur=\"noLight(this); return fieldBlur(this,'" + actual.id + "','');\" />";					
				} else {
					actual.innerHTML = "<input id=\""+ actual.id +"_field\" class=\"admin_text\" type=\"text\" value=\"" + innerHTML + "\" onkeypress=\"return fieldEnter(this,event,'" + actual.id + "')\" onfocus=\"highLight(this);\" onblur=\"noLight(this); return fieldBlur(this,'" + actual.id + "','');\" />";

					// Automatically select textbox on creation
					// See Mantis ID 1627
					document.getElementById(actual.id+'_field').select();
				}
				is_wysiwyg = false;
			}else{
				
				if(window.IEVersion > 0){
					width = width - 20;
					height = height - 10;						
				}
				textareareplace = innerHTML.match(/<TEXTAREA(.*?)>/ig);	
				if(textareareplace!=null)
				{					
					innerHTML = innerHTML.replace(/<TEXTAREA(.*?)>/ig,"<input type=hidden name=textarea>");
					innerHTML = innerHTML.replace(/<\/textarea>/ig,"<input type=hidden name=endtextarea>");	
				}
							
				width = width - 10;
				height = height + 10;
				//alert(actual.id); //debug to see what is inside
				actual.innerHTML = "<textarea name=\"textarea\" id=\""+ actual.id +"_field\" class=\"admin_text\" style=\"z-index:100; width: "+width+"px; height: "+height+"px;\" onfocus=\"highLight(this);\" onblur=\"this.focus();\" >" + innerHTML + "</textarea>";

				//onKeyPress = "ieKeyPress();";
				//FOR IE, so it won't lose focus when they move out of the textarea if they
				//select something, the next line is needed
				onBlur = "onblur=\"noLight(this); return fieldBlur(this,'" + actual.id + "','');\"";
								

				if(actual.id=='blogpost' || actual.id=='commentpost')
				{
					createWYSIWYG(actual.id,"_field",'nosave');
					//fckEdit(actual.id,'blogging');
				}else{
					size = (actual.getAttribute('size')) ? actual.getAttribute('size') : 'full';
					createWYSIWYG(actual.id,"_field",size);
					//fckEdit(actual.id,size);					
				}
				is_wysiwyg = true;
		
			}
			changing = true;
		}else{
			if(actual.id != modifying_id){
				//if(is_wysiwyg) saveTextAreaData(modifying_id);
			}

		}

		//actual.firstChild.focus();
	}
	
	function saveTextAreaData(id){
		n = id + '_field';
		
		cctent = updateTextArea(n);
		if(textareareplace!=null)
		{
			cctent = cctent.replace(/<input name="textarea" type="hidden">/ig,textareareplace);
			cctent = cctent.replace(/<input name="endtextarea" type="hidden">/ig,'</textarea>');
			textareareplace = '';
		}	
		deGenerateHTMLEditor(id,n,cctent); 
		htmlAreaBlur(id,cctent);			
	}
	function newWysiwygSave(content,id)
	{			
		var edited = content.replace(/(\r|\n)/, "");
		
		htmlAreaBlur(modifying_id,edited);
		deGenerateHTMLEditor(modifying_id,id,edited);	
	}	
	function blogsave_button(id)
	{
		var cBox = document.blogs.bcats;
		var bcat = "";
		if(cBox.length==undefined && cBox.checked==true)
		{
			bcat+=cBox.value+',';
		}else{				
			for (i = 0; i < cBox.length; i++)
			{
				if(cBox[i].checked==true)
				{
					bcat+=cBox[i].value+",";
				}			
			}
		}				
		if(bcat=="")
		{
			alert('You must chose a category the blog needs to belongs to.');
			return false;
		}else{
			document.getElementById('blogcategorylist').value=bcat;
			n = id + '_field';		
			if(document.getElementById("wysiwyg" + n))
			{			
				cctent = updateTextArea(n);
				deGenerateHTMLEditor(id,n,cctent);
			}else{			
				cctent = getUContent(id);
				deGenerateHTMLEditor(id,n,cctent);			
			}			
			htmlAreaBlur(id,cctent);				
			//return true;
		}								
	}
	
	function createWYSIWYG(id,secondPart,size){
		generate_wysiwyg(id,secondPart,size);				
	}
	function fckEdit(id,size)
	{			
		var oFCKeditor = new FCKeditor(id+'_field') ;
		switch(size)
		{	
			case 'mlm':
				oFCKeditor.ToolbarSet = 'MLM';	
				oFCKeditor.Height = '400';		
			break;		
			case 'small':				
				if(id=='pco')						
				{					
					oFCKeditor.ToolbarSet = 'Mini';
				}else if (id=='an'){
					oFCKeditor.ToolbarSet = 'Mini';
				}else{					
					oFCKeditor.ToolbarSet = 'Homepage';					
				}
			break;
			case 'blogging':
				oFCKeditor.ToolbarSet = 'Blogging';
			break;
			default:				
				oFCKeditor.ToolbarSet = 'Default';
				oFCKeditor.Height = '400';
			break;
		}
        	oFCKeditor.BasePath = "/fckeditor/" ;
        	oFCKeditor.ReplaceTextarea() ;	
	}
	function highLight(ele){
	
	}
	
	function noLight(ele){
			
	}

	function ieKeyPress(ele){
		//alert("HERE");  //debug
	}

	
	function deGenerateHTMLEditor(id,n,content){		
		document.getElementById(id).innerHTML = content;		
		editing_content = '';
		changing = false;
	}
		
function fieldEnter(campo,evt,idfld) {	
	evt = (evt) ? evt : window.event;
	if (evt.keyCode == 13 && campo.value!="") {
				elem = document.getElementById( idfld );
		//remotos = new datosServidor;
		//nt = remotos.enviar(urlBase + "?fieldname=" +escape(elem.id)+ "&content="+escape(campo.value)+"&"+formVars,"");
		//remove glow
		noLight(elem);
//		if(nt != null)
//		elem.innerHTML = nt;
		changing = false;
		return false;
	} else {
		return true;
	}
}

function insertAfter(parent, node, referenceNode) {
	parent.insertBefore(node, referenceNode.nextSibling);
}

function URLEncode(plaintext)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
		if (ch == " ") {
			encoded += " ";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
			encoded += ch;
		} else {
			var charCode = ch.charCodeAt(0);

			if (charCode > 255) {
				/*
					alert( "Unicode Character '" 
						+ ch 
						+ "' cannot be encoded using standard URL encoding.\n" +
						  "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
				*/
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};	

function fieldBlur(campo,idfld,originalHTML) {
	
	if ((campo.value!="") || (campo.id == "agt_field") && (campo.value=="")) {	
		elem = document.getElementById( idfld );

		campo.value = campo.value.replace(/\r/ig, "");
		innerHTML = campo.value.replace(/\n/ig, "<br>");		
		//innerHTML = innerHTML.replace(/"/ig, "\"");
		innerHTML = innerHTML.replace(/"/ig, '%22');				
		bodyText = "";
		
//		alert(originalHTML + "\n" + inputs[0].value +  " vs " + innerHTML + "\n" + ele.innerHTML);
		if(pregTest(idfld))
		{			
			rExp = /{label}/gi;
			var checkId = idfld.replace(rExp,"");			
			if(document.getElementById(checkId)!=null)				
			{			
				bodyText=URLEncode(document.getElementById(idfld.replace(rExp,"")).innerHTML);
				if(innerHTML.match(/</) || innerHTML.match(/>/))
				{					
					alert('The header cannot contain any HTML form tags'+innerHTML);
					return false;
				}
				bodyText = bodyText.replace(/"/ig, '%22');			
			}else{
				bodyText = 'EXTRA';
			}
		}	
		if(originalHTML != innerHTML) highlightPublishLink();

		/*
		 * Added support for editing the same box twice
		 * See Mantis ID 1627
		 */
 		 elem.onclick = function(){ 
			cambia(this);
		}

		elem.innerHTML = innerHTML;
		
		innerHTML = URLEncode(innerHTML);
		showPublishLink();
		
		loadPage("./editor.php","savesession",elem.id+"&base=editsite&headerText="+innerHTML+"&v="+bodyText);
		changing = false;
		return false;
	}
	
}	

function htmlAreaBlur(n,content) {	
	headerText = "";
	innerHTML = URLEncode(content);
	innerHTML = innerHTML.replace(/"/ig, '%22');
	if(n=='blogpost' || n=='commentpost')
	{
		headerText=URLEncode(document.getElementById(n+"{label}").value);			
		switch(n)
		{
			case 'commentpost':
			var cBox = document.comments.comment_status;
			var bcat = "";	
			ajaxContent = n+"&base=comments&v="+innerHTML+"&commentId="+document.getElementById('commentId').value+"&blogId="+document.getElementById('blogId').value;
			if(publishComment == 'y')
			{
				ajaxContent += "&publish=y";
			}
			for (var i=0; i < cBox.length; i++)
   			{
   				if (cBox[i].checked)
      				{
      					ajaxContent +="&commentstatus="+cBox[i].value;
      				}
   			}			
			//alert(ajaxContent);
			//loadPage_("./editor.php","savesession",ajaxContent,"");	
			break;			
			case 'blogpost':
				var metadescription = URLEncode(document.getElementById('metadescription').value);
				var metakeywords = URLEncode(document.getElementById('metakeywords').value);		
				var allowcomments = '';
				if(document.getElementById('allowComments').value=='on')
				{
					allowcomments = 'y';
				}
				ajaxContent = n+"&base=blogging&v="+innerHTML+"&headerText="+headerText+"&blogId="+blogId+"&allowcomments="+allowcomments+"&metakeywords="+metakeywords+"&metadescription="+metadescription;
				if(publishBlog == 'y')
				{
					ajaxContent += "&publish=y";
				}
				var cBox = document.blogs.bcats;
				var bcat = "";
				if(cBox.length==undefined && cBox.checked==true)
				{
					bcat+=cBox.value+',';
				}else{				
					for (i = 0; i < cBox.length; i++)
					{
						if(cBox[i].checked==true)
						{
							bcat+=cBox[i].value+",";
						}			
					}
				}				
				if(bcat=="")
				{
					alert('You must chose a category the blog needs to belongs to.');
					return false;
				}
				ajaxContent+="&blogcategory="+bcat;
				_body_onunload();
				loadPage("./editor.php","savesession",ajaxContent,"setBlogId");		
				//loadPage_("./editor.php","savesession",ajaxContent,"setBlogId");
				break;	
		}		
	}else{
		if(pregTest(n)> 0)
		{
			headerText=URLEncode(document.getElementById(n+"{label}").innerHTML);			
			headerText = headerText.replace(/"/ig, '%22');		
		}		
		loadPage("./editor.php","savesession",n+"&base=editsite&v="+innerHTML+"&headerText="+headerText);	
		showPublishLink();
		postid = n;
	}
	changing = false;
	return false;
}

function saveMeta(page)
{	
	headerText=URLEncode(document.getElementById(page).value);
	headerText  = headerText.replace(/script/gi,"TPIRCS");
	pageName = URLEncode(document.getElementById('page').value);			
	loadPage_("./editor.php","saveMeta","&base=editsite&pagename="+pageName+"&v="+headerText+"&meta="+page);
	showPublishLink();
	
	page_id = "po_" + page;
	pageELE = document.getElementById(page_id);

	insideDivs = pageELE.getElementsByTagName('div');
	
	showDESC = '<strong>Page Title</strong> has';
	if(page=='headerScript' || page=='bodyScript')
	{
		formDESC = '<br />To close this window, <a href="#" onClick="showID(\'po_customjava\')">click here</a>';
	}else{
		formDESC = '<br />To close this window, <a href="#" onClick="showID(\'po_'+page+'\')">click here</a>';	
	}
	
	if(page == 'metadescription') showDESC = '<strong>Meta Description</strong> has';
	if(page == 'metakeywords') showDESC = '<strong>Meta Keywords</strong> have';	
	
	for(i=0;i<insideDivs.length; i++){
		if(insideDivs[i].className == 'po_desc') insideDivs[i].innerHTML = 'Your ' + showDESC + ' been saved.';
		if(insideDivs[i].className == 'po_form') insideDivs[i].innerHTML = formDESC;		
	
	
	}
	
	changing = false;
	return false;	
}

function ManageTabPanel(dispTitle,hideTitle,dispId,hideId)
{	
	document.getElementById(dispId).style.display="block";
	document.getElementById(hideId).style.display="none";	
}

function resettScripttoGlobal(page)
{				
	loadPage_("./editor.php","getGlobal","&base=editsite&tagFor="+page);
	divtoload = 'global';
	resetId = page;
	//document.getelemene
}

function Metatags(page)
{	
	if(page=="")
	{
		page="home";
	}	
	loadPage_("./editor.php","displayMeta","&base=editsite&page="+page,'pageTitle');
	
	document.getElementById('page').value=page;
	page = page;	
	//divtoload = 'pageTitle';		
}	

function pregTest(n)
{		
	if(n.match(/{label}/) || n=='agt' || n=='an' || n=='mih' || n=='wt' || n=='pagehead1')
	//if(n.match(/{label}/) || n=='agt' || n=='mih' || n=='wt' || n=='pagehead1')  			//Use this one to make the Agent Text box customizable with font/color options	
	{		
		return 1;
	}else if(document.getElementById(n+"{label}") != undefined ){
		//document.getElementById(n+"{label}").innerHTML != ""){		
		return 1;
	}else{		
		return 0;
	}
}


function showPublishLink(){
	window.parent.document.getElementById('TOP_publishlink').style.display = 'inline';
}

function showHide(editbuttons, pushed,is_photo){	
	uploadBOX = document.getElementById(editbuttons);
	uploadRepo = document.getElementById("upload_repo_area");
	uploadREIRepo = document.getElementById("upload_rei_repo_area");	
	uploadUploadBox = document.getElementById("upload_box_area");	

	
	display = (uploadBOX.style.display == "block") ? "none" : "block";
	uploadBOX.style.display = display;
	
	if(is_photo == "upload"){
		uploadRepo.style.display = "none";
		uploadUploadBox.style.display = "block";
		uploadREIRepo.style.display = "none";		
	}else if(is_photo == "repo"){
		uploadRepo.style.display = "block";
		uploadUploadBox.style.display = "block";		
		uploadREIRepo.style.display = "none";		
	}else if(is_photo == 'rei_repo'){
		uploadRepo.style.display = "none";				
		uploadUploadBox.style.display = "none";				
		uploadREIRepo.style.display = "block";
	}	
	
	editImage = false;	
	
	/* Added for Mantis ticket 813 - 2008-11-19 - Ryan  */
	/* The statement below calculate the position of    */
	/* the uploadbox based on where the user clicks,    */ 
	/* but only if the the uplodbox is to be displayed. */ 	
	if (display == 'block'){		
		/* Upload box dimensions 600 x 380 */
		/* Coordinates of mouse click */		
		intXLocation = mouseX;
		intYLocation = mouseY;
		
		/* Center of the iframe element */
		intCenterFrame = parent.document.getElementById('site_editor').clientHeight/2;
		
		/* Determine the vertical scrollbar scroll position */
		intYScroll = (document.all)?document.body.scrollTop:window.pageYOffset;
		if (intYScroll == 0){
		    if (window.pageYOffset)
		        intYScroll = window.pageYOffset;
		    else
	        	intYScroll = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		} 						
		//Set the top coordinate of the upload box		
		if(intYLocation < intCenterFrame && intYLocation > 200){
			y = intYLocation - (380/2);		 
		} else if (intYLocation > intCenterFrame && intYScroll < (intCenterFrame/2)){						
			y = intYLocation - 380;
		} else {
			y = intYLocation;
		}
		
		//Set the left coordinate of the upload box 
		if(intXLocation > 600){
			x = intXLocation - 600; 
		} else {
			x = intXLocation;
		}				

		/* Display position the upload box */
		uploadBOX.style.left = x + "px";
		uploadBOX.style.top = y + "px";	
	} else {
		uploadBOX.style.left = "50px";
		uploadBOX.style.top = "50px";	
	}	
}


function doImage(id){
	if(!editText && !editImage){
		if(!changing){
			_id_ = document.getElementById(id);
	
			document.image_update.i_id.value = _id_.id;
			//alert(_id_.id + " " + widthEl(id));
			rh = _id_.getAttribute("rh");
			
			realHeight = parseInt(rh);
			realHeight = (isNaN(realHeight)) ? 0 : realHeight;
			
			heightElement = parseInt(heightEl(id));
			heightElement = (isNaN(heightElement)) ? 0 : heightElement;			
			
			trueheight = realHeight + heightElement;
			
			
			is_photo = _id_.getAttribute("ip");
			box_to_show = 'upload';
	
			if(is_photo == null){
				box_to_show = "repo";
			}else if(is_photo == "rp"){
				box_to_show = "rei_repo";
			}
			
			if(id == "logobox"){
				document.getElementById('deleteLogo').style.display = 'block';				
				document.getElementById('LogoLink').style.display = 'block';
				document.image_update.action = './editor.php';
				document.image_update.target = '';
			}else{
				document.getElementById('deleteLogo').style.display = 'none';
				document.getElementById('LogoLink').style.display = 'none';				
			}	
			
			document.image_update.i_width.value = widthEl(id);
			document.image_update.i_height.value = trueheight;
			document.image_update.i_id.value = id;
			
			showHide("uploadbox",id,box_to_show);
			editImage = true;
		}
	}
}
	
	
	/******
	******************************
	*******/
	
	var originals = new Array();
	var changed = new Array();
	
	var editText = false;
	var editImage = false;
	function _init(){
		
		_body_onload();	
		
		spans = document.getElementsByTagName("span"); // let's get all the span tags and see if they are editable
		//alert(fs.length);		
		
		n = 0
		for (var n = 0; n < spans.length; n++) {
			span = spans[n];	
			
			if (((' '+span.className+' ').indexOf("redigieren") != -1) && (span.id) && (!changed[span.id])) {	
				changed.push(span.id);
				
				//span.setAttribute("onclick","cambia(this)");
				span.onclick = function(){ 
					/* Added for Mantis ID 1674 */
						editText = true;
					/* End addition for Mantis ID 1674 */
						cambia(this);

				}
					
				if(span.getAttribute("sw")){
					span.style.width = span.getAttribute("sw") + "px";
				}
					
				//sapn.onclick = function () { cambia(spn); }
				span.onmouseover = function(){
					/* Removed for Mantis ID 1674 */
					/* editText = true;			  */
				}
				
				/*
				//Taken out for Mantis 1433 - Wysiwyg would reset scrollbar on IE7 b/c
				//of this onmouse event

				span.onmouseover = function(){
					 changeclass(this.id,'_hover', this.n);
				}
				*/
				/*
				//Taken out for Mantis 488 - Wysiwyg would lose focus on FF b/c
				//of these onmouse events
				span.onmouseout = function(){
					editText = false;

				}
				
				span.onmouseout = function(){
					changeclass(this.id,'_normal',this.n);
				}	
				*/
				span.style.cursor = "pointer";
				//span.style.border = "1px solid #000000";
				span.title = "Click to edit!";	
				
			}

			if(((' '+span.className+' ').indexOf("newlink") != -1) && (span.id) && (!changed[span.id])){
				changed.push(span.id);
				
				span.innerHTML = "<form name='newlink_"+span.id+"' action='editor.php' method='post'> <input type='hidden' name='base' value='editsite' />					<input type='hidden' name='post_id' value='newlink_"+span.id+"' /> <a href=\"editor.php?base=parsed_page&firsttime=&page="+offerIdLink(span.id)+"\" target=\"_self\">Click to edit this page</a><br/>Link Location: <input type='hidden' name='cmd' value='updateafflink' /> <input type='hidden' name='ol' value='"+span.getAttribute('link')+"'  /> <input type='text' name='newlink_"+span.id+"' size='15' value='"+span.getAttribute('link')+"' onBlur='loadPage(\"./editor.php\",\"savesession\",\""+span.id+"&base=editsite&v=\"+this.value);showPublishLink();' /> </form>";
			}			
		}
		
		divs = document.getElementsByTagName("div"); // let's get all the div (images) tags and see if they are editable
		//alert(fs.length);
		n = 0;
		for (var n = 0; n < divs.length; n++) {
			div = divs[n];
	
		
			if (((' '+div.className+' ').indexOf("redigieren") != -1) && (div.id) && (!changed[span.id])) {
				originals[n] = div.className;
				changeclass(div.id,'imgnormal',div.n);
				width = widthEl(div.id) - 10;
				height = heightEl(div.id) - 10;
				sh = div.getAttribute("sh"); // show height
				oh = div.getAttribute("oh"); // offset height
				insidespan = div.getElementsByTagName("span");

				if(oh > 0){
					insidespan[0].style.top = oh + "px";
				}
				
				if(sh > 0){
					insidespan[0].style.height = sh + "px";
				}else{
				
					if(height < 0) height = 10;
					insidespan[0].style.height = height + "px";
				}
				
				sw = div.getAttribute("sw");
				if(sw > 0){
					insidespan[0].style.width = sw + "px";
				}else{
					if(width < 0) width = 10;
					insidespan[0].style.width = width + "px";
				}				
//				if(window.IEVersion > 0) insidespan[0].style.left = 0;


/*				
				div.setAttribute("onMouseOver","changeclass(this.id,'imghover')");
				div.setAttribute("onMouseOut","changeclass(this.id,'imgnormal')");
				div.setAttribute("onClick","doImage(this.id)");
*/
				
				div.n = n;
				div.onmouseover = function(){
					changeclass(this.id,'imghover',this.n);
				}
				
				div.onmouseout = function(){
					changeclass(this.id,'imgnormal',this.n);
				}
				
				div.onclick = function(){

					doImage(this.id);
				}	
				

				div.style.cursor = "pointer";
				div.title = "Click to change image!";	
				div.style.zIndex = "1";
			}
		}	
		
	
	}	
	
	function highlightPublishLink(){
		pl = document.getElementById("publishlink");
		if(pl) pl.style.display = "inline";		
	}
	
	var shouldiignore = false;
	function highlighme(id,newname){
		
		
		ele = document.getElementById(id);
		divw = widthEl(id);
		divh = widthEl(id);
		changeclass(id,newname,0);


	
		
	}

	function offerIdLink(offerId)
	{
		switch(offerId)
		{
			case "affiliatelink":
				return "offer1";
			break;
			case "affiliatelink2":
				return "offer2";
			break;
			case "affiliatelink3":
				return "offer3";
			break;
		}
	}

	function unhighlighme(id,newname){
		if(shouldiignore) return ;
		hovering = false;
		
		d_nested = document.getElementById("createdonthefly_" + id); 
		throwaway_node = ele.removeChild(d_nested);		
	}
	
	
	function changeclass(id,newname,n){
		//alert("id = " + id + "\nnewname = " + newname + "\nn = " + n);
		if(!editText){			
			ele = document.getElementById(id);
			
	//		classname = (newname == "imghover") ? ele.className + " " + newname : originals[n] ;
			//classname = originals[n] + " " + newname;			
			classname = newname
	//		if(newname != "imghover") alert(classname);
			ele.className = classname;
		}
	}
	
	// Loader Function
	function lon(target)
	{
		lc = document.getElementById("loaderContainer");
		if(lc) lc.style.display = "";
	}
	
	
	function loff(target)
	{	
		lc = document.getElementById("loaderContainer");
		if(lc) lc.style.display = "none";
	}
	
	function showA() {
	 
		as = document.getElementsByTagName("a");
		for (var n = 0; n < as.length; n++) {
			oc = as[n].getAttribute("onClick");
			octarget = as[n].getAttribute("target");
			if((!oc) && (!octarget)){
				attrib = as[n].getAttribute("href");
				if(!((' '+attrib+' ').indexOf("#") != -1)){
					if(!((' '+attrib+' ').indexOf("javascript") != -1)){
						as[n].setAttribute("onClick","lon();");
					}
				}
			}
		}
		
		fs = document.getElementsByTagName("form");
		for (var n = 0; n < fs.length; n++) {
			os = fs[n].getAttribute("onSubmit");	
			octarget = fs[n].getAttribute("target");
			
			if((!os) && (!octarget)){
				
				fs[n].setAttribute("onSubmit","lon()");
			}
		}			
	 
	}		
	
	function _body_onload()
	{
		loff();
		showA();
		
	}
	
	function _body_onunload()
	{
		lon();
	
	}	

	function _addEvent(obj, evType, fn, useCapture){
		if (obj.addEventListener){			
			obj.addEventListener(evType, fn, useCapture);
			return true;
		} else if (obj.attachEvent){			
			var r = obj.attachEvent("on"+evType, fn);
			return r;
		} else {
			//alert("Handler could not be attached");
		}
	}
	
	function showID(id){
		box = document.getElementById(id);			
		display = (box.style.display == "block") ? "none" : "block";
		box.style.display = display;
	}

	function showHideProvider(v){
		pi = document.getElementById('providerinfo');		
		newHTML = '';
		if(v != 'Select your provider'){
			newH = document.getElementById(v);
			newHTML = newH.innerHTML;
		}
		
		pi.innerHTML = newHTML;
	}
	function limitText(limitField,limitNum) {
		if (limitField.value.length > limitNum) {
			limitField.value = limitField.value.substring(0, limitNum);
		} /*else {
			limitCount.value = limitNum - limitField.value.length;
		}*/
	}
	function cpublishBlog()
	{
		publishBlog = 'y';
	}
	function cpublishComment()
	{
		publishComment = 'y';
	}	
	function addblogCategory()
	{
		ajaxContent = '&base=blogging';
		if(document.getElementById("blogCategory").value!='' && document.getElementById("blogCategory").value!='general')
		{			
			aContent = ajaxContent+"&newCategory="+document.getElementById("blogCategory").value;	
			loadPage_("./editor.php","addCategory",aContent);
		}
		divtoload = 'reloadcategories';
	}
	function loadCategory()
	{
		ajaxContent = '&base=blogging';
		loadPage_("./editor.php","refreshCategories",ajaxContent);
		divtoload = 'blogCategories';
	}
	function transferOrig(id)
	{
		document.getElementById('new_'+id).innerHTML = document.getElementById('orig_'+id).innerHTML;
		//document.getElementById('');
	}
	function checkTemplate()
	{
		var elem = document.getElementById('template');
		if(elem != null && elem.id == 'fulton'){
			return true;
		} else {
		 	return false;
		}
	}
	
	var mouseX, mouseY;
	
	/* Added for Mantis ticket 813 2008-11-19 -Ryan*/
	/* Need to capture coordinates of the mouse click event. */
	function getClickLocation(event){
		//Get the browser type
		var strBrowser = navigator.appName;
		//get the coordinates based on the browser type.
		if(strBrowser.indexOf('Internet Explorer') > 0){
			mouseX = window.event.clientX;
			mouseY = window.event.clientY;
		} else {
			mouseX = event.clientX;
			mouseY = event.clientY;
		}
	}