// JavaScript Document

var httproot = "";

//Gets details about the OS and the browser

function GetBrowser() {

	var d, dom, mac, win, lin, old;
	var browser_ie, browser_ie4, browser_ie5x, browser_moz, browser_ie5mac, browser_ie5xwin, browser_op, browser_konq, browser_saf;
	
	d = document;
	n = navigator;
	na = n.appVersion;
	
	nua = n.userAgent;
	win = ( na.indexOf( 'Win' ) != -1 );
	mac = ( na.indexOf( 'Mac' ) != -1 );
	lin = ( nua.indexOf( 'Linux' ) != -1 );
	
	if ( !d.layers ){
		dom = ( d.getElementById );
		
		browser_op = nua.indexOf( 'Opera' );
		browser_konq = nua.indexOf( 'Konqueror' );
		browser_saf = nua.indexOf( 'Safari' );
		
		if ( nua.indexOf( 'Opera' ) != -1 ) return "Opera";
		if ( nua.indexOf( 'Konqueror' ) != -1 ) return "Konqueror";
		if ( nua.indexOf( 'Safari' ) != -1 ) return "Safari";
		if ( nua.indexOf( 'Gecko' ) != -1 && !browser_saf && !browser_konq) return "Firefox" ;
		if ( na.indexOf( 'MSIE 6.0' ) != -1 && na.indexOf('MSIE 7.0') == -1) return "IE6";
		if ( d.all && !browser_op ) return "IE";
		if ( browser_ie && !dom ) return "IE4";
		
	
		/*
		ie5x tests only for functionality. ( dom||ie5x ) would be default settings. 
		Opera will register true in this test if set to identify as IE 5
		*/
	
		if ( d.all && dom ) return "IE5x";
		if ( mac && browser_ie5x ) return "IE5Mac";
		if ( win && browser_ie5x ) return "IE5xWin";
	}

}

function returnObjById( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

function rollImg(imgnum, onoff) {
	the_img = returnObjById("mainlink"+imgnum);
	if (onoff == 1)
		the_img.src = httproot+"/shop/images/mainlinks_r"+imgnum+"_c1_f2.jpg"; 
	else  
		the_img.src = httproot+"/shop/images/mainlinks_r"+imgnum+"_c1.jpg"; 
}

function GetWinSize(dimension) {
	NS4Plus = (document.layers) ? 1 : 0;
	IE4Plus = (document.all) ? 1 : 0;
	if (navigator.appName=="Netscape") {
	  w = window.innerWidth;
	  h = window.innerHeight;
	}
	if (IE4Plus) {
		if (document.compatMode && document.compatMode != "BackCompat") {
			w=document.documentElement.clientWidth;
			h=document.documentElement.clientHeight;
		} else {
			w=document.body.clientWidth;
			h=document.body.clientHeight;
		}
	}
	if (dimension == "w")
		return w;
	else if (dimension == "h")
		return h;
	else
		return 0;

}

function Counter(message,counter,text,maxLength) {
  var messageObj=returnObjById(message);
  var counterObj=returnObjById(counter);
  var length=maxLength - messageObj.value.length;
  if(length <= 0) {
    length=0;
    text='<span class="disable"> '+text+' </span>';
    messageObj.value=messageObj.value.substr(0,maxLength);
  }
  counterObj.innerHTML = text.replace("{CHAR}",length);
}


// Current Page Reference
// copyright Stephen Chapman, 1st Jan 2005
// you may copy this function but please keep the copyright notice with it
function getURL(uri) {
uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
uri.path = ''; var pos = uri.dom.indexOf('\/'); if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
pos = uri.page.indexOf('?');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
pos = uri.page.indexOf('#');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
uri.ext = ''; pos = uri.page.indexOf('.');if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
uri.file = uri.page;
if (uri.ext != '') uri.file += '.' + uri.ext;
if (uri.file == '') uri.page = 'index';
uri.args = location.search.substr(1).split("?");
return uri;
}

                  
