var xhr=null;
function httpReq() {
	if (window.XMLHttpRequest)
	  {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xhr=new XMLHttpRequest();
	  }
	else
	  {
		// code for IE6, IE5
		xhr=new ActiveXObject("Microsoft.XMLHTTP");
	  }
}

function criticalMessage()
{
	httpReq();
	// set the protocol type to create full site path
    var siteURL="http://";
    siteURL+=location.host;    
    if (!xhr) 
    {
        alert ("XMLHttp failed to instantiate");
        return false;
    }                                       
    xhr.onreadystatechange = function() {                    
        if ((xhr.readyState==4) && (xhr.status==200))
        {    	        	
        	// JSON object of CRX values
            var str=xhr.responseText;                        
            var i;
            var msg="";
            // check for defined alert messages 
            if(str!='{"success":false}'){            	
                var json=JSON.parse(str);
	            for (i=0;i<json.hits.length;i++)
	            {      
	            	// check this condition
	            	var ser=json.hits[i].detMsgURL;    
	            	// check the URL whether its a day based application or non-day based application     	
	            	var alertImgURL=json.hits[i].alertImgURL;            	          	
	            	var destURL=json.hits[i].detMsgURL;
	            	var shortMsg=json.hits[i].shortMsg;            		            		            	               		
	            	msg+='<div class="errorwrap"><p><img style="vertical-align:middle;margin-top:0px" src="'+alertImgURL+'" height="20" width="20" alt="Alert Image" />&nbsp;<a class="error_msg" href=\''+destURL+'\' target=\'_blank\'> '+shortMsg+'</a></div>';            	
					document.getElementById('error_wp').style.display = "block";
	            }            
	            if(document.getElementById('error_wp')!=null && document.getElementById('error_wp')!=undefined && document.getElementById('error_wp').innerHTML!=null) {
					document.getElementById('error_wp').innerHTML=msg; 
				}
            }
	        return 1;
        }      
    };   
    var URL="/bin/ccquerybuilder.json";
    var params="propertyName=sitepath&propertyValue=" + siteURL;    
    xhr.open('POST',URL, true);     
    xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xhr.send(params);                                  
}

