var currentImage = 0;
		function switch_images_order(direction) {
			var newpos = currentImage
				if (direction == 'next') {
					newpos++; 
						if ((!extra_images[newpos]) || (extra_images[newpos] == null)) {
							newpos = 0;
						}
				} else {
					newpos--;
						if ((!extra_images[newpos]) || (extra_images[newpos] == null)) {
							newpos = extra_images.length - 1;
						}
				}
			switch_images(newpos);
		}
		
		function switch_images(position) {
			var previousZoom = zoomStatus;
			stopZoom();
			//var current_full = full_image;
			var full_image = extra_images[position];
			//extra_images[position] = current_full;
			
			set_image(full_image['image'], full_image['alt']);
			//set_image('thumbnail_'+position, extra_images[position]['thumbnail']);
			currentImage = position;
				if (previousZoom) startZoom();
		}
		
		function set_image(image_src, alt) {
				if (alt == null) alt = '';
			document.getElementById('mainImageContent').innerHTML = image_src;
			document.getElementById('mainImageAlt').innerHTML = alt;
		}
		
		function show_overlay(position) {
			var selectedText = '';
			var selectField = document.getElementById(position+'dropdown');
				for (var i=0; i<selectField.length; i++){
						if (selectField[i].value == selectField.value) {
							selectedText = selectField[i].text;
						}
				}
			document.getElementById(position+'dropdown').style.width = 'auto';
			document.getElementById(position+'overlay').innerHTML = selectedText;
			document.getElementById(position+'dropdown').multiple = false;
			document.getElementById(position+'overlay').style.display = 'block';
			document.getElementById(position+'dropdown').style.top = '0px';
			document.getElementById(position+'overlay').style.width = (parseInt(document.getElementById(position+'dropdown').offsetWidth)) + 'px';
			document.getElementById(position+'overlay').style.height = document.getElementById(position+'dropdown').offsetHeight + 'px';
			document.getElementById(position+'overlay').style.lineHeight = (parseInt(document.getElementById(position+'dropdown').offsetHeight)) + 'px';
		}
		
		function hide_overlay(position, direction) {
			var singleHeight = parseInt(document.getElementById(position+'dropdown').offsetHeight);
			document.getElementById(position+'overlay').style.display = 'none';
			document.getElementById(position+'dropdown').multiple = true;
				if (direction == 'up') {
					document.getElementById(position+'dropdown').style.top = singleHeight - parseInt(document.getElementById(position+'dropdown').offsetHeight) + 'px';
				}
			document.getElementById(position+'dropdown').style.width = (parseInt(document.getElementById(position+'dropdown').offsetWidth) + 10) + 'px';
			document.getElementById(position+'dropdown').focus();
		}
		
		function update_stock_dropdowns(product_id) {
				var step = 1;
				var path = '';
				var selected = '';

					while (document.getElementById('step_'+product_id+'_' + step)) {
						var element = document.getElementById('step_' +product_id+'_'+ step);
						
						var name = element.name;
						
						var id = parseInt(name.substr(name.lastIndexOf('[')+1, (name.lastIndexOf(']') - (name.lastIndexOf('[')+1))));
						selected = element.value;
						foundSelected = false;
						element.length = 0;
							if (element.type != 'hidden') {
								//alert(product_id + ' - ' + id + ' - ' + name);
									for (var n = 0; n < optionsArray[product_id][id].length; n++) {
										//alert(selected+optionsArray[id][n]['id']);
										
											if (attributesArray[product_id][path+optionsArray[product_id][id][n]['id']] > 0) {
												if (optionsArray[product_id][id][n]['id'] == selected) {
													foundSelected = true;
												}
												try{
													element.add(new Option(optionsArray[product_id][id][n]['text'], optionsArray[product_id][id][n]['id']), null);
												}
												catch(e){
													//element.options[element.options.length] = new Option(optionsArray[id][n]['text'], optionsArray[id][n]['id'], false, false);
		
													element.add(new Option(optionsArray[product_id][id][n]['text'], optionsArray[product_id][id][n]['id']));
												}
											}
									}
									if (!foundSelected) {
										selected = element.options[0].value;
									}
							}
						element.value = selected;
						
						path += selected+',';
						step++;
					}
				
				var attributeString = path.substr(0, path.length-1);
					
				//Change the qty dropdown
				var element = document.getElementById('products_quantity_' + product_id);
					if (element) {
						var stockSelected = element.value;
						element.options.length = 0;
						
					
							if (attributesArray[product_id][attributeString] != null) {
								var stock = parseInt(attributesArray[product_id][attributeString]);
									if (stockSelected > stock) stockSelected = stock;
									if (stock > 5) stock = 5;
									for (var n = 1; n <= stock; n++) {
										try{
											element.add(new Option(n, n), null);
										}
										catch(e){
											element.add(new Option(n, n));
										}
									}
							} else {
									try{
										 element.add(new Option('Choose you options above first', ''), null);
									}
									catch(e){
										 element.add(new Option('Choose you options above first', ''));
									}
							}
						element.value = stockSelected;
					}
			}

		function get_child_stock(product_id, stock_prefix) {
				for (var attribute_string in attributesArray[product_id]) {
						if (attribute_string.substr(0, stock_prefix.length) == stock_prefix) {
							return attributesArray[product_id][attribute_string];
						}
				}
		}
		
		function update_out_stock_dropdowns(product_id) {
				var step = 1;
				var path = '';
				var selected = '';

					while (document.getElementById('out_step_'+product_id+'_' + step)) {
						var element = document.getElementById('out_step_' +product_id+'_'+ step);
						
						var name = element.name;
						
						var id = parseInt(name.substr(name.lastIndexOf('[')+1, (name.lastIndexOf(']') - (name.lastIndexOf('[')+1))));
						selected = element.value;
						foundSelected = false;
						element.length = 0;
							if (element.type != 'hidden') {
								//alert(product_id + ' - ' + id + ' - ' + name);
									for (var n = 0; n < optionsArray[product_id][id].length; n++) {
										//alert(selected+optionsArray[id][n]['id']);
											if (get_child_stock(product_id, path+optionsArray[product_id][id][n]['id']) < 1) {
												if (optionsArray[product_id][id][n]['id'] == selected) {
													foundSelected = true;
												}
												try{
													element.add(new Option(optionsArray[product_id][id][n]['text'], optionsArray[product_id][id][n]['id']), null);
												}
												catch(e){
													//element.options[element.options.length] = new Option(optionsArray[id][n]['text'], optionsArray[id][n]['id'], false, false);
		
													element.add(new Option(optionsArray[product_id][id][n]['text'], optionsArray[product_id][id][n]['id']));
												}
											}
									}
									if (!foundSelected) {
										selected = element.options[0].value;
									}
							}
						element.value = selected;
						
						path += selected+',';
						step++;
					}
			}

			
			function checkSuggestion(e) {
					if(window.event) {
						keynum = e.keyCode;
					} else if(e.which) {
					 	keynum = e.which;
					}
				keynum = parseInt(keynum);
					switch(keynum) {
						case 13: //Enter
								if (currentSearchPos > -1) {
									selectSuggestion(document.getElementById('searchSuggestRow'+currentSearchPos+'Content').innerHTML);
								} else {
									submitSearch();
								}
							return;
					}
	}
	
