function toggleFeaturedItems() {
    var fiDiv = $('fiDiv');
    var fiShowHideLink = $('fiHideShowLink');
    if ( typeof fiShowHideLink == 'undefined' || ! fiShowHideLink)
        return;
    if ( fiDiv.style.display == 'none' ) {
        fiDiv.style.display = '';
        fiShowHideLink.className = "right hideitems";
        fiShowHideLink.innerHTML = "Hide This";
        SetCookie("hidefi", "", 2000, "/", ".thesimsresource.com");  
    } else {
        fiDiv.style.display = 'none';
        fiShowHideLink.className = "right showthis";
        fiShowHideLink.innerHTML = "Show This";
        SetCookie("hidefi", "1", 2000, "/", ".thesimsresource.com"); 
    }
}

var downloadRules =
{   
    'body' : function(el)
    {
        if($('fiDiv'))
        {
            if(CheckCookie("hidefi")!="1")
            {
               toggleFeaturedItems();
            }    
        }
    }
    ,
	'a.bdownload' : function(el)
	{
		if(!auth_isLoggedIn())
		{
			el.onclick = function() { LightBox.LoadTemplate("/account/not-logged-in/feature/download"); return false; }
			return false;
		}
		el.style.display = "block";
		el.onclick = function(e)
		{
	 		var ret = checkRequirements(this);
	 		/*
            if(!auth_isSubscriber())
	 			return nonSubscriberLightbox(this);
            */
	 		return(ret);
		}
	}
	,
	'a.dl' : function(el)
	{
		if(!auth_isLoggedIn())
		{
			el.onclick = function() { LightBox.LoadTemplate("/account/not-logged-in/feature/download"); return false; }
			return false;
		}
		el.style.display = "block";
		el.onclick = function(e)
		{
/*            if(!auth_isSubscriber()) {
                var newHref = FCx(el.href);
                if(newHref != el.href)
                {
                    el.href = newHref;
                    el.target = "_blank";
                }
            }*/
            var itemid = this.getAttribute("itemid");
            if ( itemid > 0 ) {
                var feedbackbox = $('feedbackbox_' + itemid);
                if ( feedbackbox ) feedbackbox.style.visibility = 'visible';
            }
	 		var ret = checkRequirements(this);
            /*
	 		if(!auth_isSubscriber())
	 			return nonSubscriberLightbox(this);
	 		*/
            return(ret);
		}
	}
	,
	'a.dll' : function(el)
	{
		if(!auth_isLoggedIn())
		{
			el.onclick = function() { LightBox.LoadTemplate("/account/not-logged-in/feature/download"); return false; }
			return false;
		}
		el.style.display = "block";
		el.onclick = function(e)
		{
	 		var ret = checkRequirements(this);
	 		/*
            if(!auth_isSubscriber())
	 			return nonSubscriberLightbox(this);
	 		*/
            return(ret);
		}
	}
	,
	'a.s2p' : function(el)
	{
		if(!auth_isLoggedIn())
		{
			el.onclick = function() { LightBox.LoadTemplate("/account/not-logged-in/feature/download"); return false;  }
			return false;
		}
		el.style.display = "block";
		el.onclick = function(e)
		{
            /*if(!auth_isSubscriber()) {
                var newHref = FCx(el.href);
                if(newHref != el.href)
                {
                    el.href = newHref;
                    el.target = "_blank";
                }
            }*/
            var itemid = this.getAttribute("itemid");
            if ( itemid > 0 ) {
                var feedbackbox = $('feedbackbox_' + itemid);
                if ( feedbackbox ) feedbackbox.style.visibility = 'visible';
            }
	 		var ret = checkRequirements(this);
	 		/*
            if(!auth_isSubscriber())
	 			return nonSubscriberLightbox(this);
	 		*/
            return(ret);
		}
	}
    ,
    'a.s3p' : function(el)
    {
        if(!auth_isLoggedIn())
        {
            el.onclick = function() { LightBox.LoadTemplate("/account/not-logged-in/feature/download"); return false;  }
            return false;
        }
        el.style.display = "block";
        el.onclick = function(e)
        {
            /*if(!auth_isSubscriber()) {
                var newHref = FCx(el.href);
                if(newHref != el.href)
                {
                    el.href = newHref;
                    el.target = "_blank";
                }
            }*/
            var itemid = this.getAttribute("itemid");
            if ( itemid > 0 ) {
                var feedbackbox = $('feedbackbox_' + itemid);
                if ( feedbackbox ) feedbackbox.style.visibility = 'visible';
            }
             var ret = checkRequirements(this);
             /*
            if(!auth_isSubscriber())
                 return nonSubscriberLightbox(this);
             */
            return(ret);
        }
    }    
	,	
	'a.bsk' : function(el)
	{     
		if(!auth_isLoggedIn())
		{
			el.onclick = function() { LightBox.LoadTemplate("/account/not-logged-in/feature/download"); return false;  }
			return false;
		}
		else if(!auth_isSubscriber())
		{
			el.onclick = function() { LightBox.LoadTemplate("/account/subscriber-feature/feature/downloadbasket"); return false;  }
		 	return false;
		}
		else
		{
	 		el.onclick = function()
	 		{		
				if(!checkRequirements(this)) return false;
				addToBasket(this);
			}
		}
		return false;
	}
	,	
	'a.bskl' : function(el)
	{
		if(!auth_isLoggedIn())
		{
			el.onclick = function() { LightBox.LoadTemplate("/account/not-logged-in/feature/download"); return false;  }
			return false;
		}
		else if(!auth_isSubscriber())
		{
			el.onclick = function() { LightBox.LoadTemplate("/account/subscriber-feature/feature/downloadbasket"); return false;  }
		 	return false;
		}
		else
		{
	 		el.onclick = function()
	 		{		
				if(!checkRequirements(this)) return false;
				addToBasket(this);
			}
		}
		return false;
	}
}

Behaviour.register(downloadRules);
//ValucClick interstitial
function FCx(x){
  var min=60; // minimum minutes between interstitials (needs to be >15)
  if(x.indexOf('get.media')>0){
    x=unescape(x.substring(x.indexOf('&url=')+5,x.length));
  }else{
    if(document.cookie.indexOf('CxIC=1')<=0){
      x='http://media.fastclick.net/w/get.media?sid=18639&m=5&tp=6&url='+escape(x);
      var date_ob=new Date();
      date_ob.setTime(date_ob.getTime()+min*1000*60);
      document.cookie='FCxIC=1; path=/; expires='+date_ob.toGMTString();
    }
  }
  return x;
}                

