
	function getXmlHttp()
	{
		var xmlHttp = null;
	
		try {
	
			xmlHttp = new XMLHttpRequest();
	
		} catch (e) {
	
			var progIds = ['MSXML2.XMLHTTP', 'Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0'];
	
			var success = false;
	
			for (var iterator = 0; (iterator < progIds.length) && ( ! success); iterator ++) {
	
				try {
	
					xmlHttp = new ActiveXObject(progIds[iterator]);
	
					success = true;
	
				} catch (e) {}
			}
	
			if ( ! success ) {
	
				return null;
			}
		}
	
		return xmlHttp;
	}
	
	
	
	
	function elem( elem_id )
	{
		return document.getElementById( elem_id );
	}
	
	
	function Show_Back()
	{
		var mainImage = elem( 'mainImage' );
		mainImage.src = mainImage_back;
	}
	
	
	function Show_Extra1()
	{
		var mainImage = elem( 'mainImage' );
		mainImage.src = mainImage_extra1;
	}
	
	
	function Show_Extra2()
	{
		var mainImage = elem( 'mainImage' );
		mainImage.src = mainImage_extra2;
	}
	
	
	function Show_Regular()
	{
		var mainImage = elem( 'mainImage' );
		mainImage.src = mainImage_front;
	}
	
	function setProgramLinks(stylenum,colorcode) {
		document.getElementById( 'domesticquote1' ).href='instantprogram.php?programtype=order&type=Domestic&style='+stylenum+'&color='+colorcode;
		document.getElementById( 'domesticquote2' ).href='instantprogram.php?programtype=quote&type=Domestic&style='+stylenum+'&color='+colorcode;
		document.getElementById( 'domesticquote3' ).href='instantprogram.php?programtype=virtualsample&type=Domestic&style='+stylenum+'&color='+colorcode;
		document.getElementById( 'overseasquote1' ).href='instantprogram.php?programtype=order&type=Overseas&style='+stylenum+'&color='+colorcode;
		document.getElementById( 'overseasquote2' ).href='instantprogram.php?programtype=quote&type=Overseas&style='+stylenum+'&color='+colorcode;
		document.getElementById( 'overseasquote3' ).href='instantprogram.php?programtype=virtualsample&type=Overseas&style='+stylenum+'&color='+colorcode;
	}

	function setNormalImageViews(largeimage,backthumb,backlargeimage,extra1thumb,extra1largeimage,extra2thumb,extra2largeimage) {
		elem('mainImage').src=largeimage;
		if (elem('backthumb') != null) {
			elem('backthumb').src=backthumb;
			if (elem('backdiv') != null) {
				elem('backdiv').onmouseover = function() {elem('mainImage').src=backlargeimage;elem('backdiv').onclick = function(){showNormalWindow(backlargeimage)};elem('mainImage').onclick = function(){showNormalWindow(backlargeimage)};if (elem('zoomdiv') != null) {elem('zoomdiv').onclick = function(){showNormalWindow(backlargeimage)};};};
			}


		}
		if (elem('extra1thumb') != null) {
			elem('extra1thumb').src=extra1thumb;
			if (elem('extra1div') != null) {
				elem('extra1div').onmouseover = function() {elem('mainImage').src=extra1largeimage;elem('extra1div').onclick = function(){showNormalWindow(extra1largeimage)};elem('mainImage').onclick = function(){showNormalWindow(extra1largeimage)};if (elem('zoomdiv') != null) {elem('zoomdiv').onclick = function(){showNormalWindow(extra1largeimage)};};};
			}
		}
		if (elem('extra2thumb') != null) {
			elem('extra2thumb').src=extra2thumb;
			if (elem('extra2div') != null) {
				elem('extra2div').onmouseover = function() {elem('mainImage').src=extra2largeimage;elem('extra2div').onclick = function(){showNormalWindow(extra2largeimage)};elem('mainImage').onclick = function(){showNormalWindow(extra2largeimage)};if (elem('zoomdiv') != null) {elem('zoomdiv').onclick = function(){showNormalWindow(extra2largeimage)};};};
			}
		}
	}
	
	
	function setCurrentZoomImage(theimage) {
		elem('mainImage').src=theimage;
	}
	
	function setZoomViews(largeimage,backthumb,backlargeimage,extra1thumb,extra1largeimage,extra2thumb,extra2largeimage) {
		setCurrentZoomImage(largeimage);
		if (elem('backthumb') != null) {
			elem('backthumb').src=backthumb;
			elem('backdiv').onmouseover = function() {setCurrentZoomImage(backlargeimage)};
		}
		if (elem('extra1thumb') != null) {
			elem('extra1thumb').src=extra1thumb;
			elem('extra1div').onmouseover = function() {setCurrentZoomImage(extra1largeimage)};
		}
		if (elem('extra2thumb') != null) {
			elem('extra2thumb').src=extra2thumb;
			elem('extra2div').onmouseover = function() {setCurrentZoomImage(extra2largeimage)};
		}
	}




	
	function Update_Stock( id )
	{
		
		obj = elem( 'product_id[' + id + ']' );
		product_id = obj.options[obj.selectedIndex].value;
		
		obj = elem( "stock_" + id );
		obj.innerHTML = '...';
		
		xmlObj = getXmlHttp();
		xmlObj.onreadystatechange = Update_Stock_Receive;
		
		url = 'style_ajax.php?action=getstock&id=' + id + '&product_id=' + product_id;
		
		xmlObj.open('POST', url, true);
		xmlObj.send("");
		
	}
	
	
	function Update_Stock_Receive()
	{
		
		if ( xmlObj.readyState == 4 ) {
			
			resp = xmlObj.responseText;
			
			var resp_array = resp.split( ',' );
			
			elem( 'stock_' + resp_array[0] ).innerHTML = resp_array[1];
			
		}
		
	}

	function Select_Color( style_id, color_scheme_id ) {
		
		if ( document.getElementById("color_scheme_id") != null) {
			for (i = 0; i < document.getElementById("color_scheme_id").length; i++) {
				if (document.getElementById("color_scheme_id").options[i].value == color_scheme_id) {
					document.getElementById("color_scheme_id").options[i].selected = true;
					Update_ProductInfo(style_id);
				}
			}
		}
	
		
	}

		function Update_ProductInfo( style_id ) {
		obj = elem( 'color_scheme_id' );
		color_scheme_id = obj.options[obj.selectedIndex].value;
		
		if (color_scheme_id) {
		
			obj = elem( "product_info" );
			obj.innerHTML = '<p>Loading Product Information...</p>';
		
			xmlObj = getXmlHttp();
			xmlObj.onreadystatechange = Update_ProductInfo_Receive;
		
			url = 'style_ajax.php?action=getproductinfo&style_id=' + style_id + '&color_scheme_id=' + color_scheme_id;
		
			xmlObj.open('POST', url, true);
			xmlObj.send("");

		} else {
			elem( 'product_info' ).innerHTML = '';
		}
		
	}
	
	
	function Update_ProductInfo_Receive()
	{
		
		if ( xmlObj.readyState == 4 ) {
			
			resp = xmlObj.responseText;
			
			elem( 'product_info' ).innerHTML = resp;
			
		}
		
	}
	
	
	function showZoomWindow(style_id, color_scheme_id) 
	{
		window.open('style_view_popup.php?style_id=' + style_id + '&color_scheme_id=' + color_scheme_id,'popup','menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=790,height=580');
	}
	
	function showNormalWindow(large_image) {
		window.open(large_image,'popup','menubar=no,location=no,resizable=yes,scrollbars=yes,status=yes,width=400,height=400');
	}
	
	function setLargeZoomClick(style_id, color_scheme_id)
	{
		elem('mainImage').onclick = function(){showZoomWindow(style_id,color_scheme_id)};
		if (elem('backdiv') != null) {
			elem('backdiv').onclick = function(){showZoomWindow(style_id,color_scheme_id)};
		}
		if (elem('extra1div') != null) {
			elem('extra1div').onclick = function(){showZoomWindow(style_id,color_scheme_id)};
		}
		if (elem('extra2div') != null) {
			elem('extra2div').onclick = function(){showZoomWindow(style_id,color_scheme_id)};
		}
		if (elem('zoomdiv') != null) {
			elem('zoomdiv').onclick = function(){showZoomWindow(style_id,color_scheme_id)};
		}
	}
	
	function setLargeNormalClick(large_image, backlarge_image, extra1large_image, extra2large_image)
	{
		elem('mainImage').onclick = function(){showNormalWindow(large_image)};
		if (elem('backdiv') != null) {
			elem('backdiv').onclick = function(){showNormalWindow(backlarge_image)};
		}
		if (elem('extra1div') != null) {
			elem('extra1div').onclick = function(){showNormalWindow(extra1large_image)};
		}
		if (elem('extra2div') != null) {
			elem('extra2div').onclick = function(){showNormalWindow(extra2large_image)};
		}		
		if (elem('zoomdiv') != null) {
			elem('zoomdiv').onclick = function(){showNormalWindow(large_image)};
		}		
		
	}
