

// DOM for all browsers
//
function obj(name) {
	if(document.all) 	return eval("document.all."+name);
	else 				return document.getElementById(name);
}




function set_mailto( id , who , where , subject , body ) {
	where = where.replace(/\*/g, ".");
	obj(id).href="mailto:"+who+"@"+where;
	if( obj(id).innerHTML == "mail") {
		obj(id).innerHTML=who+"@"+where;
	}
}




////////////////////////////////////////////////////////////////////////////////////////////////////////////
// automatic window resize code

var old_dest_x=0;

function window_resize_interval() {
	// init
	// setpos("aussenrum",lastx_size,lasty_size);

	var elmnt=obj("aussenrum");

	// only if exists (i.e. not in popups or in case of error)
	if( elmnt ) {
		elmnt	= elmnt.style;
		var dest_x;
	
		if (window.innerWidth) dest_x = window.innerWidth;
		else if (document.body && document.body.offsetWidth) dest_x = document.body.offsetWidth;
		else dest_x = 0;
	
		dest_x = (dest_x-800)/2 ;
	
		if ( dest_x < 0 ) dest_x =0 ;

		if( dest_x != old_dest_x ) {
			elmnt.left = dest_x;
			old_dest_x=dest_x;
		}
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////



// open popup window
function new_window(uri,name,w,h,scroll,mode) {
	var left, top;
	left = (screen.width/2) - (w/2);
	top = (screen.height/2) - (h/2);
	
	if( name=="RANDOM" ) {	
		name = "RANDOM"+Math.round( 999999 * Math.random()); // "always" create new window... ok, good enough.
	}
	
	if(mode=='pop') { 
		popup = window.open(
			uri,
			name,
				'width=' + w + 
				',height=' + h + 
				',left=' + left + 
				',top=' + top + 
				',resizable=1,toolbar=0,scrollbars=' + scroll +',menubar=0,directory=0,status=0');
	} else 	if(mode=='this') { 
		document.location.href=uri;
	} else 	if(mode=='blank') { 
		popup = window.open(
			uri,
			name,
				'width=' + w + 
				',height=' + h + 
				',left=' + left + 
				',top=' + top + 
				',resizable=1,toolbar=1,scrollbars=1,menubar=1,directory=1,status=1');
	}
}


function yesno( id ) {
	var ob= "linkcount"+id ;
	ob=obj( ob ).getAttribute("href2");
	if( confirm("Wollen Sie die Anzeige wirklich loeschen?")  ) document.location.href=ob;
}


	
function edit( table , id , field , areamode) {
	new_window("../sale/edit.php?table="+table+"&id="+id+"&field="+field+"&areamode="+areamode , "" ,400 , 400 , 0 , 'blank' );
}




