//return a random number from 1 up to and including intMax
function Rnd(intMax)
{
	return Rnd0(intMax)+1;
}

//return a random number from 0 up to and not including intMax
function Rnd0(intMax)
{
	return Math.floor(Math.random()*intMax);
}

//return a random array item
function RndA(ary)
{
 	return ary[Rnd0(ary.length)];
}

function ClickMe(blnFirst)
{
	if (!blnFirst)
	{
	    $('divLittleGuys').hide();
	    newLittleGuy();

        //get next little guy		
        if (window.location.href.indexOf("http://forums.g4tv.com")>-1)
            var myAjax = new Ajax.Request('http://forums.g4tv.com/messageview.cfm?catid=24&threadid=568763', {method: 'get' });
        else if (window.location.href.indexOf("http://g4tv.com/")>-1)
            var myAjax = new Ajax.Request('http://g4tv.com/littleguys.aspx', {method: 'get' });
        
        urchinTracker("/pageview_events/clicked_on_a_little_guy");
	}
	else
	{
		newLittleGuy();
		
		// cache icons
		for(var i=1; i<=7; i++)
		{
		    var icon = new Image();
		    icon.src = "http://media.g4tv.com/images/phoenix/littleguys/cute_" + i + ".gif";
		}
	}

	return false;
}

var blnFirstLittleGuy=true;
function newLittleGuy()
{
	var intWhichIcon = Rnd(7);

	$('imgLittleGuys').src = "http://media.g4tv.com/images/phoenix/littleguys/cute_" + intWhichIcon + ".gif";

	$('hrefLittleGuys').blur();

	if (blnFirstLittleGuy)
	{
		$('spnLittleGuysText').innerHTML = aryTextOptions[0];
		blnFirstLittleGuy=false;
	}
	else
	{
		$('spnLittleGuysText').innerHTML = RndA(aryTextOptions);
    }

    $('divLittleGuys').show();
}

var aryTextOptions;
function initLittleGuys()
{
    if ($('divLittleGuys'))
    {
	    aryTextOptions = [
            "Click Me",
            "...One Giant Click for Mankind",
            "...You Started Clicking This",
            "All Your Clicks Are Belong to Us",
            "Can You Click?",
            "Can't Stop Clicking",
            "Chicks with Clicks",
            "Click Forever",
            "Click Her",
            "Click Him",
            "Click Me ME",
            "Click Off, A-hole!",
            "Click Them",
            "Click and Dagger",
            "Click for Glory",
            "Click for Justice",
            "Click for Success",
            "Click for Truman",
            "Click me again!",
            "Click or die",
            "Click... Clock... Click... Clock",
            "Clicker",
            "Clickit or Ticket",
            "Clickity Click Click",
            "Clickity Click, Clickity Clack",
            "Clickizzle Foshizzle",
            "Clickophobia yet?",
            "Clickque Moi",
            "Clicks are for kids",
            "Clicky Fembot",
            "Das ist Klik",
            "Dirty Click Monster",
            "Four Score and Seven Clicks Ago...",
            "Get Your Click On",
            "Get Your Clicks",
            "Gimme a Click",
            "Hyperlink Me",
            "Mouse Here",
            "One Small Click for Man...",
            "Screw you and your whole preppy Click, man! ",
            "Select This",
            "Single Click",
            "Someone set us up the click",
            "Sometimes you feel like a Click",
            "The Clicker Man! Boo!",
            "This is Clicking Ridiculous",
            "Try Clicking Here",
            "U Know U Want 2",
            "Why Not Click?",
            "You look like the type of guy who has a hard time finding the click",
            "You're Still Clicking?",
            "Click it and lick it",
            "Click your mother",
            "Make with the Clicky",
            "Click it, just a little bit",
            "Almost there",
            "Click me harder",
            "Click me faster",
            "Click for more",
            "Click me baby",
            "You have a big click",
            "Let me watch you click",
            "You give good click",
            "Click me long time",
            "Hey big clicker",
            "Totally Click-o-licious",
            "Click-fil-a",
            "Click that mess!!",
            "Click this mess!!",
            "Bringin' Clicky Back",
            "Click me...Click you!!",
            "Click it like it's hot!",
            "Clickinator",
            "Click and Bake",
            "Click You!",
            "Clicky Litter",
            "Click and Sniff",
            "Click and Jane",
            "DO IT!!",
            "Stop looking at my Clicks!",
            "Wanna touch my clicks?",
            "Go Click yourself San Diego!",
            "Click It To Me",
            "Click Away",
            "Clicks Ahoy",
            "You Won't Click Me When You're Angry",
            "I Like Big Clicks",
            "Everyday I Click The Link",
            "Everytime You Click Away",
            "You Can't Always Click What You Want",
            "A Click A Day Keeps The Aliens Away",
            "To Click Or Not To Click",
            "Support OCD, Click Here",
            "Whole Lotta Clickin' Goin On",
            "Clicker Up Front",
            "Click Envy",
            "Click-On-Click Action",
            "Better Than Fantasy Football",
            "Can't Find The Click?",
            "Clickheads Apply Here",
            "Live Free Or Click",
            "Clicks 2: The Clickering",
            "Click it, Fool",
            "Click or Die",
            "Surprise Here",
            "Click and all of you wildest dreams will come true",
            "Click Clack",
            "What's this?",
            "Clicka What?",
            "Click, Pants, Now!",
            "Click For Glory",
            "uClick",
            "Click it, Baby",
            "I'm Ron BurgunClickme?",
            "The Greatest Click Ever",
            "OrgasClick",
            "C-C-C-C-CLICK",
            "clickso-facto",
            "Click 2: Electric Boogaloo",
            "Click (The Movie)",
            "The Wrath Of Click",
            "Click It Beyotch",
            "Gimmie A Click",
            "Click To The Future",
            "Click Your Fate",
            "Click Fever",
            "Click Me Baby",
            "Click You",
            "Bag 'O Click",
            "Le Clic (That'S French, Dude)",
            "Clicks Of Steel",
            "Must... Keep... Clicking...",
            "Dawn Of The Click",
            'Dr. Uwe Bolls "Click In The Dark"',   
            "Help me I'm hostage in a click",
            "Click Cheney",
            "Click It To Ride",
            "The Great Click-tator"
            
            ];
            
        ClickMe(true);
    }
}
addLoadEvent(initLittleGuys);