var xmlhttp=GetXmlHttpObject();
function newsletter1() {

var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.getElementById('subscribe_email').value;
   if(reg.test(address) == false) {
      document.getElementById('subscribe_msg').style.color="red";
      document.getElementById('subscribe_msg').innerHTML="Please enter valid Email address";
      return false;
   }

newsletter();
return false;
}

function newsletter()
{
//alert(document.getElementById('subscribe_email').value);
//return false;
var sid=document.getElementById('subscribe_email').value;
//alert(sid);
   if(xmlhttp==null)
    {
        alert("Your browser does not support XMLHTTP!");
    }

    var url="Newsleter.php";
    url=url+"?sid="+sid +"&rand="+ Math.random();
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
                //alert('hi')
                    document.getElementById('subscribe_msg').innerHTML='Your email address has been added!';
			document.getElementById('subscribe_email').value='Email';
                    //return false;
                }
	}
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}
function getSales(sid)
{
   if(xmlhttp==null)
    {
        alert("Your browser does not support XMLHTTP!");
    }

    var url="getSales.php";
    url=url+"?sid="+sid +"&rand="+ Math.random();
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
                    document.getElementById('service').innerHTML=xmlhttp.responseText;
                }
	}
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

function getContractor(cname)
{
 if(cname=='Cork'){
     document.getElementById('mainimg').src="/cpi/images/contractor_map_munster_co_cork.png";
     document.getElementById('maindiv').style.display='none';
     document.getElementById('corkdiv').style.display='block';
 }

   if(xmlhttp==null)
    {
        alert("Your browser does not support XMLHTTP!");
    }

    var url="getContractor.php";
    url=url+"?cname="+cname +"&rand="+ Math.random();
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
                    document.getElementById('inner_right').innerHTML=xmlhttp.responseText;
                }
	}
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

function getServicedata(catid,sid,cid){
    //alert(catid+".."+sid+'..'+cid);
    if(xmlhttp==null)
    {
        alert("Your browser does not support XMLHTTP!");
    }

    var url="getServicedata.php";
    url=url+"?sid="+sid +"&cid="+cid+"&catid="+catid+"&rand="+ Math.random();
	xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState==4 && xmlhttp.status==200){
                 document.getElementById('serviceData').innerHTML=xmlhttp.responseText;
               }
	}
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

function getSalesdata(catid,sid,cid){
    if(xmlhttp==null)
    {
        alert("Your browser does not support XMLHTTP!");
    }

    var url="getSalesdata.php";
    url=url+"?sid="+sid +"&cid="+cid+"&catid="+catid+"&rand="+ Math.random();
	xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState==4 && xmlhttp.status==200){
                 document.getElementById('serviceData').innerHTML=xmlhttp.responseText;
               }
	}
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

function GetXmlHttpObject()
{
    if (window.XMLHttpRequest)
    {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject)
    {
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
}

