function findObj(theObj, theDoc) {
  var p, i, foundObj;

  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++)
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

  return (foundObj);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function getCookie(name) {
	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
			return unescape(document.cookie.substring(offset, end))
		}
		else return ""
	}
}

var uri = new Object();

startList = function() {
	if (document.all&&document.getElementById&&document.getElementById("nav")) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
	getURL( uri );
	setKeyword( "keyword" );
}
window.onload=startList;

function getURL( uri ) {
	uri.dir = location.href.substring( 0, location.href.lastIndexOf( '\/' ));
	return uri;
}

function setKeyword( name ) {
  parm = new Array;
	value = new Array;
	var beg = "" + location.href;
	beg = beg.substring( beg.indexOf( name ) );
	parm = beg.split( '&' );
	for ( i = 0; i < parm.length; i++ ) {
	   value[ i ] = parm[ i ].split( '=' );
	   	if ( value[ i ][ 0 ] == name ) {
 		createMyCookie( "keyword", value[ i ][ 1 ] );
		}
	}
}

function createMyCookie( name, value, days ) {
	if ( days )	{
		var date = new Date();
		date.setTime( date.getTime() + ( days*24*60*60*1000 ));
		var expires = "; expires=" + date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name + "=" + value + expires + "; path=/";
}

function getDate() {
	var d = new Date();
	var year = "" + d.getFullYear();
	year = year.substring(( year.length - 2 ), year.length );
	var month = "" + ( d.getMonth() + 1 );
	if ( month.length == 1 ) {
		month = "0" + month;
	}
	var data = "" + d.getDate();
	if ( data.length == 1 ) {
		data = "0" + data;
	}
	return ( year + month + data );
}

function getMyCookie( name ) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf( "; " + prefix );
    if ( begin == -1 ) {
        begin = dc.indexOf( prefix );
        if ( begin != 0 ) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf( ";", begin );
    if ( end == -1 ) {
        end = dc.length;
    }
    return unescape( dc.substring( begin + prefix.length, end ));
}

function getCookie2( name ) {
  parm = new Array;
	value = new Array;
	var beg = "" + location.href;
	beg = beg.substring( beg.indexOf( name ) );
	parm = beg.split( '&' );
	for ( i = 0; i < parm.length; i++ ) {
	   value[ i ] = parm[ i ].split( '=' );
	   if ( value[ i ][ 0 ] == name )  return value[ i ][ 1 ];
	}
	return null;
}

function changeLanguage() {
	var loc = parent.location.href;
	if (loc.lastIndexOf("/tc/") != -1) {
		tloc = loc.replace("/tc/", "/gb/");
	} else {
		tloc = loc.replace("/gb/", "/tc/");
	}
	window.parent.location = tloc;
}

function ieupdate(){
 var strBrowser = navigator.userAgent.toLowerCase();
 if(strBrowser.indexOf("msie") > -1 && strBrowser.indexOf("mac") < 0){
  var theObjects = document.getElementsByTagName('object');
  var theObjectsLen = theObjects.length;
  for (var i = 0; i < theObjectsLen; i++) {
   if(theObjects[i].outerHTML){
    if(theObjects[i].data){
     theObjects[i].removeAttribute('data');
    }
    var theParams = theObjects[i].getElementsByTagName("param");
    var theParamsLength = theParams.length;
    for (var j = 0; j < theParamsLength; j++) {
      if(theParams[j].name.toLowerCase() == 'flashvars'){
        var theFlashVars = theParams[j].value;
      }
    }
    var theOuterHTML = theObjects[i].outerHTML;
    var re = /<param name="FlashVars" value="">/ig;
    theOuterHTML = theOuterHTML.replace(re, "<param name='FlashVars' value='" + theFlashVars + "'>");
    theObjects[i].outerHTML = theOuterHTML;
   }
  }
 }
}

window.onunload = function() {
 if (document.getElementsByTagName) {
  var objs = document.getElementsByTagName("object");
  for (i=0; i<objs.length; i++) {
   objs[i].outerHTML = "";
  }
 }
}