var xmlhttpsearch;	
	function runSearch(term) {
			if (runLiveSearch != '1') return;
				if (window.XMLHttpRequest) {
					xmlhttpsearch=new XMLHttpRequest();
				} else if (window.ActiveXObject) {
					
					xmlhttpsearch=new ActiveXObject("Microsoft.XMLHTTP");
				} else {
					return;
				}
			xmlhttpsearch.onreadystatechange=function() {
					if (xmlhttpsearch.readyState==4) {
						document.getElementById('pageContent').className = 'contentWithLeft';
						
						document.getElementById('pageContent').innerHTML = xmlhttpsearch.responseText;
					}
			}
			if (seacrhUrl.indexOf('?') != -1) {
				var url = seacrhUrl + '&';
			} else {
				var url = seacrhUrl + '?';	
			}
		//alert(url + "keywords=" + term);
		xmlhttpsearch.open("GET", url + "keywords=" + term,true);
		xmlhttpsearch.send(null);
	}
	
	function getSuggestions(e, term) {
		
				var xmlhttp;
					if(window.event) {
						keynum = e.keyCode;
					} else if(e.which) {
					 	keynum = e.which;
					}
				keynum = parseInt(keynum);
					switch(keynum) {
						case 13: //Enter
								if (currentSearchPos > -1) {
									selectSuggestion(document.getElementById('searchSuggestRow'+currentSearchPos+'Content').innerHTML);
								} else {
									submitSearch();
								}
							return;
						break;
						case 38: //Keyup
								if (!getSuggestionsStatus) return;
							var newPos = currentSearchPos-1;
								if (!document.getElementById('searchSuggestRow'+newPos)) {
										for (var n = 9; n >= 0; n--) {
												if (document.getElementById('searchSuggestRow'+n)) {
													newPos = n;
													break;
												}
										}
								}
							selectSearchRow(newPos);
							currentSearchPos = newPos;
							return;
						break
						case 40: //Keydown
								if (!getSuggestionsStatus) return;
							var newPos = currentSearchPos+1;
								if (!document.getElementById('searchSuggestRow'+newPos)) newPos = 0;
							selectSearchRow(newPos);
							currentSearchPos = newPos;
							return;
						break;
					}
					
					if (window.XMLHttpRequest) {
						xmlhttp=new XMLHttpRequest();
					} else if (window.ActiveXObject) {
						xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
					} else {
						return;
					}
				
					xmlhttp.onreadystatechange=function() {
							if (xmlhttp.readyState==4) {
									if (xmlhttp.responseText.length < 1) {
										hideSuggestions();
									} else {
										document.getElementById('searchSuggest').style.display = 'block';
										document.getElementById('searchSuggestContent').innerHTML = xmlhttp.responseText;
										currentSearchPos = -1;
									}
							}
					}
				xmlhttp.open("GET","ajax_search_suggest.php?search_term=" + term,true);
				xmlhttp.send(null);
				runSearch(term);
			}
			
			function selectSuggestion(term) {
				document.getElementById('searchInput').value = term;
				hideSuggestions();
				submitSearch();
			}
			
			function hideSuggestions() {
				document.getElementById('searchSuggest').style.display = 'none';
			}
			
			function submitSearch() {
					if (document.getElementById('searchInput').value == 'Enter your search terms...') {
						document.getElementById('searchInput').value = '';
						return false;
					} else if (document.getElementById('searchInput').value == '') {
						document.getElementById('searchInput').value = 'Enter your search terms...';
						return false;
					}
				allowSubmit = true;
				document.forms['quick_find'].submit();	
			}
			
			function getSuggestionsStatus() {
					if (document.getElementById('searchSuggest').style.display == 'block') {
						return true;
					} else {
						return false;
					}
			}
			
			function selectSearchRow(number) {
					for (var n = 0; n < 10; n++) {
							if (!document.getElementById('searchSuggestRow'+n)) return;
							if (n == number) {
								document.getElementById('searchSuggestRow'+n).className = 'listingRowOver';
							} else {
								document.getElementById('searchSuggestRow'+n).className = 'listingRow';
							}
					}
			}


			function checkLine(element, onlyIfUnchecked) {
				//	if (onlyIfUnchecked == null) onlyIfUnchecked = false;
				var checkbox = (((element.childNodes[0].type == 'checkbox') || (element.childNodes[0].type == 'radio')) ? element.childNodes[0] : element.childNodes[1]);
				var type = checkbox.type;
				
					if (onlyIfUnchecked && checkbox.checked) return false;
				checkbox.checked = !checkbox.checked;
				
				element.className = 'checkboxLine'+(checkbox.checked ? ' checked' : '');
					if (type == 'radio') {
						//Loop over the other ones and switch to unchecked.
						var fields = document.getElementsByName(checkbox.name);
							for (var n = 0; n < fields.length; n++) {
									if (fields[n].value != checkbox.value) {
										fields[n].checked = false;
										fields[n].parentNode.className = 'checkboxLine';
									}
							}
					}
				return checkbox.checked;
			}
			
			function open_popup(url, width, height, scrollbars) {
					if (scrollbars == null) scrollbars = false;
				window.open(url, "Window", "status=1, height="+height+", width="+width+", scrollbars="+(scrollbars ? '1' : '0')+"" );
				return false;
			}
			
			
			
			
			
	function explode(seperator, string) {
		
		var return_array = new Array;
			if (!empty(string)) {
				return_array = string.split(seperator);
			}
	
		return return_array;
	}
	
	function strtolower(string) {
			if (empty(string)) {
				return '';
			}
		return string.toLowerCase();
	}
	
	function empty(string) {
			if ((string == null) || (!string) || (string.length < 1)) {
				return true;
			} else {
				return false;	
			}
	}
	
	function strlen(string) {
			if ((string == null) || (!string)) {
				string = '';
			}
		return string.length;
	}
	
	function strpos(string, findString) {
			if ((string == null) || (!string)) {
				string = '';
			}
			if (string.indexOf(findString) != -1) {
				return true;	
			} else {
				return false;	
			}
	}
	
	function count(array) {
		return array.length;
	}



