function img2txt(img) {
  txt = img.alt;
document.getElementById("largeimage").innerHTML=txt;
  }
  
function imgParse_to_Generic_Large(img)	
	{
	name = img.alt;

document.getElementById('LargeImage').innerHTML="<img border='0'   src='image/"+ name  +".jpg' />";
	}

function imgParse_to_Generic_Large_Quilt(img)	
	{
	name = img.alt;

document.getElementById('LargeImage').innerHTML="<img border='0'   src='http://www.bymolly.com/image/"+ name  +".jpg' />";
	}



function imgParse_to_Generic(img)	
	{
	name = img.alt;

document.getElementById(name).innerHTML="<img border='0'  width='110' height='110'     src='image/s"+ name  +".jpg' />";
	}



function imgParse_to_Generic_an_qu(img)	
	{
	name = img.alt;

document.getElementById(name).innerHTML="<img border='0'  width='110' height='110'     src='image/_t"+ name  +".jpg' />";
	}


function imgParse_to_Generic(img)	
	{
	name = img.alt;

document.getElementById(name).innerHTML="<img border='0'  width='110' height='110'     src='image/s"+ name  +".jpg' />";
	}


  
// content function
function handleHttpResponse() {
//failsafeImg();
if (http.readyState!= 4) 
 	{
	 document.getElementById("products").innerHTML = "<img src='/revised/ajax-loader.gif' />";
	}
	  if (http.readyState == 4) 
		 {
		 results = http.responseText;
		document.getElementById("cart").style.visibility="hidden";
		 document.getElementById("item").innerHTML = '<img src="http://www.bymolly.com/revised/l/i/image/Lix.jpg" />'; 
		 document.getElementById("products").innerHTML = results;	 
		 }
// end function
}


// content function
function handleHttpResponseItem() {
if (http.readyState!= 4) 
 	{
	
	 document.getElementById("cart").style.visibility="visible";
	 document.getElementById("item").innerHTML = "<img src='/revised/ajax-loader.gif' />";
	}
	  if (http.readyState == 4) 
		{
		get_the_cart();
		results = http.responseText; 
		document.getElementById("item").innerHTML = results;	 
		//changeLg();
		}
// end function
}






function getInfo(url) 
{
http = getHTTPObject()
http.open("GET", url, true); 
http.onreadystatechange = handleHttpResponse; 


http.send(null);
}

function getItem(url) 
{
http = getHTTPObject()
http.open("GET", url, true); 
http.onreadystatechange = handleHttpResponseItem; 
http.send(null);
}






function addInfo(url) { 
var http = false;
http = getHTTPObject()
strsubmit = formData2QueryString();

http.open("POST", url, true);

http.onreadystatechange = handleHttpResponseCart; 

http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

http.send(strsubmit);
}


//  add cart function
function handleHttpResponseCart() 
	{

	
if ((http.readyState == 4) && (http.status == 200)) 
 	{
	get_the_cart_added();}
	// end function
	}


function getHTTPObject() { var xmlhttp; 
/*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } 
catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } 
@else xmlhttp = false; @end @*/  
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
{ 
	try { xmlhttp = new XMLHttpRequest(); 
	xmlhttp.overrideMimeType('text/xml');
	} catch (e) 
		{ xmlhttp = false; } 
} 
return xmlhttp; 
} 


function get_the_cart()
	{
	str = "<input style='width:auto;height:auto;  border:none;' type=\"image\" border='0' src=\"/revised/addtobasket2.jpg\" value=\"Add to cart\" id=\"switcher\"  name=\"add_to_cart\" onclick=\"addInfo('http://www.bymolly.com/revised/cart/cart.php')\" /><br/><br/><div id='notecart' style='display: none'>Your items have bee added<a href='/revised/cart/cart.php' target='_parent'>View cart</a></div>";
	document.getElementById("cart").innerHTML = str;

	}

function get_the_cart_added()
	{
	str = "<input style='width:auto;height:auto; border:none;'  type=\"image\"  border='0'  src=\"/revised/addtobasket2.jpg\" value=\"Add more to cart\" id=\"switcher\"  name=\"add_to_cart\" onclick=\"addInfo('http://www.bymolly.com/revised/cart/cart.php')\" /><br/><br/><div id='notecart'>Item added! <a href='/revised/cart/cart.php' target='_parent'>View cart</a></div>";
	document.getElementById("cart").innerHTML = str;

	}

function clear_notification()
	{
	document.getElementById("notecart").style.display="none";
	}	

function adding_the_cart()
	{
	document.getElementById("cart").innerHTML = "Adding to cart....";
	}

function changeLg()
	{
	document.Lgimage.src = '/image/asdfasf.jpg';	
	}
function defaultImg()
	{
	alert('error');
	document.Lgimage.src = "/image/Lgdefault.jpg";
	}

function formData2QueryString() {
	docForm = window.document.form;

	var strSubmitContent = '';
	var formElem;
	var strLastElemName = '';
	
	for (i = 0; i < docForm.elements.length; i++) {
		
		formElem = docForm.elements[i];
		switch (formElem.type) {
			// Text fields, hidden form elements
			case 'text':
			case 'hidden':
			case 'password':
			case 'textarea':
			case 'select-one':
				strSubmitContent += formElem.name + '=' + escape(formElem.value) + '&'
				break;
				
			// Radio buttons
			case 'radio':
				if (formElem.checked) {
					strSubmitContent += formElem.name + '=' + escape(formElem.value) + '&'
				}
				break;
				
			// Checkboxes
			case 'checkbox':
				if (formElem.checked) {
					// Continuing multiple, same-name checkboxes
					if (formElem.name == strLastElemName) {
						// Strip of end ampersand if there is one
						if (strSubmitContent.lastIndexOf('&') == strSubmitContent.length-1) {
							strSubmitContent = strSubmitContent.substr(0, strSubmitContent.length - 1);
						}
						// Append value as comma-delimited string
						strSubmitContent += ',' + escape(formElem.value);
					}
					else {
						strSubmitContent += formElem.name + '=' + escape(formElem.value);
					}
					strSubmitContent += '&';
					strLastElemName = formElem.name;
				}
				break;
				
		}
	}
	
	// Remove trailing separator
	strSubmitContent = strSubmitContent.substr(0, strSubmitContent.length - 1);

	return strSubmitContent;
}
