var mpUrl='modality_pages.php';
var mDiv='modalityDIV';
var checkTXT='';

function ahah(url,vars, target) {
	document.getElementById(target).innerHTML =  '';
   if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {ahahDone(target);};
        req.open("POST", url, true);
		req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        req.send(vars);
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {ahahDone(target);};
            req.open("POST", url, true);
			req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            req.send(vars);
        }
    }
}

function ZM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ahahDone(target) {
   // only if req is "loaded"
   if (req.readyState == 4) {
       // only if "OK"
       if (req.status == 200 || req.status == 304) {
           results = req.responseText;
           document.getElementById(target).innerHTML =  results;
       } else {
           document.getElementById(target).innerHTML="ahah error:\n" +
               req.statusText;
       }
   }
}

function ahahTXT(url) {
   if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {ahahDoneTXT();};
        req.open("GET", url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {ahahDoneTXT();};
            req.open("GET", url, true);
            req.send();
        }
    }
	
}

function ahahDoneTXT() {
   // only if req is "loaded"
   if (req.readyState == 4) {
       // only if "OK"
       if (req.status == 200 || req.status == 304) {
           checkTXT = req.responseText;
       } 
   }
}


function ZMGetVal(el){
	var ret;
	field=document.getElementById(el);
	ret=eval('field.value');	
	return ret;
}

function ZMLogin(){
	var usercode=ZMGetVal('usercode');
	var password=ZMGetVal('password');
    var keepLogin = 'false';
    if($('#keepLogin').is(':checked')) {
         keepLogin = 'true';
    }
	if(usercode==''){
		alert('Please fill in your username');
	} else if(password==''){
		alert('Please fill in your password');
	} else{
		ahah(mpUrl, 'usercode=' + usercode + '&password=' + password + '&keepLogin=' + keepLogin, mDiv);
	}
}

function ZMLogoff(){
	ahah(mpUrl, 'action=logoff', mDiv);
}

function ZMSearch(pFunctionNumber, pSearchFor){
   	ahah(mpUrl, 'p=11&functionNumber=' + pFunctionNumber + '&searchFor=' + pSearchFor, mDiv);
}



function ZMshowPage(id){
	ahah(mpUrl, 'p=' + id, mDiv);
}

function ZMPasswort(){
    ahah(mpUrl, 'p=passwort_vergessen', mDiv);           
}

function ZMPasswortSend(){
    if($('#loginemail').val() != ''){
      ahah(mpUrl, 'p=passwort_vergessen&loginemail=' + $("#loginemail").val(), mDiv);                          
    } else {
                     
    }
}

function ZMTogglePartner(id){
    $('#partner' + id).toggle();
    if($('#partnerImg' + id).attr("src") == "images/info.png"){
         $('#partnerImg' + id).attr("src","images/min.png");
    } else {
         $('#partnerImg' + id).attr("src", "images/info.png");   
    }
    
}










