ADMIN={};ADMIN.entry=function(site){	var thisObj = this;	this._data={};	this._data["site"] = site;	if(typeof this.headline=="undefined")this.headline=[];		this.init=function(refObj, type, editor){		this._type=type;		var thisObj = this;		if(typeof this.headline[type]=="undefined")			this.headline[type] = new Lib.IFrameEdit(refObj, editor, function(rq){thisObj.setVar(thisObj._type, rq);}, function(rq){thisObj.save(thisObj._type, rq);});		this.headline[type].init();	},	this.setVar=function(name, request){		request = GLOBAL.texttohtml(request);		this._data[name]=request;		//alert(JSON.stringify(this._data));	},	this.save=function(name, request){		//this._data[name]=GLOBAL.texttohtml(this._data[name]);		//alert(GLOBAL.PATH);		REQUEST.send(GLOBAL.PATH+"script/adminSite.php5", "POST", "data="+JSON.stringify(this._data), "text", function(re){thisObj.reloadSite();});	},	this.reloadSite=function(re){		location.reload();		/*if(typeof re !="undefined" && re !=''){			if(re == 'update')				location.reload();			else if(re == 'insert')				location.replace(GLOBAL.PATH + 'en/blog' );		}else{			location.reload();		}*/	}}ADMIN.dbentry=function(db, id, save, arr){	var thisObj = this;	this._data={};	this._data["db"] = db;	this._data["id"] = id;	this._data["content"] = [];		if(typeof arr!="undefined"){		//alert(arr);		for(var i=0; i<arr.length;i++)			if(document.getElementById(arr[i])!=null)				this._data["content"].push({"type":arr[i], "content":document.getElementById(arr[i]).firstChild.nodeValue});	}	//this._type["type"] = type;		this._savebut = save;	if(typeof this.headline=="undefined")this.headline=[];	this.init=function(refObj, type, editor){		this._temptype=type;		this._refObj = refObj;		var temp=0;		for(var i=0; i<this._data["content"].length;i++)			if(this._data["content"][i].type==type)				temp=1;		if(temp===0)			this._data["content"].push({"type":type, "content":this._refObj.firstChild.nodeValue});					var thisObj = this;				if(typeof this.headline[type]=="undefined")			this.headline[type] = new Lib.IFrameEdit(this._refObj, editor, function(rq){thisObj.save(thisObj._temptype, rq);}, thisObj.saveData);		this.headline[type].init();		//this.addSaveBut();	};	this.save=function(name, request){		for(var i=0; i<this._data["content"].length;i++){						if(this._data["content"][i].type==name){				//if(this._data["content"][i].type=='Headline')					//request = strip_tags(request, '');				request = GLOBAL.texttohtml(request);				this._data["content"][i].content=request;			}		}		if(!this._savebut)			thisObj.saveData();	};	/*this.addSaveBut=function(){		var thisObj = this;		if(this._savebut && document.getElementById("savebut")==null){			var savebut = PTDoom.create("div");				savebut.id="savebut";			savebut.onclick=function(){				thisObj.saveData();			}			$(savebut).append("save");			$(this._refObj.parentNode).append(savebut);		}	};*/	this.saveData=function(){		//alert(JSON.stringify(thisObj._data));				del=false;		for(var i=0; i<thisObj._data.content.length;i++){			if(thisObj._data.content[i].content=='<br>' || thisObj._data.content[i].content==''){				del=true;			}		}		if(del){			check = confirm('Delete entry?');			if (check) {					REQUEST.send(GLOBAL.PATH + "script/adminDb.php5", "POST", "data=" + JSON.stringify(thisObj._data), "text", function(re){						thisObj.reloadSite(re)					});			}			if(check==false){				this.headline[this._temptype].showRefObj();				this.headline[this._temptype].saveButli.firstChild.nodeValue = "save";							}		}else{			REQUEST.send(GLOBAL.PATH + "script/adminDb.php5", "POST", "data=" + JSON.stringify(thisObj._data), "text", function(re){				thisObj.reloadSite(re)			});		}						};	this.setVars=function(arr){		if(typeof arr!="undefined"){			for(var i=0; i<arr.length;i++)				this._data["content"].push(arr[i]);		}	};	this.reloadSite=function(re){		if(typeof re !="undefined" && re !=''){			if (re == 'update') {				alert('entry successfully changed');				this.headline[this._temptype].showRefObj();				this.headline[this._temptype].saveButli.firstChild.nodeValue = "save";			}else if (re == 'delete') 				location.replace(GLOBAL.PATH + 'en/blog');			else if (re == 'error') 				alert('error: please refresh and try again');			else if (re == 'blog') 				location.replace(GLOBAL.PATH + 'en/blog');			else if (re == 'texte') 				location.replace(GLOBAL.PATH + 'en/text');			else{				alert(re);				//location.reload();			}						}else{			location.reload();		}	}}GLOBAL={};GLOBAL.texttohtml = function(text){	/*text = text.replace(/&/g, "&amp;");	text = text.replace(/</g, "&lt;");	text = text.replace(/>/g, "&gt;");*/		text = text.replace(/'/g, "&prime;");	//text = text.replace(/"/g, "&quot;");	text = text.replace(/&/g, '#und#');		/*text = text.replace(/   /g, "&nbsp; &nbsp;");	text = text.replace(/  /g, "&nbsp; ");	text = text.replace(/\n /g, "<br>&nbsp;");	text = text.replace(/\n/g, "<br>");*/	return text;}GLOBAL.texttoLinks = function(text){	//text = text.replace(/[http:\/\/]*(w{3}\.\S+\.\S+)/ig, '<a href="http://$1" target="_blank">$1<\/a>');	//text = text.replace(/([\w\.]{3,}@[\w\.\-_]{3,}\.[a-z]{2,3})/ig, '<a href="mailto:$1">$1</a>');	return text;}GLOBAL.htmltotext = function(text){	text = text.replace(/&amp;/g, "&");	text = text.replace(/<br>/g, "\n");	text = text.replace(/&lt;/g, "<");	text = text.replace(/&gt;/g, ">");	text = text.replace(/&quot;/g, "\"");	//text = text.replace(/<br>/g, "\n");	text = text.replace(/&nbsp;/g, " ");	text = GLOBAL.strip_Tags(text);	return text;}GLOBAL.strip_Tags=function(string){	return string.replace(/(<([^>]+)>)/ig,"");}