var zoomStatus = false;
				
	function switchZoom() {
			if (!zoomStatus) {
				startZoom();
			} else {
				stopZoom();
			}
	}
											
	function startZoom() {
		
		document.getElementById('mainImage').style.width = document.getElementById('mainImageContent').offsetWidth+'px';
		document.getElementById('mainImage').style.height = document.getElementById('mainImageContent').offsetHeight+'px';
		document.getElementById('mainImage').style.cursor = 'move';
		document.getElementById('zoomTextExtra').style.display = 'block';
		
		set_image(extra_images[currentImage]['zoom']);
		//document.getElementById('mainImageContent').style.top = '0px';
		//document.getElementById('mainImageContent').style.left = '0px';
		//alert(document.getElementById('mainImageContent').firstChild.offsetWidth);
		var halfX = (parseInt(document.getElementById('mainImageContent').firstChild.offsetWidth)/2) - (parseInt(document.getElementById('mainImage').style.width)/2);
		document.getElementById('mainImageContent').style.left = (halfX*-1)+'px';
		
		var halfY = (parseInt(document.getElementById('mainImageContent').firstChild.offsetHeight)/2) - (parseInt(document.getElementById('mainImage').style.height)/2);
		document.getElementById('mainImageContent').style.top = (halfY*-1)+'px';
		
		zoomStatus = true;
		document.getElementById('zoomText').innerHTML = 'ZOOM OUT';
		
		addEvent(document.getElementById('mainImageContent'), 'mousedown', function (evt) {
				if (evt.preventDefault) {
					evt.preventDefault();
				} 
			startDrag();
			return false;
		});
		addEvent(document.getElementById('mainImageContent'), 'dragstart', function (evt) {
				if (evt.preventDefault) {
					evt.preventDefault();
				}
			return false;
		});
		addEvent(document, 'mouseup', function (evt) {
			stopDrag();
		});

	}

	function stopZoom() {
		set_image(extra_images[currentImage]['image']);
		document.getElementById('mainImage').style.width = 'auto';
		document.getElementById('mainImage').style.height = 'auto';
		document.getElementById('mainImage').style.cursor = 'auto';
		document.getElementById('zoomTextExtra').style.display = 'none';
		zoomStatus = false;
		document.getElementById('zoomText').innerHTML = 'ZOOM IN';
		document.getElementById('mainImageContent').style.top = '0px';
		document.getElementById('mainImageContent').style.left = '0px';
	}
	
	function addEvent( obj, type, fn ) {
	  if ( obj.attachEvent ) {
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
		obj.attachEvent( 'on'+type, obj[type+fn] );
	  } else {
		obj.addEventListener( type, fn, false );
	  }
	}
	
	function removeEvent( obj, type, fn ) {
	  if ( obj.detachEvent ) {
		obj.detachEvent( 'on'+type, obj[type+fn] );
		obj[type+fn] = null;
	  } else {
		obj.removeEventListener( type, fn, false );
	  }
	}
	
