function init(){
	posdetails();
}

function menuClickResult(data) {
	var lscript=data.split(":::");
	document.getElementById('maincontent').innerHTML=lscript[0];
	
	dhtmlLoadScript(lscript[1]);
	dhxLayout.cells("b").setText(" Live Courier v2.0 - " + lscript[2]);
	if (lscript[3] && lscript[3]==1){
		gridIntervalId = setInterval ( "isLoaded()", 500 );
		keeplog("Interval ID :" + gridIntervalId);
	}
}

function menuClick(id) {
	url = "../includes/php/generalfunctions.inc.php";
	what = "menuClickResult(req.responseText)";
	if (id=="logoff"){
		location.replace("logoff.php");	
	}else if (id=='show_log'){
		showhidewindows("logwindow");
	}else{
		DoCallback("action=switchpages&pageid="+ id);
	}
}

function posdetails() {
	obj=document.getElementById('livelogo');
	var objl=obj.name;
	var ovalue=obj.value;

	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}

	curleft = (curleft +100)
	curtop = (curtop - 180)
	document.getElementById('clivespot').style.left=curleft + 'px';
	document.getElementById('clivespot').style.top=curtop + 'px';
//	alert (curleft);	
}

function showclive(){
	if (document.getElementById('clivespot').style.visibility=='visible'){
		document.getElementById('clivespot').style.visibility='hidden';
	}else{
		document.getElementById('clivespot').style.visibility='visible'
	}
}

var Dom = {
		get: function(el) {
			if (typeof el === 'string') {
				return document.getElementById(el);
			} else {
				return el;
			}
		},
		add: function(el, dest) {
			var el = this.get(el);
			var dest = this.get(dest);
				dest.appendChild(el);
			},
		remove: function(el) {
			var el = this.get(el);
				el.parentNode.removeChild(el);
			}
	};

var entryGroup = {
		strAlertMsg: "",
		groupContainer: "",
		target:"",
		userin:"false",
	    addupdate: function(gform,gaction,urlcontent,whattodo,require){	
				query:"";
				this.query="";	
				this.strAlertMsg="";
				
				if (require==true){
					for(var ctr=0;ctr< Dom.get(gform).elements.length;ctr++){
						x=Dom.get(gform).elements[ctr];
						
						if (x.getAttribute('required')=="true" && (x.value=="" || x.value=="select"))
							this.strAlertMsg += x.title + "\n";
					}
				
				if (this.strAlertMsg!=""){alert (this.strAlertMsg+"\n"+"Can not be blank");return false;}
				}
				
				for(var ctr=0;ctr< Dom.get(gform).elements.length;ctr++){
					x=Dom.get(gform).elements[ctr];
					
					if (x.type=="text" || x.type=="select-one" || x.type=="select-multiple" || x.type=="hidden" || x.type=="textarea" || x.type=="checkbox" ){
						if (x.type=="checkbox" && x.checked==true){
							x.value=1;
						}else if(x.type=="checkbox" && x.checked==false){
							x.value=0;
						}
						if (this.query==""){
							this.query += x.id + "=" + x.value;
						}else{
							this.query += "&" + x.id + "=" + x.value;
						}
					}
				}
				if (this.userin=="true"){
					url = "../includes/php/"+urlcontent+".inc.php";
				}else{
					url = "includes/php/"+urlcontent+".inc.php";
				}
				
				if (whattodo==""){
					what = "entryGroup.alertuser(req.responseText)";
				}else{
					what = whattodo + "(req.responseText)";
				}
				DoCallback("action="+gaction+"&"+ this.query);
			},
	   		fillvalue: function (data){
	   			if (this.target!=""){
	   				document.getElementById(this.target).value=data;
	   			}
	   		},
	   		alertuser:function(data){
	   			alert(data);
	   		}
}
