<!--
	function copyUrl() {
		return url;
	}
	
	function addToCartSubmit(group) {
		var group = urlGroup(group);
//		alert(Base64.decode(group["bikeparam"]));
		var html = '<form name="tempform" id="tempform" action="' + unescape(group["checkout"]) + '" method="post">';
		
		var order = ["bikeparam", "product", "qty", "txt_size", "stickername", "stickercolour", "txt_cassettebody", "rawImageString", "bikeName"];
		for (var j=0; j<order.length; j++) {
			for (var i in group) {
				if (order[j] == i) {
					html += '<input name="' + i + '" id="' + i + '" value="' + group[i] + '" type="hidden" />';
				}
			}
		}
		html += '</form>';
		jQuery('div#fakeForm').html(html);
		jQuery('form#tempform').submit();
	}
	
	function urlGroup(url) {
		var group = {};
		var ary = url.split("&");
		for (var i=0; i<ary.length; i++) {
			var temp = ary[i].split("=");
			group[temp[0]] = temp[1];
		}
		return group;
	}
	
	function popupColourChart() {
		alert("helo");
		//var popWin = window.open('../../components/com_npbikes/html/colour_chart.html','popWin','scrollbars=yes,width=890,height=500');
		//if(popWin) {
		//	popWin.focus();
		//}
		return false;
	}
	
	function shareByEmail(group) {
		var group = urlGroup(group);
//		alert(Base64.decode(group["bikeparam"]));
		var html = '<form name="tempform" id="tempform" action="' + unescape(group["toUrl"]) + '" method="post" target="_blank">';
		for (var i in group) {
			if (i != "imageParams") {
				html += '<input name="' + i + '" id="' + i + '" value="' + group[i] + '" type="hidden" />';
			}
		}
		html += '</form>';
		jQuery('div#fakeForm').html(html);
		jQuery('form#tempform').submit();
	}
	
	function saveForLater(group) {
		var group = urlGroup(group);
//		alert(Base64.decode(group["bikeparam"]));
		var html = '<form name="tempform" id="tempform" action="' + unescape(group["toUrl"]) + '" method="post" target="_blank">';
		for (var i in group) {
			if (i != "imageParams") {
				html += '<input name="' + i + '" id="' + i + '" value="' + group[i] + '" type="hidden" />';
			}
		}
		html += '</form>';
		jQuery('div#fakeForm').html(html);
		jQuery('form#tempform').submit();
	}
	
	function downloadImage(group) {
		var group = urlGroup(group);
		var html = '<form name="tempform" id="tempform" action="' + unescape(group["toUrl"]) + '" method="post">';
		for (var i in group) {
			html += '<input name="' + i + '" id="' + i + '" value="' + group[i] + '" type="hidden" />';
		}
		html += '</form>';
		jQuery('div#fakeForm').html(html);
		jQuery('form#tempform').submit();
	}
	
	function printImage(encode, url, bike_name, bike_id) {
		var decode = Base64.decode(encode);
		var ary = decode.split("&");
		var group = [];
		var groupName = [];
		for (var i=0; i<ary.length; i++) {
			var temp = ary[i].split("=");
			group.push(temp[1].toLowerCase());
			groupName.push(temp[0].toLowerCase());
		}
		var imageFileName = group.join("_") + ".jpg";
		url = unescape(url);
		var popWin = window.open(url + '?f=' + imageFileName + '&bike_id=' + bike_id + '&bike_name=' + bike_name + '&group_name=' + groupName,'popWin','scrollbars=yes,width=890,height=580');
		if(popWin) {
			popWin.focus();
		}
	}
	
	function isValidEmailFormat(str) {
		var re = /^\S+\@\S+\.\S+$/;	
		return re.test(str);
	}
	
	window.addEvent('domready', function() {
		if ($('getaquoteForm')) {
			$('groupset').getParent().adopt( new Element('div', {'id':'er-groupset', 'class':'error-message'}) );
			$('crankset').getParent().adopt( new Element('div', {'id':'er-crankset', 'class':'error-message'}) );
			$('wheelset').getParent().adopt( new Element('div', {'id':'er-wheelset', 'class':'error-message'}) );
			$('fullname').getParent().adopt( new Element('div', {'id':'er-fullname', 'class':'error-message'}) );
			$('address').getParent().adopt( new Element('div', {'id':'er-address', 'class':'error-message'}) );
			$('city').getParent().adopt( new Element('div', {'id':'er-city', 'class':'error-message'}) );
			$('country').getParent().adopt( new Element('div', {'id':'er-country', 'class':'error-message'}) );
			$('tel').getParent().adopt( new Element('div', {'id':'er-tel', 'class':'error-message'}) );
			$('email').getParent().adopt( new Element('div', {'id':'er-email', 'class':'error-message'}) );
			
			$('getaquoteForm').addEvent('submit', function() {
				var isSubmit = true;
				$('er-groupset').innerHTML = "";
				$('er-crankset').innerHTML = "";
				$('er-wheelset').innerHTML = "";
				$('er-fullname').innerHTML = "";
				$('er-address').innerHTML = "";
				$('er-city').innerHTML = "";
				$('er-country').innerHTML = "";
				$('er-tel').innerHTML = "";
				$('er-email').innerHTML = "";
				
				if ( $('groupset').value == "" ) {
					$('er-groupset').innerHTML = "Please select the group set";
					isSubmit = false;
				}
				if ( $('crankset').value == "" ) {
					$('er-crankset').innerHTML = "Please select the crank set";
					isSubmit = false;
				}
				if ( $('wheelset').value == "" ) {
					$('er-wheelset').innerHTML = "Please select the wheel set";
					isSubmit = false;
				}
				if ( $('fullname').value == "" ) {
					$('er-fullname').innerHTML = "Please enter the full name";
					isSubmit = false;
				}
				if ( $('address').value == "" ) {
					$('er-address').innerHTML = "Please enter the street address";
					isSubmit = false;
				}
				if ( $('city').value == "" ) {
					$('er-city').innerHTML = "Please enter the city";
					isSubmit = false;
				}
				if ( $('country').value == "" ) {
					$('er-country').innerHTML = "Please enter the country";
					isSubmit = false;
				}
				if ( $('tel').value == "" ) {
					$('er-tel').innerHTML = "Please enter the telephone";
					isSubmit = false;
				}
				if ( $('email').value == "" ) {
					$('er-email').innerHTML = "Please enter the email address";
					isSubmit = false;
				}
				if ( $('email').value != "" ) {
					if (!isValidEmailFormat( $('email').value )) {
						$('er-email').innerHTML = "Please enter a valid email address";
						isSubmit = false;
					}
				}
				return isSubmit;
			});
			
			
			
			$('dealer-search').addEvent('click', function(event) {
				event.stop();
				var searchList = new Array();
				var req = new Request({
					method: 'get',
					url: "http://www.neilprydebikes.com/index.php?option=com_npbikes&view=all&layout=xml&is_xml=1",
					onRequest: function() {  },
					onSuccess: function(html) {
						var obj = unserialize(html);
						for (var i in obj) {
							var dealer = obj[i];
							if ( dealer["address"].toLowerCase().indexOf($('search-txt').value.toLowerCase()) != -1 ) {
								searchList.push(dealer);
							}
						}
						genSearchResultList(searchList);
					}
				}).send();
			});
		}
		
		if ($('saveforlaterForm')) {
			$('email').getParent().adopt( new Element('div', {'id':'er-email', 'class':'error-message'}) );
			$('saveforlaterForm').addEvent('submit', function() {
				var isSubmit = true;
				if ( $('email').value == "" ) {
					$('er-email').innerHTML = "Please enter the email address";
					isSubmit = false;
				}
				if ( $('email').value != "" ) {
					if (!isValidEmailFormat( $('email').value )) {
						$('er-email').innerHTML = "Please enter a valid email address";
						isSubmit = false;
					}
				}
				return isSubmit;
			});
		}
		
		if ($('sharebyemailForm')) {
			$('email_to').getParent().adopt( new Element('div', {'id':'er-email_to', 'class':'error-message'}) );
			$('email_from').getParent().adopt( new Element('div', {'id':'er-email_from', 'class':'error-message'}) );
			$('sharebyemailForm').addEvent('submit', function() {
				var isSubmit = true;
				if ( $('email_to').value == "" ) {
					$('er-email_to').innerHTML = "Please enter the email address";
					isSubmit = false;
				}
				if ( $('email_to').value != "" ) {
					if (!isValidEmailFormat( $('email_to').value )) {
						$('er-email_to').innerHTML = "Please enter a valid email address";
						isSubmit = false;
					}
				}
				if ( $('email_from').value == "" ) {
					$('er-email_from').innerHTML = "Please enter the email address";
					isSubmit = false;
				}
				if ( $('email_to').value != "" ) {
					if (!isValidEmailFormat( $('email_from').value )) {
						$('er-email_from').innerHTML = "Please enter a valid email address";
						isSubmit = false;
					}
				}
				return isSubmit;
			});
		}
	});
	
