// TO POPUP CONTENT!
var myw = self.screen.width;
function popup(URL, w, h) {
	var popup = window.open (URL,"Popup",'top=550,left='+(myw-w-30)+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h);
	if( navigator.appName.substring(0,8) == "Netscape" ) {
		popup.location = URL;
	}
} 
self.name = "content";

//	JUST USE 
//  <a href="#" onclick="popup('popup.html', 350, 180);">
//	TO POPUP CONTENT
//
//












function openAWindow( pageToLoad, winName, width, height, center) {
  xposition=0; yposition=0;
  if ((parseInt(navigator.appVersion) >= 4 ) &&(center)) {
   xposition = (screen.width - width) / 2;
   yposition = (screen.height - height) / 2;
  }
  args = "width=" + width + ","
  + "height=" + height + ","
  + "location=0,"
  + "menubar=1,"
  + "resizable=1,"
  + "scrollbars=1,"
  + "status=0,"
  + "titlebar=1,"
  + "toolbar=1,"
  + "hotkeys=0,"
  + "screenx=" + xposition + "," //NN Only
  + "screeny=" + yposition + "," //NN Only
  + "left=" + xposition + "," //IE Only
  + "top=" + yposition; //IE Only
  window.open( pageToLoad, winName, args );
}
// add and remove thousands separators
function addCommas( sValue ) {

//	var f=sValue;
	sValue = String(sValue);

	//sValue = String(sValue).split(',');
	//sValue = sValue.join('|');

	//alert("d:"+sValue)

	var sRegExp = new RegExp('(-?[0-9]+)([0-9]{3})'); 
	while(sRegExp.test(sValue)) { 
		sValue = String(sValue).replace(sRegExp, '$1|$2');
	}

	sValue = sValue.split('.');
	sValue = sValue.join(',');

	sValue = sValue.split('|');
	sValue = sValue.join('.');

//	alert('Add: '+f+'=>'+sValue);

	return sValue; 
}
function removeCommas( sValue ) {

//	var f=sValue;

	sValue = String(sValue).split(',');
	sValue = sValue.join('|');



/*
	var sRegExp = new RegExp('/\./');
	while(sRegExp.test(sValue)) { 
		sValue = String(sValue).replace(sRegExp, '');
	}*/

	sValue = sValue.split('.');
	sValue = sValue.join('');

	sValue = sValue.split('|');
	sValue = sValue.join('.');

//	alert('Remove: '+f+'=>'+sValue);

	return sValue;
}

//alert(addCommas('500.10'));

/*
function addCommas( sValue ) { 
	var sRegExp = new RegExp('(-?[0-9]+)([0-9]{3})'); 
	while(sRegExp.test(sValue)) { 
		sValue = String(sValue).replace(sRegExp, '$1,$2');
	}
	return sValue; 
}
function removeCommas( sValue ) {
	var sRegExp = new RegExp(',');
	while(sRegExp.test(sValue)) { 
		sValue = String(sValue).replace(sRegExp, '');
	}
	return sValue;
}
*/

// netto + ust = brutto
function addFields(one, two, target) {
	//target.value = parseInt(one.value,10) + parseInt(two.value,10);
	var v = Number(one.value) + Number(two.value);
	v = v*100;
	v = Math.round(v);
	v = v/100;

	if (Math.round(v) == v) {
		v = String(v)+'.00';
	}


	target.value = v;
}

function subFields(one, two, target) {
	//target.value = parseInt(one.value,10) + parseInt(two.value,10);
	var v = Number(one.value) - Number(two.value);
	v = v*100;
	v = Math.round(v);
	v = v/100;

	if (Math.round(v) == v) {
		v = String(v)+'.00';
	}

	target.value = v;
}


/*
##################################
# open/close items with arrow
##################################
*/
function pfeil() {

	// passed external arguments
	if (pfeil.arguments.length>0) {
		
		var n1 = 1;
		for (var t=0; t<pfeil.arguments.length/2 ;t++ ) {

			while (eval("document.main.getVar"+n1).value.length>0) {
				n1++;
			}

			// transform the arguments into variables and values
			eval("document.main.getVar"+n1).value = pfeil.arguments[(n1-1)*2];
			eval("document.main.getVal"+n1).value = pfeil.arguments[(n1*2)-1];
		}
	}

	// try to submit the form
	if (save(document.main, 'main')) {
		document.main.submit();
	}
}