var startPosX = '';
var startPosY = '';
var bufferX = 0;
var mousePos = false;
var dragStatus = false;
	function startDrag() {
		
			if (!zoomStatus) {
				return;
			}
		
		document.getElementById('mainImageContent').firstChild.ondrag = 'return false';
		
		//Set the left as the offset left in case the image was centered.
		bufferX = parseInt(document.getElementById('mainImageContent').firstChild.offsetLeft);
		
		startPosX = mousePos.x;
		startPosY = mousePos.y;
		
		

		dragStatus = true;
	}
	
	function stopDrag() {
		dragStatus = false;
		document.body.style.cursor = '';
	}

		function updateDrag() {
			if (!dragStatus) {
				return;
			}

		var parentWidth = parseInt(document.getElementById('mainImage').offsetWidth-2);
		var width = parseInt(document.getElementById('mainImageContent').firstChild.offsetWidth);
		var parentHeight = parseInt(document.getElementById('mainImage').offsetHeight-2);
		var height = parseInt(document.getElementById('mainImageContent').firstChild.offsetHeight);
		var top = parseInt(document.getElementById('mainImageContent').style.top);
		var left = parseInt(document.getElementById('mainImageContent').style.left);
			if (isNaN(top)) {
				top = 0;
			}
			if (isNaN(left)) {
				left = 0;
			}
			
		var differenceLeft = mousePos.x-startPosX;
		startPosX = mousePos.x;
		var differenceTop = mousePos.y-startPosY;
		startPosY = mousePos.y;
		
		var ratioX = ((width-parentWidth)/parentWidth);
		
		var ratioY = ((height-parentHeight)/parentHeight);

		top += parseInt(differenceTop*ratioY);
		
		left += parseInt(differenceLeft*ratioX);

			if (top > 0) {
				top = 0;
			}
			if (left > 0) {
				left = 0;
			}
		var minX = 0 - (width-parentWidth);
		var minY = 0 - (height-parentHeight);
			if (left < minX) {
				left = minX;
			}
			if (top < minY) {
				top = minY;
			}
		
			if (ratioY > 0.1) document.getElementById('mainImageContent').style.top = top+'px';
			if (ratioX > 0.1) document.getElementById('mainImageContent').style.left = left+'px';
	}
	
	function trackMouse(ev){ 
		ev = ev || window.event; 
		
		mousePos = getMouseCoords(ev);
			if (dragStatus) {
				updateDrag();
			}
	} 
	
	function getMouseCoords(ev){ 
			if(ev.pageX || ev.pageY){ 
				return {x:ev.pageX, y:ev.pageY}; 
			}
		return { x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, y:ev.clientY + document.body.scrollTop  - document.body.clientTop }; 
	}
	
