
      window.onDomReady = initReady_waizicross;
 
      // Initialize event depending on browser
      function initReady_waizicross(fn)
      {
      	//W3C-compliant browser
      	if(document.addEventListener) {
          document.addEventListener("DOMContentLoaded", fn, false);
        }
      	//IE
      	else {
          document.onreadystatechange = function(){readyState_waizicross(fn)}
        }
      }
 
      //IE execute function
      function readyState_waizicross(func)
      {
      	// DOM is ready
      	if(document.readyState == "interactive" || document.readyState == "complete")
      	{
      		func();
      	}
      }

function mySetCenter (obj) {
    obj.style.position = "absolute";
    obj.style.top = ( window.outerHeight - obj.style.height ) / 2 + window.pageYOffset  - 350 + "px";
    obj.style.left = ( window.outerWidth - obj.style.width ) / 2 - 200 +document.body.scrollLeft + "px";
    return obj;
}
function creat_popup_waizi()
{
    waizi_gesamt_window_top = document.body.scrollTop;
    if ( document.getElementById('waizitabelle_leistung_container') == null )
    {
        _container = document.createElement('div');
        _container.id = "waizitabelle_leistung_container";
        _win = document.createElement('div');
        _win.id = "waizmanntabelleleistung_window";
        
        _container.appendChild(_win);        
       
        document.body.appendChild(_container);
    }
    _container = document.getElementById('waizitabelle_leistung_container');
    
        
    _container.style.top = Math.floor(window.innerHeight/2) - 50 + waizi_gesamt_window_top;
    
    _container = mySetCenter(_container); 
}

var waizi_debug = false;

function debugRepeaterFunc()
    {    
        var debug_div = document.getElementById("debug_div");
        debug_div.style.position = 'absolute';
        debug_div.style.right = '0px';
        
        debug_div.innerHTML = 'pageYOffset: '+window.pageYOffset;
        
        debug_div.style.top = window.pageYOffset+'px';
    }

if ( waizi_debug )
{
    var _debug_div = document.createElement('div');
    _debug_div.id = "debug_div";
    _debug_div.innerHTML = "Debug div";
    
    document.body.appendChild(_debug_div);
    
    _debug_div.style.border = "1px solid #CCC;";
    _debug_div.style.padding = "5px";
    
    setInterval('debugRepeaterFunc()', 3000);
}

function removeDOM_id(element)
{
     var e = document.getElementById(element);
     if(!e)
          alert("There is no element with the id: "+element);
     //e.removeChild(e.childNodes[0]);
     e.parentNode.removeChild(e);
}

// Define the callback function
function getInfo_waizicross(jsonData) {
 document.getElementById("waizmanntabellecrossdomain").innerHTML = jsonData.app_view;  
 //document.getElementById("cross_wrapper_bottom_"+cross_appid_wir_helfen).innerHTML = jsonData.app_bottom;     
 //alert('Name = ' + jsonData.name);
 bObj_getinfo.removeScriptTag(); 
}

window.onDomReady(onReady_waizicross);
 
//do when DOM is ready
function onReady_waizicross()
{
	// The web service call
     var req = 'http://www.waizmanntabelle.de/waizicrossdomain_2011/controller/getinfo.php?callback=getInfo_waizicross&id='+waizmanntabelle_user_id;  
    // Create a new request object
    bObj_getinfo = new JSONscriptRequest( req ); 
    // Build the dynamic script tag
    bObj_getinfo.buildScriptTag(); 
    // Add the script tag to the page
    bObj_getinfo.addScriptTag();
}
function saveBewNeuCallback(jsonData)
{
    if (jsonData.erfolg) { alert('Ihre Bewertung wurde erfolgreich gespeichert!'); } else { alert('Ein Fehler ist aufgetreten!'); }
    
    removeDOM_id('waizitabelle_leistung_container');
    return false;
}
function save_bew_neu_waizicross( formObject, des )
{
    kommentar = document.getElementById('bew_form_waizzle_bew_text');
    if (kommentar.value == '') { alert('Bitte geben Sie Kommentar an!'); kommentar.focus(); return false;}
    
    email = document.getElementById('bew_form_waizzle_bew_email');
    if (email.value == '') { alert('Bitte geben Sie Ihre Email an!'); email.focus(); return false;}
    
    name = document.getElementById('bew_form_waizzle_bew_name');
    if (name.value == '') { alert('Bitte geben Sie Ihren Namen an!'); name.focus(); return false;}
    
    
    
    
    getstring = '';
    var myarr = [];
    for (var i=0;i<formObject.length;i++)
    {
        if ( ( formObject.elements[i].name != 'bew_user_art' && formObject.elements[i].name != 'bew_note_e') || formObject.elements[i].checked == true )
        {
            myarr.push( formObject.elements[i].name + '='+encodeURI( formObject.elements[i].value) );
        }
        
    }
    getstring = myarr.join('&');
    
    var req = 'http://www.waizmanntabelle.de/waizicrossdomain_2011/controller/save_bew_neu.php?callback=saveBewNeuCallback&id='+waizmanntabelle_user_id+'&'+getstring;;  
    // Create a new request object
    bObj_getinfo = new JSONscriptRequest( req ); 
    // Build the dynamic script tag
    bObj_getinfo.buildScriptTag(); 
    // Add the script tag to the page
    bObj_getinfo.addScriptTag();
    
    return false;
}

