//CNC Masters Quotation Class

//Description : receives requests for the site's quotation system

//-----------------------------------------------------------------------------------------------------------------------------------------------

function createRequestObject(){

     var ro;

     ro = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();

     return ro;

}

var http = createRequestObject();

var http2 = createRequestObject();

//-----------------------------------------------------------------------------------------------------------------------------------------------

function sndReq(item_name,item,action)

{

	if(action=='add')

	{

     	if(confirm('Add '+item_name+' to your quotation cart?', 'Message From CNC Masters'))

     		{
					//should always be absolute otherwise the session variables will be messed up
					
				
     				http.open('get', 'http://www.cncmasters.com/quotation/qoutation.class.php?item_name='+item_name+'&item='+item+'&action='+action);

     				http.onreadystatechange = handleResponse;

     				http.send(null);

			}

 	}
 	
 	if(action=='addmulti')

	{

     	if(confirm('Add '+item_name+' to your quotation cart?', 'Message From CNC Masters'))

     		{
					//should always be absolute otherwise the session variables will be messed up
					
				
     				http.open('get', 'http://www.cncmasters.com/quotation/qoutation.class.php?item_name='+item_name+'&item='+item+'&action='+action);

     				http.onreadystatechange = function() { self.close(); }

     				http.send(null);
     				
     				
     				

			}

 	}
 	
 	

	 //-----------------------------------------------------------------------------------------------------------------------------------------------

	if(action=='delete')

	{

	 	if(confirm('Delete '+item_name+' from your quotation list?'))

	 		{
				

	     		http.open('get', 'http://www.cncmasters.com/quotation/qoutation.class.php?item_name='+item_name+'&item='+item+'&action='+action);

	     		http.onreadystatechange = function()
				{
					if(http.readyState == 4)
					{
						//alert(http.responseText);
						location.reload(true);
					}
				}

	     		http.send(null);
	     		
 		        
				
				
 			}

	}

 	//-----------------------------------------------------------------------------------------------------------------------------------------------

 	//send quotation to email event

 	 if(action=='send')

 	 	{

	 	if(confirm('Send your quotation?'))

	 		{
				//should always be absolute otherwise the session variables will be messed up
	     		http.open('get', 'http://www.cncmasters.com/quotation/qoutation.class.php?action='+action);

	     		http.onreadystatechange = handleResponse;

	     		http.send(null);

	     		//show alert of confirmation

	     		alert('Quotation Sent!');

	     		window.location = "http://www.cncmasters.com/"

 			}

 		}

 }

//-----------------------------------------------------------------------------------------------------------------------------------------------

function handleResponse() {

	//if there is response

     if(http.readyState == 4)

     {

          var response = http.responseText;

          var update = new Array();

          if(response.indexOf('|') != -1) 

          {

               update = response.split('|');

               document.getElementById(update[0]).innerHTML = update[1];

          }

     }

}



function ChooseHolderPopup()

{

var w = window.open('http://www.cncmasters.com/chooseholders.php', '_blank' );	

//, 'height=400,width=350,resizable=0'

}
