var _thispage = "";

function w(s) { document.write(s); }
function wl(s) { document.writeln(s); }
function wlbr(s) { document.writeln(s+'<br>'); }


function setCookie(c_name, value, expiredays, path)
		{
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);

		var copt="";

		if (expiredays != null) copt = copt+";expires="+exdate.toGMTString();
		if (path != null) copt = copt+";javahere=yes;path="+path;

		document.cookie=c_name+ "=" +escape(value)+ copt;
		}


function getCookie(c_name)
		{
		if (document.cookie.length>0)
			{
			c_start=document.cookie.indexOf(c_name + "=");
			if (c_start!=-1)
				{ 
				c_start=c_start + c_name.length+1; 
				c_end=document.cookie.indexOf(";",c_start);
				if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
				} 
			}

		return "";
		}



function redirectpage(url, wait)
		{
		wl('<meta HTTP-EQUIV="Refresh" CONTENT="'+wait+';URL=http:'+url+'">');
		wl('If the page fails to appear please <a href="'+url+'">click here</a>');
		}


function resetBrandID()
		{
		setCookie("brandid", "", 120, "/");
		}

function setBrandID(id)
		{
		setCookie("brandid", id, 120, "/");
		}

function getBrandID()
		{
		return getCookie("brandid");
		}

function getPageURL()
		{
		if (_thispage.length == 0)
			{
			var i, j;
			
			i = document.URL.indexOf('?', i);
	
			if (i < 0) i = document.URL.length;
			_thispage = document.URL.substring(0, i);
	
			if (_thispage == "" || _thispage.charAt(_thispage.length-1) == '/') _thispage += "index.html";
			}
		
		return _thispage;
		}

function getPageName()
		{
		var	i, s, t;
		
		s = getPageURL();
		i = s.lastIndexOf('/')
		
		if (i > 0)
			{
			t = s.substring(i+1, s.length);
			}
		else
			{
			t = s;
			}
		
		return t;
		}

