function popup(url,w,h)
{
	atr = '';
	atr = atr + 'toolbar=no,';
	atr = atr + 'scrollbars=yes,';
	atr = atr + 'location=no,';
	atr = atr + 'statusbar=no,';
	atr = atr + 'menubar=no,';
	atr = atr + 'resizable=yes,';
	if (w) {
	atr = atr + 'width='+w+',';
	atr = atr + 'height='+h;
	}
	else{
	atr = atr + 'width=700,';
	atr = atr + 'height=500';
	}
	new_window=window.open(url,'popup',atr);
	new_window.focus();
}

function goopener (url)
{
window.opener.focus();
window.opener.location=url;
window.close();
}

function goback (url) {
window.location=url;
}

function SetFocus() {
  if (document.forms.length > 0) {
    var field = document.forms[0];
    for (i=0; i<field.length; i++) {
      if ( (field.elements[i].type != "image") && 
           (field.elements[i].type != "hidden") && 
           (field.elements[i].type != "reset") && 
           (field.elements[i].type != "submit") ) {

        document.forms[0].elements[i].focus();

        if ( (field.elements[i].type == "text") || 
             (field.elements[i].type == "password") )
          document.forms[0].elements[i].select();
        
        break;
      }
    }
  }
}

function confirmlink(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
    var is_confirmed = confirm('Warning :\n' + theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }
    return is_confirmed;
} // end of the 'confirmLink()' function

//------------------------------------//
function dropFile(btn){
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'TR') tr = tr.parentNode;
		tr.parentNode.removeChild(tr);
		checkForLast();
	}	
}
function addFile(btn){
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'TR') tr = tr.parentNode;
		var idSuffix = Math.round(Math.random()*1000);
		var newTr = tr.parentNode.insertBefore(tr.cloneNode(true),tr.nextSibling);
		thisChilds = newTr.getElementsByTagName('td');
		for (var i = 0; i < thisChilds.length; i++){
			if (thisChilds[i].className == 'header') thisChilds[i].innerHTML = '';
		}
		qty = document.getElementsByName('qty[]');
		if (qty.length>0)  {
			for (var i = 0; i < qty.length; i++)
				qty[i].value=(i+1);
		}
		checkForLast();
	}	
}
