var ajaxRequest = new XMLHttpRequest();

function AjaxLoadPage(url) {
	var Content = document.getElementById('Content');
	Content.className = "Content Solid Hidden";
	if(url.indexOf("product_")!=-1)
		var fullUrl = 'content.php?page='+url+"&ajax=true";
	else
		fullUrl = 'Pages/'+url+'.html';
	ajaxRequest.onreadystatechange =
		function() {
			if(ajaxRequest.readyState==4) {
				if (ajaxRequest.status==200)
					Content.innerHTML = ajaxRequest.responseText;
				else
					Content.innerHTML = "Error:<br/>unable to load page at <b>"+fullUrl+"</b>";
				Content.className = "Content Solid";
				Custom.init();
			}
		}
	ajaxRequest.open("GET",fullUrl,true);
	ajaxRequest.send();
}

function getElementsByName_iefix(tag, name) {
     
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}

function activatePlaceholders() {
	var detect = navigator.userAgent.toLowerCase(); 
	if (detect.indexOf("safari") > 0 || detect.indexOf("chrome") > 0)
		return false;
	var inputs = document.getElementsByTagName("input");
	for (var i=0;i<inputs.length;i++) {
		if (inputs[i].getAttribute("type") == "text") {
			if (inputs[i].getAttribute("placeholder") && inputs[i].getAttribute("placeholder").length > 0) {
				inputs[i].value = inputs[i].getAttribute("placeholder");
				inputs[i].onclick = function() {
					if (this.value == this.getAttribute("placeholder")) {
						this.value = "";
					}
					return false;
				}
				inputs[i].onblur = function() {
					if (this.value.length < 1) {
						this.value = this.getAttribute("placeholder");
					}
				}
			}
		}
	}
}

function popup(mylink, windowname)
{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	   href=mylink;
	else
	   href=mylink.getAttribute('href');
	window.open(href, windowname, 'width=512,height=512,scrollbars=no');
	return false;
}

function goToSignup() {
	var baseurl = "http://apple.freebiejeebies.co.uk/231701";
	var myInputs = document.getElementsByTagName("input");
	var itemid = "";
	for (var i=0;i<myInputs.length;i++) {
		if(myInputs[i].type == "radio" && myInputs[i].checked == true) {
			itemid="itemid" + String(myInputs[i].alt);
		}
	}
	window.location = baseurl+itemid;
}