document.onmousemove = trackMouse;

			
	function update_cart_totals() {
		var total_price = 0;
			for(var products_id in productsArray) {
					if (!document.getElementById('products_quantity_' + products_id)) continue;
				var price = parseFloat(productsArray[products_id]);
				var qty = parseInt(document.getElementById('products_quantity_' + products_id).value);
				var final_price = price * qty;
					if (document.getElementById('products_price_' + products_id)) document.getElementById('products_price_' + products_id).innerHTML = '$' + number_format(final_price, 2);
				total_price += final_price;
			}
		var coupon_amount = ((document.getElementById('coupon_amount')) ? document.getElementById('coupon_amount').value : 0);
		var coupon_value = 0;
			if (coupon_amount != 0) {
					if (coupon_amount.substr(-1) == '%') {
						coupon_amount = parseInt(coupon_amount.substr(0, coupon_amount.length - 1));
						coupon_value = total_price * (coupon_amount/100);
					} else if (coupon_amount.substr(0, 1) == '$') {
						
					}
			}
			if (document.getElementById('subtotal_price')) document.getElementById('subtotal_price').innerHTML = '$' + number_format(total_price, 2);
			if ((coupon_value > 0) && document.getElementById('coupon_value')) {
				total_price -= coupon_value;
				document.getElementById('coupon_value').innerHTML = '$' + number_format(coupon_value, 2);
			}
			if (document.getElementById('total_price')) document.getElementById('total_price').innerHTML = '$' + number_format(total_price, 2);
			if (document.getElementById('total_price_second')) document.getElementById('total_price_second').innerHTML = '$' + number_format(total_price, 2);
	}
	
	function number_format(a, b, c, d) {
			if (c == null) {
				c = '.';
			}
			if (d == null) {
				d = ',';
			}
	 a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
	 e = a + '';
	 f = e.split('.');
	 if (!f[0]) {
	  f[0] = '0';
	 }
	 if (!f[1]) {
	  f[1] = '';
	 }
	 if (f[1].length < b) {
	  g = f[1];
	  for (i=f[1].length + 1; i <= b; i++) {
	   g += '0';
	  }
	  f[1] = g;
	 }
	 if(d != '' && f[0].length > 3) {
	  h = f[0];
	  f[0] = '';
	  for(j = 3; j < h.length; j+=3) {
	   i = h.slice(h.length - j, h.length - j + 3);
	   f[0] = d + i +  f[0] + '';
	  }
	  j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
	  f[0] = j + f[0];
	 }
	 c = (b <= 0) ? '' : c;
	 return f[0] + c + f[1];
	}
	
	function setBackgroundBlurStatus(display) {
			if (display == null) display = false;
		document.getElementById('blurBackground').style.display = (display ? 'block' : 'none');
	}

	function setPopupCartStatus(display, cartInfoString) {
			if (display == null) display = false;
			if (cartInfoString == null) cartInfoString = '';
		var cartInfo = new Array; //Defined here so we can ignore it in the return;
		eval(cartInfoString);
		document.getElementById('popupCart').style.top = (display ? '50%' : '-1000px');
		setBackgroundBlurStatus(display);
		
			if (cartInfoString != '') {
					for(var key in cartInfo) setPopupCartItem(key, cartInfo[key]);
			}
	}
	
	function setPopupReviewStatus(display, infoString) {
		document.getElementById('popupReview').style.top = (display ? '50%' : '-1000px');
		document.getElementById('popupReview').style.display = (display ? 'block' : 'none');
	}
	
	function setPopupCartItem(key, val) {
			if (document.getElementById('popupCartItem_' + key)) document.getElementById('popupCartItem_' + key).innerHTML = val;
	}
	
	function hideAddProduct() {
		setPopupCartStatus(false);
		setPopupReviewStatus(false);
		set_image_src('button_add_to_cart', 'templates/purelypiercings/images/buttons/english/button_add_to_cart.gif');
	}
	
	function set_image_src(id, image_src) {
			if (document.getElementById(id)) document.getElementById(id).src = image_src;
	}
	
	function addProduct(form_name) {
		var httpRequest;
		var formData = tep_get_form_data(form_name);
			if (formData == null) return true;
		set_image_src('button_add_to_cart', 'templates/purelypiercings/images/buttons/english/button_added_to_cart.gif');
		//var arrayString = 'var cartInfo = new Array;cartInfo["name"] = "test Product";';
		//setPopupCartStatus(true, arrayString);
		
			if (window.XMLHttpRequest) {
				httpRequest=new XMLHttpRequest();
			} else if (window.ActiveXObject) {
				httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
			} else {
				return;
			}
			httpRequest.onreadystatechange=function() {
					if (httpRequest.readyState==4) {
							if (httpRequest.responseText.length > 0) setPopupCartStatus(true, httpRequest.responseText);
					}
			}
		var url = ajaxCartUrl;
		var getString = compile_array_string(formData['GET']);
			if (getString != '') {
					if (url.indexOf('?') == -1) {
						url += '?';
					} else {
						url += '&';
					}
				url += getString;
			}

		httpRequest.open(formData['method'],url,true);
			if (formData['method'] == 'POST') {
				httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				httpRequest.send(compile_array_string(formData['POST']));
			} else {
				httpRequest.send(null);
			}
		//
				
		return false; //Click the click.
	}
	
	function compile_array_string(array) {
			if (array == null) array = new Array;
		var return_string = '';
			for (key in array) {
					if (return_string != '') return_string += '&';
				return_string += key + '=' + array[key];
			}
		return return_string;
	}