function getBewertungFormCallback(jsonData)
{
    creat_popup_waizi();       
    
    document.getElementById("waizmanntabelleleistung_window").innerHTML = jsonData.app_view;  
    
    bObj_getbew.removeScriptTag();
}

function get_bewertung_form( leistung_id )
{
    
     var req = 'http://www.waizmanntabelle.de/waizicrossdomain_2011/controller/get_bewertung_form.php?callback=getBewertungFormCallback&id='+waizmanntabelle_user_id+'&leistung_id='+leistung_id;  
    // Create a new request object
    bObj_getbew = new JSONscriptRequest( req ); 
    // Build the dynamic script tag
    bObj_getbew.buildScriptTag(); 
    // Add the script tag to the page
    bObj_getbew.addScriptTag();
}

function mehrTarifeCallback_waizicross(jsonData)
{
    document.getElementById("waizmanntabellecrossdomain_2").innerHTML = jsonData.app_view;
    bObj_mehr.removeScriptTag(); 
    window.location.hash="mehr_tarife_waizi";     
}

function mehr_tarife_waizicross()
{
    var req  = 'http://www.waizmanntabelle.de/waizicrossdomain_2011/controller/getinfo2.php?callback=mehrTarifeCallback_waizicross&id='+waizmanntabelle_user_id;

    bObj_mehr = new JSONscriptRequest(req); 
    bObj_mehr.buildScriptTag(); 
    bObj_mehr.addScriptTag();
    
}


function updateTableCallback_waizicross(jsonData)
{
    document.getElementById("waizmanntabellecrossdomain").innerHTML = jsonData.app_view;
    bObj_uptable.removeScriptTag(); 
    window.location.hash="vergleichsergebnis_waizi"; 
}

function update_table_waizicross()
{
    var tag = document.getElementById("tag_waizicross").value;
    var monat = document.getElementById("monat_waizicross").value;
    var jahr = document.getElementById("jahr_waizicross").value;
    var geschlecht = document.getElementById("geschlecht_waizicross").value;
    var luecke = document.getElementById("luecke_waizicross").value;
    var zb_lauf = document.getElementById("zb_lauf_waizicross").value;
    
    var req = 'http://www.waizmanntabelle.de/waizicrossdomain_2011/controller/update_table.php?callback=updateTableCallback_waizicross&id='+waizmanntabelle_user_id+'&tag='+tag+'&monat='+monat+'&jahr1='+jahr+'&geschlecht='+geschlecht+'&luecke='+luecke+'&zb_lauf='+zb_lauf;  
    
    bObj_uptable = new JSONscriptRequest( req );
    bObj_uptable.buildScriptTag(); 
    bObj_uptable.addScriptTag();    
    
    return false;
}

function wertFuerUserAnzeigen(jsonData) { 
    document.getElementById("waizi_schnellcheck").innerHTML = jsonData.app_view;  
    document.getElementById("waizi_schnellcheck_bottom").innerHTML = jsonData.app_bottom;     
    //alert('Name = ' + jsonData.name);
    bObj1.removeScriptTag(); 
}
function return_weizmannwert_fuer_user(jsonData)
{
    document.getElementById('wz_tarife_vergleich_result_fuer_user').innerHTML = jsonData.app_view;
}
function show_wz_tarife_vergleich_fuer_user(tarif_id)
{
    var req2  = 'http://www.waizmanntabelle.de/crossdomainfuncs/get_waizmannwert_fuer_user.php?callback=return_weizmannwert_fuer_user&tarif_id='+tarif_id+'&wert_fuer_user_user_id='+wert_fuer_user_user_id;  
    bObj2 = new JSONscriptRequest(req2); 
    bObj2.buildScriptTag(); 
    bObj2.addScriptTag();
}

