function e(id){ 
	return document.getElementById(id);
}

function trackPageView(bike_id)
{
try
  {
  	//alert('/bikeview/'+bike_id);
	urchinTracker('/bikeview/'+bike_id);
  }
catch(err)
  {
  }
  
  return true;
  
}

function populateModels(id){
	
	//Hide or show the model box if it's not equal to ALL
	var str = id.split("model_id");
	var str_id = str[1];
	if (str_id == "") {

		e("model_combo_container").innerHTML="<select class=\"ub_form\" style=\"width: 175px;\"><option>All models</option></select>";
		//e("model_combo_container").className="model_combo_off";
		
		//if (str_last_active.length > 0) {
		//	e(str_last_active).name = "";
		//}
	}
	else {
		//e("model_combo_text").className="model_combo_on";
		//e("model_combo_container").className="model_combo_on";
	}
	
	//Display the correct model onchange
	if ((e("model_combo_container")) && (e(id + "_container"))) {
		
		//alert(id);
		
		if (e(id + "_container") && e(id + "__source")) {
			var str_combo = String(e(id + "_container").innerHTML);
			str_combo = str_combo.split("__source").join("");
		
			e("model_combo_container").innerHTML = str_combo;
			e(id).name = "model_id";
			str_last_active = id;
		}
	}
}

function displayBarContent(id) {
	switch(id)
	{
	case "in-stock":
	  e("ub-bar-under").src = "Images/img-under-in-stock-on.gif";
	  e("ub-bar-content").innerHTML = e("ub-stock-content").innerHTML;
	  break;
	case "enquire-now":
	  e("ub-bar-under").src = "Images/img-under-enquiry-on.gif";
	  e("ub-bar-content").innerHTML = e("ub-enquire-content").innerHTML;
	  break;
	}	
}


function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

// Example:

// alert( readCookie("myCookie") );

function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function checkScroll() {

	if (readCookie("bln_scroll_to_bottom") == true) {
		scrollTo(0,99999999999);
		writeCookie("bln_scroll_to_bottom", false, 0);
		
	}
}

function isdefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}
