//////////////////////////////////////////////////////
//													//
//					JS-Functions					//
//													//
//////////////////////////////////////////////////////


/////////////////////////////////////////////////////
//	Resize handler to prevent the Netscape Resize-Bug
/////////////////////////////////////////////////////
if(document.ids)window.onLoad=function(){
	var origWidth=innerWidth;
	var origHeight=innerHeight;
	function initResize(){onResize=
	function(){
	if((innerWidth!=origWidth)||
		(innerHeight!=origHeight))
		self.location.href=location.href;}}
	initResize();}

/////////////////////////////////////////////////////
// PopUp Opener
/////////////////////////////////////////////////////
var pop = null;
function popdown() {
  if (pop && !pop.closed) pop.close();
}
function popup(obj,w,h) {
  var url = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
  if (!url) return true;
  w = (w) ? w += 20 : 150;  // 150px*150px is the default size
  h = (h) ? h += 25 : 150;
  var args = 'width='+w+',height='+h+',resizable';
  popdown();
  pop = window.open(url,'',args);
  return (pop) ? false : true;
}
window.onunload = popdown;
window.onfocus = popdown;

/////////////////////////////////////////////////////
// Dynamically form field creation
/////////////////////////////////////////////////////
function insert_file_input()
{
    var fx = document.getElementById('t1');
    var tbody = document.createElement("tbody");
    var tr  = document.createElement("tr");
    var td  = document.createElement("td");
    var inp = document.createElement("input");
    inp.size = 80;
    inp.type = 'text';
    inp.name = 'voting_question[]';

    td.appendChild(inp);
    tr.appendChild(td);
    tbody.appendChild(tr);
    fx.appendChild(tbody);
}

/////////////////////////////////////////////////////
// Dynamically form field creation
/////////////////////////////////////////////////////
function insert_range_input()
{
    var fx = document.getElementById('t1');
    var tbody = document.createElement("tbody");
    var tr  = document.createElement("tr");
    var td  = document.createElement("td");
    var inp1 = document.createElement("input");
	var inp2 = document.createElement("input");
    inp1.size = 20;
    inp1.type = 'text';
    inp1.name = 'range_value[]';
	inp2.size = 20;
	inp2.type = 'text';
    inp2.name = 'range_price[]';
    td.appendChild(inp1);
	td.appendChild(inp2);
    tr.appendChild(td);
    tbody.appendChild(tr);
    fx.appendChild(tbody);
}

/////////////////////////////////////////////////////
// Confirm on submit
/////////////////////////////////////////////////////
function confirmSubmit(frmObj){
	if (confirm("Sind Sie sicher, daß Sie diesen Eintrag speichern wollen?")) return true; 
 	else return false; 
}
/////////////////////////////////////////////////////
// Confirm on delete
/////////////////////////////////////////////////////
function confirmDelete(){
	if (confirm("Sind Sie sicher, daß Sie diesen Eintrag löschen wollen?")) return true; 
 	else return false; 
}
/////////////////////////////////////////////////////
// PopUp opener
/////////////////////////////////////////////////////
function popup(url) {
	fenster = window.open(url, "newwindow", "toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, width=1024, height=768, left=120, top=120"); 
	fenster.focus();
}
/////////////////////////////////////////////////////
// Image opener
/////////////////////////////////////////////////////
function openimage(url) {
	fenster = window.open(url, "newwindow", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=800, height=600, left=60, top=60"); 
	fenster.focus();
}