function OpenPopup(href,target,width,height) {
	if(!target) { target='_blank'; }
	if(!width) { width=650; }
	if(!height) { height=700; }
	var popup=self.open(href,target,'width='+width+'px,height='+height+'px,status=no,toolbar=no,scrollbars=yes,resizable=yes,menubar=no,location=no');
	popup.focus();
	return popup;
}


function AppendURLParameter(reftext,parameter) {
	if(reftext.indexOf('?') > 0) {
		return reftext + '&' + parameter;
	}
	return reftext + '?' + parameter;
}

//Popup Sperre:
var popup_running=false;
var popup_window;
function is_popup_active() {
	if(popup_running) {
		alert("Popup bereits offen!");
		popup_window.focus();
		return false;
	}
	return true;
}
// !!!ACHTUNG php_self muss via PHP gesetzt werden (Session ID!!)!!!
function CheckPopup() {
	if(!php_self) {
		Alert("Fehlendes php_self in js");
	}
	popup_running=true;
	if(popup_window) {
		if(popup_window.closed == false) {
			window.setTimeout("CheckPopup()", 500);
			return;
		}
	}
	popup_running=false;
	var reftext=php_self;
	self.open(reftext,'_self');
}

//value des selektierten combo feldes oder false:
function get_selected(select_field,alert_user) {
	var sel=select_field.selectedIndex;
	if((sel<0) || isNaN(sel)) {
		if(alert_user) { alert('Bitte zuerst auswaehlen'); }
		select_field.focus();
		return false;
	}
	var typ_id=select_field[sel].value;
	if(typ_id<1) {
		if(alert_user) { alert('Bitte zuerst auswaehlen'); }
		select_field.focus();
		return false;
	}
	return typ_id;
}

//Rundschau Mobile Demo:
function ShowMobileRundschau() {
	var popup=self.open('http://mobile.rundschau.at','_blank','"scrollbars=no,width=185,height=300",status=no,toolbar=no,resizable=yes,menubar=no,location=no');
	popup.focus();
}

/**ergibt ein <div id="name"> HTML Objekt**/
function GetDocItem(name) {
	var obj;
	if(!obj) {
		if(document.all) {  		//ie
			obj=document.all[name];
		}
	}
	if(!obj) {
		if(document.layers) {		//netscape < 7
			obj=document.layers[name];
		}
	}
	if(!obj) {						//netscape 7
		obj=document.getElementById(name);
	}
	if(!obj) {
		alert("**kw**GetDocItem Failed");
		return 0;
	}
	return obj;
}

////////////////////////////////////////////////////////
//div behandlung
////////////////////////////////////////////////////////
// Browser abfrage
var div_browser="";
var divpos_x=0;
var divpos_y=0;
if (navigator.appName.indexOf("Netscape")!=-1) {	//Wenn Netscape
	if (document.layers) { 	//NS4
		div_browser="NS4";
	} else {
		div_browser="NS6"; 		//NS6
	}
}
if (document.all) {			//sonst IE 4 >
	div_browser="IE";
}
if(div_browser=="NS4") {
	document.onmouseover = div_position;
} else if(div_browser=="NS6") {
	document.onmouseover = div_position;
}

function div_position(Ereignis) {
	divpos_x=Ereignis.pageX;
	divpos_y=Ereignis.pageY;
}

// Show Div
function div_show(lay) {
	var lay;
	lay=GetDocItem(lay);
	
	if(div_browser=="NS4") {
		//document.onmouseover = div_position;
	} else if(div_browser=="NS6") {
		//document.onmouseover = div_position;
	} else if(div_browser=="IE") {
		divpos_x=document.body.scrollLeft+event.clientX;
		divpos_y=document.body.scrollTop+event.clientY;
	}
	lay.style.top=divpos_y;	// Mausposition top
	lay.style.left=divpos_x;	// MausPosition left;
}

function div_show_position(lay,x,y) {
	var lay;
	lay=GetDocItem(lay);
	
	lay.style.top=y;
	lay.style.left=x;
}

// Hide Div
function div_hide(lay) {
	var lay;
	lay=GetDocItem(lay);
	lay.style.left=-900;
}

//füge text an die selektion eines textfeldes ein:
//preText selection postText
function textfield_insert(field,preText,postText,delSel) {
	var selectedText;
	var newText;
	field.focus();
	if(document.selection) {
		selectedText=document.selection.createRange().text;
		newText=preText+selectedText+postText;
		document.selection.createRange().text=newText;
	}else {
		fieldText=field.value;
		selectedText=fieldText.substring(field.selectionStart, field.selectionEnd);
		if(delSel) {
			newPart=preText+postText;
		} else {
			newPart=preText+
					fieldText.substring(field.selectionStart, field.selectionEnd)+
					postText;
		}
		newText=fieldText.substring(0, field.selectionStart)+
				newPart+
				fieldText.substring(field.selectionEnd);
		pos=field.selectionStart+newPart.length;
		field.value=newText;
		field.selectionStart=pos;
		field.selectionEnd=pos;
	}
}

