//
// Globale Variablen:
//



var handleFailure = function(o){
	if(o.responseText !== undefined){
		div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
		div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
		div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
	 YAHOO.example.container.wait.hide();
 }
};


//
// Funktionen
//


function gotoid(form,action,maske,div,load) {
 do_submit(form,action,maske,div,load);
// var nid = form.elements["tmp_nid"].value; 
// document.getElementById(nid).focus();
}


// prüft ob die Taste "Enter" gedrückt wurde....bekommt das event in 'e' übergeben
function do_entersubmit(e,form,action,maske,div,load) {
 var obenter = checkEnter(e);
 if (obenter) {
  do_submit(form,action,maske,div,load)
 }
}

function do_submit(form,action,maske,div,load,ajaxtype) {
 var divcont = document.getElementById(div);
 //alert("Submit: Maske: "+maske+" Div: "+div);
 var handleSuccess = function(o){
  if(o.responseText !== undefined){
   divcont.style.display = "block";
   divcont.innerHTML = o.responseText;
   YAHOO.example.container.wait.hide(); 
	 }
 };
 
 var handleFailure = function(o){
  	alert("Failure");
   if(o.responseText !== undefined){
  		divcont.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
  		divcont.innerHTML += "<li>HTTP status: " + o.status + "</li>";
  		divcont.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
  	 YAHOO.example.container.wait.hide();
   }
  };
 
 var callback = {
  success:handleSuccess,
  failure:handleFailure,
  argument:['foo','bar']
 };
 if (form) {YAHOO.util.Connect.setForm(form);} 
 var postData = "ajax_"+maske+"&btn_"+action+"="+action;
 
 if (ajaxtype == 'm') {
  var modulname = 'shop/warenkorb';
  postData = "najax_"+maske+"&najaxmodul_"+modulname+"&btn_"+action+"="+action; 
 }

 
 var cObj = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); 
 // var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
 if (load == undefined) {YAHOO.example.container.wait.show();}
}

function do_upload(form,action,maske) {
  var handleUpload = function(o){
 	 if(o.responseText !== undefined){
    alert(o.responseText);
 	 }
  };
  var callback = {
   failure:handleFailure,
   upload: handleUpload,
   argument:['foo','bar']
  };
  alert("Vor set form");
  if (form) {YAHOO.util.Connect.setForm(form,true,true);} 
  alert("Nach set form");
  var postData = "ajax_"+maske+"&btn_"+action+"="+action;
 	var cObj = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); 
  alert("Nach connect");
}


function div_leeren(ldiv){
 var div = document.getElementById(ldiv);
 div.style.display = "none";
 div.innerHTML = '';
}

function setload(div) {
 div.innerHTML = '<div align="center"><br /><br /><br /><img src="/base/cw/img/layout/load.gif" border="1"></div>'; 
}

function openpanel (form,maske,action) {
 YAHOO.example.container.wait.show();
 var div = document.getElementById("panel");
 div.style.display = "block";

 var divcont = document.getElementById('panelcontent');
 var handleSuccess = function(o){
	 if(o.responseText !== undefined){
   //var pop_width  = parseFloat(o.responseText.substring(0,4));
   //var pop_height = parseFloat(o.responseText.substring(5,8));
   //var pop_xpos   = parseFloat(o.responseText.substring(9,12));
   //var pop_ypos   = (e.pageY)-(150);
   //YAHOO.example.container.panel.cfg.setProperty("width",pop_width+"px");
   //YAHOO.example.container.panel.cfg.setProperty("height",pop_height+"px"); 
   //YAHOO.example.container.panel.cfg.setProperty("x",pop_xpos);   
   //YAHOO.example.container.panel.cfg.setProperty("y",pop_ypos);
   //divcont.innerHTML = o.responseText.substring(12);
   divcont.innerHTML = o.responseText;

   YAHOO.example.container.panel.show();
	  YAHOO.example.container.wait.hide(); 
  }
 };
 var callback = {
  success:handleSuccess,
  failure:handleFailure,
  argument:['foo','bar']
 };
 if (form) {YAHOO.util.Connect.setForm(form);} 
 var postData = "ajax_"+maske+"&btn_"+action+"="+action;
 var cObj = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);  
}








function setdspanelpos(pannel,table,width,height,xpos) {
 var handleSuccess = function(o){
	 if(o.responseText !== undefined){ // div.style.width  = "100px"; // div.style.height = "120px"; // div.style.left   = "100px"; // div.style.top    = "100px";
   alert(o.responseText);
  }
 };
 var callback = {
  success:handleSuccess,
  failure:handleFailure
 };
 var postData = "ajax_ds_vorschau_setpos&tmp_pannel="+pannel+"&tmp_suchtabelle="+table+"&tmp_width="+width+"&tmp_heigth="+height+"&tmp_xpos="+xpos;
	var cObj = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); 
}