// DeleteObject
function dObj(loc, id, session) {
	if (confirm("Sind Sie sicher, dass Sie dieses Objekt wirklich löschen wollen?\nEs ist nicht rückgängig machbar!")) {
		//alert("Löschen funktioniert gerade nicht!");
		window.location.href="?l="+loc+"&rid="+id+"&"+session;
	}
}


function dDisabled() {
	window.status = 'Menüfunktion nicht gestattet!';
}

function hilightMe(obj, onoff) {
	if (onoff == 1) {
		obj.tmpClassName = obj.className;
		obj.className = "psHilight";
	} else {
		obj.className = obj.tmpClassName;
	}
}

// General Save Function
var savedalready = false;
function save(obj, objname) {
	var returnval = true;
	if (savedalready) {
		returnval = false;
		savedalready = false;
		//alert('Sie haben zwei Mal Speichern gedrückt.\n\nNur das erste Versuch wird akzeptiert!');
	}
	obj.id.disabled = false;

	// Check for custom processing functions
	if (returnval == true) {
		if (submit_handler) {
			returnval = submit_handler(objname);
		}
	}

	// Allow only one click
	if (returnval == true) {
		obj.Submit.disabled = true;
		savedalready = true;
	}
	return returnval;
}

// Search results
function sresults(nr) {
	document.searchform.sstart.value = nr;
	document.searchform.submit();
}

function closewindow() {
	if (confirm("Wollen Sie wirklich das Fenster schließen?\nDie Änderungen werden nicht gespeichert!")) {
		top.close();
	}
}

// converts all commas (,) to points (.) in currencies because SQL handles only points as separators
function sqlValue(obj) {
	var v = String(obj.value);
	if (v.indexOf(",") != -1) {
		var a=v.split(",");
		v=String(a[0]+"."+a[1]);
		obj.value=v;
	}
}
// null function
function nll() {
}
/*
// Browser version check
function Is () {
	var agt=navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);

	this.mac = agt.indexOf('mac') != -1;
	this.ie = agt.indexOf('msie') != -1;
	this.mz = agt.indexOf('gecko') != -1;
	this.win = agt.indexOf('win') != -1;

	// debugging only
	window.status = agt;
}
*/
function sparrechner(){
var pageToLoad = "_statischeseiten/sparrechner/sparrechner2.html";
var winName = "sparrechner";
var width = 610;
var height = 460;
var	center = 1;


xposition=0; yposition=0;
xposition = ((screen.width - width) / 2);
yposition = ((screen.height - height) / 2 );
args = "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=0,"
+ "scrollbars=0,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //NN Only
+ "screeny=" + yposition + "," //NN Only
+ "left=" + xposition + "," //IE Only
+ "top=" + yposition; //IE Only
window.open( pageToLoad, winName, args );
}




function frachtenfinder(){
var pageToLoad = "_statischeseiten/con_nieder.php";
var winName = "frachtenfinder";
var width = 610;
var height = 460;
var	center = 1;


xposition=0; yposition=0;
xposition = ((screen.width - width) / 2);
yposition = ((screen.height - height) / 2 );
args = "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=0,"
+ "scrollbars=0,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //NN Only
+ "screeny=" + yposition + "," //NN Only
+ "left=" + xposition + "," //IE Only
+ "top=" + yposition; //IE Only
window.open( pageToLoad, winName, args );
}



function forum(){
var pageToLoad = "_statischeseiten/forum/con_forum.php";
var winName = "forum";
var width = 635;
var height = 600;
var	center = 1;


xposition=0; yposition=0;
xposition = ((screen.width - width) / 2);
yposition = ((screen.height - height) / 2 );
args = "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=0,"
+ "scrollbars=0,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //NN Only
+ "screeny=" + yposition + "," //NN Only
+ "left=" + xposition + "," //IE Only
+ "top=" + yposition; //IE Only
window.open( pageToLoad, winName, args );
}

function fahrzeugboerse(){
var pageToLoad = "_statischeseiten/fahrzeugboerse/con_fz.php";
var winName = "fahrzeugboerse";
var width = 1000;
var height = 600;
var	center = 1;


xposition=0; yposition=0;
xposition = ((screen.width - width) / 2);
yposition = ((screen.height - height) / 2 );
args = "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=1,"
+ "scrollbars=0,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //NN Only
+ "screeny=" + yposition + "," //NN Only
+ "left=" + xposition + "," //IE Only
+ "top=" + yposition; //IE Only
window.open( pageToLoad, winName, args );
}