function genSearchResultList(list) {
		var str = '';
		var remarkText = 'If the listed dealers are too far from your location please contact us directly: ';
		$('search-result-container').innerHTML = str;
		str += '<div class="searchList">';
		for (var i=0; i<list.length; i++) {
			str += '		<input class="input-radio dealer-email" name="dealer-info" type="radio" value="' + list[i]["email"] + '">';
			str += '		<div class="dealer-info">';
			str += '			<div class="companyname">';
			str += '				' + list[i]["name"];
			str += '			</div>'
			str += '			<div class="companydetail">';
			str += '			' + list[i]["address"] + "<br>" + list[i]["phone"] + "<br>" + list[i]["email"];
			str += '			</div>'
			str += '			<div class="clearfix"> </div>';
			str += '		</div>'
			str += '	<div class="clearfix"> </div>';
		}
		str += '	<div class="remark">' + remarkText  + '</div>';
		str += '	<input class="input-radio dealer-email validate-one-required" name="dealer-info" type="radio" value="info@neilprydebikes.com">';
		str += '	<div class="dealer-info">';
		str += '		<div class="companyname">NeilPryde Bikes</div>'
		str += '	</div>';
		str += '	<div class="clearfix"> </div>';
		str += '</div>';

		$('search-result-container').innerHTML = str;
		
	}	
	
	/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/
 
var Base64 = {
 
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}
//-->