function get_schnellcheck_waizicross()
{
    cross_appid_wert_fuer_user_anzeigen = 2667;
    cross_appstyle_wert_fuer_user_anzeigen = 0;
    wert_fuer_user_user_id = waizmanntabelle_user_id;
    
    
    creat_popup_waizi();   
    
    
    
    var _win = document.getElementById('waizmanntabelleleistung_window');
    
    div_win_close1 = document.createElement('div');
    div_win_close1.style.textAlign = 'right';
    win_close = document.createElement('a');
    win_close.style.fontSize = '12px';
    win_close.innerHTML = 'Fenster schliessen <img style="vertical-align: right; border: none;" src="http://www.waizmanntabelle.de/css/images/close.gif" />'
    win_close.href = "javascript:removeDOM_id('waizitabelle_leistung_container');";
    win_close.style.textAlign = 'right';
    div_win_close1.appendChild(win_close);
    _win.appendChild(div_win_close1);
    
    if ( document.getElementById('cross_wrapper_'+cross_appid_wert_fuer_user_anzeigen) == null )
    {
        _cross_wrapper = document.createElement('div');
        _cross_wrapper.id = 'cross_wrapper_'+cross_appid_wert_fuer_user_anzeigen;
        _win.appendChild(_cross_wrapper);
    }
    
    if ( document.getElementById('waizi_schnellcheck') == null )
    {
        var _waizi_schnellcheck = document.createElement('div');
        _waizi_schnellcheck.id = "waizi_schnellcheck";
        _cross_wrapper.appendChild(_waizi_schnellcheck);
    }
    if ( document.getElementById('waizi_schnellcheck_bottom') == null )
    {
        var _waizi_schnellcheck_bottom = document.createElement('div');
        _waizi_schnellcheck_bottom.id = "waizi_schnellcheck_bottom";
        _cross_wrapper.appendChild(_waizi_schnellcheck_bottom);
    }
    
    
    
    var _container = document.createElement('div');
    _container.id = "waizitabelle_leistung_container";
    var _win = document.createElement('div');
    _win.id = "waizmanntabelleleistung_window";
    
    
    

    // The web service call
    var req1  = 'http://www.waizmanntabelle.de/crossdomainfuncs/wert_fuer_user_anzeigen.php?callback=wertFuerUserAnzeigen'+'&app_id='+cross_appid_wert_fuer_user_anzeigen+'&app_style='+cross_appstyle_wert_fuer_user_anzeigen+'&wert_fuer_user_user_id='+wert_fuer_user_user_id;
    // Create a new request object
    bObj1 = new JSONscriptRequest(req1); 
    // Build the dynamic script tag
    bObj1.buildScriptTag(); 
    // Add the script tag to the page
    bObj1.addScriptTag();    
}



function wertFuerUserAnzeigen(jsonData) { 
    document.getElementById("waizi_schnellcheck").innerHTML = jsonData.app_view;  
    document.getElementById("waizi_schnellcheck_bottom").innerHTML = jsonData.app_bottom;     
    //alert('Name = ' + jsonData.name);
    bObj1.removeScriptTag();
    
    var _win = document.getElementById('waizmanntabelleleistung_window') 
    
    
    div_win_close2 = document.createElement('div');
    div_win_close2.style.textAlign = 'right';
    
    win_close1 = document.createElement('a');
    win_close1.style.fontSize = '12px';
    win_close1.innerHTML = 'Fenster schliessen <img style="vertical-align: right; border: none;" src="http://www.waizmanntabelle.de/css/images/close.gif" />'
    win_close1.href = "javascript:removeDOM_id('waizitabelle_leistung_container');";
    win_close1.style = 'text-align: right;';
    div_win_close2.appendChild(win_close1);
    _win.appendChild(div_win_close2);
}

function return_weizmannwert_fuer_user(jsonData)
{
    document.getElementById('wz_tarife_vergleich_result_fuer_user').innerHTML = jsonData.app_view;
}

