
function sendMsg(id,suppName){



					
                                var crt = document.getElementById("cart");
																
																crt.innerHTML = "<form  method='post' name='msgform' >" + 
																
																                " <table cellpadding='3' width='100%' > " +
																								 
																								 "<tr><td height='5' colspan='2' bgcolor='#cccccc'> </tr> " +
																								
																								" <tr><td  colspan='2' align='right'><center> <b> Send Message to "+suppName+"</center> </tr>" +
																 																								
																								"<tr><td  height='5' colspan='2' bgcolor='#cccccc'>  </tr>" +
																								 																								 
																								"<tr><td width='149'  align='right'><b>Name: </td>" +
																								
																								"<td width='300'> <input type='text' style='height:17px;border:1px solid black' name='name' size='30' /> </tr>" +
																								 
																								"<tr><td width='149'  align='right'><b>Phone: </td>" +
																								
																								"<td > <input type='text' style='height:17px;border:1px solid black' name='phone' size='30' /> </tr>" +
																								 
	
																								"<tr><td  align='right'><b>Email: </td>" +
																								
																								"<td > <input type='text' style='height:17px;border:1px solid black' name='email' size='30' /> </tr>" +
																								
																								"<tr><td align='right'><b>Comments: </td>" +
																								
																								"<td > <textarea style='border:1px solid black' name='comments' rows='6' cols='40' ></textarea></tr>" +
																																																
																								"<tr><td > &nbsp; </td>" +
																								
																								"<td > <input type='button' onclick='validate(\""+id+"\")'  value='Send'  /> </tr>" +	
					
																							   "</table> </form>";
																								
																								 
																crt.style.visibility = "visible";
															//	crt.style.position   = "absolute";
														//		crt.style.right      = "95px";
													//			crt.style.top        = "175px";
																


}



function reqObject () {
  var req = false;



 if (window.XMLHttpRequest)
 {

    try {
        req = new XMLHttpRequest();
        
    }catch (e) {

        req = false;

    }



 } else if(window.ActiveXObject){

   try {
        req = new ActiveXObject("Msxml2.XMLHTTP");

   }catch(e) {
 
           try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
           catch(e) { req = false; }

   }



}
else  alert ("Your browser does not support AJAX");



 return req;


}

reqObj   = new reqObject();


function validate(id){

  var doc = document.msgform;

  fname  = doc.name.value;
  phone  = doc.phone.value;
  email  = doc.email.value;
	comments = doc.comments.value;
	
	
  if(fname && phone && /^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})$/.exec(email) && comments )
    { 
		

		    sendMsgO(id,fname,phone,email,comments); 
				

				
	  }
  else
    alert("Please fill fields\nwith proper data");




}


function sendMsgO(arg1,arg2,arg3,arg4,arg5){
var query = "msg.php?id=" + arg1 + "&name=" + arg2 + "&phone=" + arg3 + "&email=" + arg4 + "&comments=" + arg5; 

if (reqObj) {
         
				 try {
         reqObj.open("GET",query,true);
         reqObj.onreadystatechange = process_;
         reqObj.send("");
         
          }
					
					catch(e) { alert(e); return; }


  } else return alert("AJAX Error");



}


 function process_(){

  
	    
    // only if req shows "loaded"
    if (reqObj.readyState == 4) {
        // only if "OK"
     
        if (reqObj.status == 200) {
             results = reqObj.responseText;
            
             if(results == "OK"){
             
             document.msgform.name.disabled = true;
             document.msgform.phone.disabled = true;
						 document.msgform.email.disabled = true;
						 document.msgform.comments.disabled = true;
						 
             alert("Thank You\n\nYour message has been sent\n\nIt will be processed shortly");
						 
						 document.getElementById('cart').innerHTML = "";

						 return;
             }
            
          
        } else {
            alert("There was a problem sending order\nPlease try again");
               return;
        }
    }
}






