function init() {
  if ( location.pathname != '/' || location.search == '' ) window.location = 'http://' + location.hostname + '?home'
	aObj = document.getElementById('nav').getElementsByTagName('a')
	for ( i=0;i<aObj.length;i++ ) {
      if (document.location.href.indexOf(aObj[i].href)>=0) {
        aObj[i].className = 'active'
		aObjParent = aObj[i].parentNode.parentNode.parentNode
		aObjParentA = aObjParent.getElementsByTagName('a')
		aObjParentTest = aObjParent.getElementsByTagName('ul')
		if ( aObjParent.id == 'menu' ) {}
		else if ( aObjParentTest.length > 0 ) aObjParentA[0].className = 'active' 
    }
  }
  
  liObj = document.getElementById('content').getElementsByTagName('li')
  for(i=0;i<liObj.length;i++) {
  	liObj[i].style.color = '#cfae78'
  }
  
  $(document).ready(function() {
	$('ul li').wrapInner('<span></span>')
  })
  
  if ( location.pathname + location.search == '/' || location.pathname + location.search == '/?home' ) {
	  displayOverlay();
  }
}

function SetCookie(sName, sValue, sPath, sExpires)
{
  sCookie = sName + "=" + escape(sValue);
  if( sPath!=null && sPath!="undefined" )
	  sCookie += ";path="+sPath;
	  var date = new Date();
		  date.setTime(date.getTime()+(7*24*60*60*1000));
		  var expires = '; expires='+date.toGMTString();
	  sCookie += expires
  document.cookie = sCookie;
}

function GetCookie(sName, sDefault)
{
  var aCookie = String(document.cookie).split(';');
  for (var i=0; i <aCookie.length; i++)
  {
	if( aCookie[i]==sName || aCookie[i]==(" "+sName) )
		return "";

	var aCrumb = aCookie[i].split("=");
	if (aCrumb[0]==sName || aCrumb[0]==(" "+sName)) 
	{
		var strResult=unescape(aCrumb[1]);
 
		if( strResult=="null" )
			return "";

		if( strResult=="undefined" )
			return "";

    	return strResult;
	}
  }
  
  if( typeof( sDefault )=="undefined" )
	return "";
  else
	return sDefault;
}

function DeleteCookie(name,path,domain) 
{
   if (GetCookie(name)=="") 
      return;
      
   if(path=="undefined")
      path=null;
      
   if( domain=="undefined" )
      path=null;
   
   var sCookie  = name + "=" +
      ((path) ? ";path=" + path : "") +
      ((domain) ? " domain=" + domain : "") +
      ";expires=Thu, 01-Jan-70 00:00:01 GMT";
    
   document.cookie = sCookie;
   
   alert(sCookie);
}

function displayOverlay() {
	if (GetCookie('origins') != 'nopopup010112') {
		SetCookie('origins','popup')
		$('#overlay').koverlay({title: 'title1', dynamic: true})
	}
}

function hideOverlay() {
	SetCookie('origins','nopopup251111')
	$('#overlay').koverlay.hide()
}

window.onload = init;

var flashvars = {}
var params = {wmode:"transparent"}
var attributes = {}
