//////////////////////////////////////////////////////
//													//
//					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_fields()
{
    var fx = document.getElementById('t1');
    var tbody = document.createElement("tbody");
    var tr  = document.createElement("tr");
	var th  = document.createElement("th");
    var td  = document.createElement("td");
    var inp1 = document.createElement("input");
	var inp2 = document.createElement("input");
	var inp3 = document.createElement("input");
	var inp4 = document.createElement("input");
	var inp5 = document.createElement("input");
	
	inp1.size = '12';
    inp1.type = 'text';
    inp1.name = 'art_no[]';
	inp1.value = '';
	
	inp2.size = '54';
	inp2.type = 'text';
    inp2.name = 'art_desc[]';
	inp2.value = '';
	
	inp3.size = '6';
	inp3.type = 'text';
    inp3.name = 'art_price[]';
	inp3.value = '';
	
	inp4.size = '12';
	inp4.type = 'text';
    inp4.name = 'art_site_capacity[]';
	inp4.value = '';
	
	inp5.size = '4';
	inp5.type = 'radio';
    inp5.name = 'service_id[]';
	inp5.value = '1';
	
    td.appendChild(inp1);
	td.appendChild(inp2);
	td.appendChild(inp3);
	td.appendChild(inp4);
	td.appendChild(inp5);
    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=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=640, height=480, left=60, top=60"); 
	fenster.focus();
}
/////////////////////////////////////////////////////
// Image opener
/////////////////////////////////////////////////////
function openshop(url) {
	fenster = window.open(url, "newwindow", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=806, height=540, left=60, top=60"); 
	fenster.focus();
}