/*
	Gets the form data incl, action, get method and post'
*/
	function tep_get_form_data(form_name) {
		
		var form = document.forms[form_name];
			if (!form) return null;
		
		var formData = new Array;
		
		formData['action'] = form['action'];
		formData['method'] = form['method'].toUpperCase();

		formData['POST'] = new Array;
		formData['GET'] = new Array;

			if (formData['action'].indexOf('?') != -1) {
				var explode = formData['action'].split('?');
				formData['action'] = explode[0];
				var vars = explode[1].split('&');
					for (var n = 0; n < vars.length; n++) {
						var current_var = vars[n].split('=');
						formData['GET'][current_var[0]] = current_var[1];
					}
			}

		//Now lets loop the contents;
			for (var n = 0; n < form.elements.length; n++) {
				formData[formData['method']][form.elements[n].name] = form.elements[n].value;
			}

		return formData;
	}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=600,height=900,screenX=150,screenY=150,top=150,left=150')
}

		function hover_tab(tab, status) {
				if (tab == tab_selected) return;
				if (status) {
						if (document.getElementById(tab).className.substr(-5) != 'Hover') {
							document.getElementById(tab).className += 'Hover';
						}
				} else {
					document.getElementById(tab).className = document.getElementById(tab).className.replace('Hover', '');
				}
		}
	
	
		function select_tab(tab) {
				if (tab == tab_selected) return;
			hover_tab(tab, false);
			document.getElementById(tab_selected).className = document.getElementById(tab_selected).className.replace('Selected', '');
			document.getElementById(tab_selected+'Content').style.display = 'none';
			document.getElementById(tab).className += 'Selected';
			document.getElementById(tab+'Content').style.display = 'block';
			
			tab_selected = tab;
		}
		
		function update_rating(rating) {
			rating = parseInt(rating.substr(-1));
				for (var n = 1; n <= 5; n++) {
					var coreClassName = document.getElementById('review_rating_' + n).className.replace('Selected', '').replace('Unselected', '');
					//alert(coreClassName);
					document.getElementById('review_rating_' + n).className = coreClassName + ((n <= rating) ? 'Selected' : 'Unselected');
				}
			
			document.getElementById('review_rating').value = rating;
		}

		function switch_display_status(id) {
				if (!document.getElementById(id)) return;
			document.getElementById(id).style.display = ((document.getElementById(id).style.display == 'none') ? 'block' : 'none');	
		}
		
		function set_shop_now_window() {
				var winW = 630;
					if (document.body && document.body.offsetWidth) {
						winW = document.body.offsetWidth;
					}
					if (document.compatMode=='CSS1Compat' && document.documentElement && document.documentElement.offsetWidth ) {
						winW = document.documentElement.offsetWidth;
					}
					if (window.innerWidth && window.innerHeight) {
						winW = window.innerWidth;
					}
					if (winW >= 1100) document.getElementById('whyShop').style.right = '0px';
			}
			
		function extraImagesScroll() {
			var id = extraImagesScrollId;
			var direction = extraImagesScrollDirection;
			var holder = document.getElementById(id);
			var wrapper = document.getElementById(id+'Wrapper');
			
				if (!holder || !wrapper) extraImagesScrollKill();
			var wrapperWidth = (wrapper.style.width ? parseInt(wrapper.style.width) : parseInt(wrapper.offsetWidth));
			var holderWidth = parseInt(holder.offsetWidth);
			var holderLeft = (holder.style.left ? parseInt(holder.style.left) : 0);
				
				switch(direction) {
					case 'right':
						holderLeft -= extraImagesScrollSpeed;
					break;
					case 'left':
						holderLeft += extraImagesScrollSpeed;
					break;	
				}
			//alert(holderLeft);
				if (holderLeft > 0) holderLeft = 0;
				if (holderLeft < (wrapperWidth-holderWidth)) holderLeft = (wrapperWidth-holderWidth);
			//alert(holderLeft);
			holder.style.left = holderLeft+'px';
				if ((holderLeft == 0) || (holderLeft == (wrapperWidth-holderWidth))) {
						if (holderLeft == 0) {
							document.getElementById(id+'Right').style.display = 'block';
							document.getElementById(id+'Left').style.display = 'none';
						} else {
							document.getElementById(id+'Right').style.display = 'none';
							document.getElementById(id+'Left').style.display = 'block';	
						}
					extraImagesScrollKill();
				} else {
					document.getElementById(id+'Left').style.display = 'block';
					document.getElementById(id+'Right').style.display = 'block';
				}
					
		}
		
		function extraImagesScrollKill() {
				if (!extraImagesScrollObject) return;
			clearInterval(extraImagesScrollObject);
			extraImagesScrollObject = false;
		}
		
		function extraImagesScrollStart(id, direction) {
				if (extraImagesScrollObject) return;
			extraImagesScrollId = id;
			extraImagesScrollDirection = direction;
			extraImagesScrollObject = setInterval('extraImagesScroll();', 25);
		}

