//document.oncontextmenu = function() { return false; }
//document.onselectstart = function() { return false; }

function DoCallback(data) {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open('POST', url, true);
        req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        req.send(data);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject('Microsoft.XMLHTTP')
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open('POST', url, true);
            req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            req.send(data);
        }
    }
}

function processReqChange() {
    // only if req shows 'loaded'
    if (req.readyState == 4) {
        // only if 'OK'
        if (req.status == 200) {
            eval(what);
        } else {
            alert('There was a problem retrieving the XML data: ' + req.responseText);
        }
    }
}

function showBusy(th) {
    document.getElementById(th).innerHTML = "<p align=center><img src='images/busy.gif' height='20px'> <font size=2><b>Please wait ...</b></font></p>";
}

function gotoURL(url) {
    document.location.href = url;
}

function chkFld(fieldName,chkFor,showMessage) {
    if(fieldName.value==chkFor) {
        alert(showMessage);
        fieldName.focus();
        return false;
    } else {
        return true;
    }
}

function hoverMe(th,n) {
    if(n==1) {    
        th.className = "btn_Hover";
    } else {
        th.className = "btn_Nrml";
    }
}

function doCmd(cn,qstr) {
    try {
    showBusy("resultPane");
    } catch(e) {}
    DoCallback("q="+cn+"&"+qstr);
}

function chkEmail(fn,m) {
    var em = fn.value;
    var vch = "abcdefghijklmnopqrstuvwxyz0123456789@_-.";
	
    if(vch.indexOf(em.charAt(0))>25) {
        if(m)
            alert("Invalid Email ID. Please enter valid Email ID!");
        else
	        fn.style.background = "#FFF4E9";    
	        
	    fn.focus();
	    return false;		
    }				
	
    for(i=0;i<em.length;i++) {
	    if(vch.indexOf(em.charAt(i))==-1) {
            if(m)
                alert("Invalid Email ID. Please enter valid Email ID!");
            else
	            fn.style.background = "#FFF4E9";		    
		    
		    fn.focus();
		    return false;		
	    }				
    }		
    if(em=="" || em.indexOf(".")==-1 || em.indexOf("@")==-1 || em.lastIndexOf(".")==em.length-1 || em.lastIndexOf("@")==em.length-1 || em.lastIndexOf(".")-em.indexOf(".")==1 || em.indexOf("@")!=em.lastIndexOf("@") || em.indexOf(".")-em.indexOf("@")==1 || em.indexOf(".")-em.indexOf("@")==-1 ) {
        if(m)
            alert("Invalid Email ID. Please enter valid Email ID!");
        else
	        fn.style.background = "#FFF4E9";
	        	    
	    fn.focus();
	    return false;		
    }		
	
    fn.style.background = "#ffffff";
    return true;
}