function show_wz_tarife_vergleich_fuer_user(tarif_id)
{
    var req2  = 'http://www.waizmanntabelle.de/crossdomainfuncs/get_waizmannwert_fuer_user.php?callback=return_weizmannwert_fuer_user&tarif_id='+tarif_id+'&wert_fuer_user_user_id='+wert_fuer_user_user_id;  
    bObj2 = new JSONscriptRequest(req2); 
    bObj2.buildScriptTag(); 
    bObj2.addScriptTag();
}

function parseVergleichInfo_waizicross(jsonData)
{
    creat_popup_waizi();   
    
    _container.style.width = '640px';
    _win = document.getElementById('waizmanntabelleleistung_window');
    _win.style.width = '640px';
    
    document.getElementById("waizmanntabelleleistung_window").innerHTML = jsonData.app_view;  
    
    bObj3.removeScriptTag(); 

}



function get_vergleich_waizicross( user_id, wat )
{
    var req1  = 'http://www.waizmanntabelle.de/waizicrossdomain_2011/controller/get_vergleich.php?callback=parseVergleichInfo_waizicross&id='+waizmanntabelle_user_id+'&wat='+wat;

    bObj3 = new JSONscriptRequest(req1); 
    bObj3.buildScriptTag(); 
    bObj3.addScriptTag();
}


function parse_leistung_Info_waizicross(jsonData)
{
    creat_popup_waizi();       
    
    document.getElementById("waizmanntabelleleistung_window").innerHTML = jsonData.app_view;  
    
    bObj_leistung.removeScriptTag();
}

function get_leistung_info_waizicross( leistung_id, user_id, preis)
{
    var req  = 'http://www.waizmanntabelle.de/waizicrossdomain_2011/controller/get_leistung_info.php?callback=parse_leistung_Info_waizicross&id='+user_id+'&leistung_id='+leistung_id+'&preis='+preis;

    bObj_leistung = new JSONscriptRequest(req); 
    bObj_leistung.buildScriptTag(); 
    bObj_leistung.addScriptTag();
}


function getAngebotCallback_waizicross(jsonData)
{
    creat_popup_waizi();      
    
    document.getElementById("waizmanntabelleleistung_window").innerHTML = jsonData.app_view;  
    
    bObj_angebot_f.removeScriptTag();
    
    //return false;
}

function get_angebot_waizicross( leistung_id, user_id, preis )
{
    var req  = 'http://www.waizmanntabelle.de/waizicrossdomain_2011/controller/get_angebot_form.php?callback=getAngebotCallback_waizicross&id='+user_id+'&leistung_id='+leistung_id+'&preis='+preis;

    bObj_angebot_f = new JSONscriptRequest(req); 
    bObj_angebot_f.buildScriptTag(); 
    bObj_angebot_f.addScriptTag();
    
    //return false;
}

function submitAngebotFormCallback_waizicross(jsonData)
{
    alert(jsonData.app_view);
    bObj_sangebot_f.removeScriptTag();
    removeDOM_id('waizitabelle_leistung_container');
    return false;
}
function submitAngebotForm_waizicross()
{
    /* validation */
    vorname = document.getElementById('angebot_f_vorname');
    if (vorname.value == '') { alert('Bitte geben Sie Ihren Vornamen an!'); vorname.focus(); return false;}
    
    name = document.getElementById('angebot_f_name');
    if (name.value == '') { alert('Bitte geben Sie Ihren Namen an!'); name.focus(); return false;}
    
    geburt = document.getElementById('angebot_f_geburtstag');
    if (geburt.value == '') { alert('Bitte geben Sie Ihren Geburtstag an!'); geburt.focus(); return false;}
    
    email = document.getElementById('angebot_f_email');
    if (email.value == '') { alert('Bitte geben Sie Ihren Geburtstag an!'); email.focus(); return false;}
    /* end validation */
    
    formObject = document.getElementById('angebot_f_waizzle');
    getstring = '';
    var myarr = [];
    for (var i=0;i<formObject.length;i++)
    {
        myarr.push( formObject.elements[i].name + '='+encodeURI( formObject.elements[i].value) );
    }
    getstring = myarr.join('&');
    //alert(getstring);
    
    var req  = 'http://www.waizmanntabelle.de/waizicrossdomain_2011/controller/submit_angebot_form.php?callback=submitAngebotFormCallback_waizicross&id='+waizmanntabelle_user_id+'&'+getstring;

    bObj_sangebot_f = new JSONscriptRequest(req); 
    bObj_sangebot_f.buildScriptTag(); 
    bObj_sangebot_f.addScriptTag();
   // alert(formObject.join(" and "));
    return false;
}


