
var prodDivs = new Array();
var prodLinks = new Array();
var currentHash;


function initProduct() {

    var divTags = document.getElementsByTagName("div");
    var linkTags = document.getElementsByTagName("a");

    for (i = 0; i < divTags.length; i++) {

        if (divTags[i].id.indexOf("DivLarge") == 0) {

            prodDivs.push(divTags[i]);

        }

    }

    for (i = 0; i < linkTags.length; i++) {

        if (linkTags[i].className == "redarrow") {

            prodLinks.push(linkTags[i]);

        }

    }
    if (prodDivs.length > 0) {
    
        checkHash(true);
        setInterval("checkHash(false)", 100);
    }
}

function checkHash(initial) {
    if ((currentHash != location.hash) || initial) {
        if ((location.hash.length > 0) && (document.getElementById("DivLarge" + location.hash.substring(1)) != null)) {
            showProduct(location.hash.substring(1));
        } else {
            showProduct(prodDivs[0].id.substring("DivLarge".length));
        }
        currentHash = location.hash;
    }
}


function closeProduct() {

for (i = 0; i < prodDivs.length; i++) {

    prodDivs[i].style.display = "none";
    prodLinks[i].className = "redarrow";

}

}

function showProduct(divName) {
    closeProduct();
    var div = document.getElementById("DivLarge" + divName);
    div.style.display = "block";
    pageTracker._trackPageview(location.pathname + "#" + divName);

    for (i = 0; i < prodDivs.length; i++) {
    
        if (prodDivs[i].id.substring("DivLarge".length) == divName) {

            prodLinks[i].className = "redarrow_on";
        
        }


    }

}




// Enables Assignment of Multiple window.onload Functions
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

addLoadEvent(initProduct);


function getDHTMLObj(objName)
{
	if (document.getElementById)
		return document.getElementById(objName);
	else if (document.all)
		return document.all[objName];
	else if (document.layers)
		return document.layers[objName];
	else
		return null;
} 

function cacheImages()
{
	var i;
	
	var oImages = new Array(document.images.length);			//array of image objects
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_off\.(gif|jpg)/) > 0 )
		{	
			oImages[i] = new Image();
			oImages[i].src = document.images[i].src.replace("_off.", "_on.");
		}
	}
	return;
}

function setImage(oImage)
{

	var i;

	//first reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_on\.(gif|jpg)/) )
			document.images[i].src.replace("_on.", "_off.");
	}
	
	//now set the image to be in the "on" state		
	eval(oImage).src = eval(oImage).src.replace("_off.", "_on.");
				
	return;
}

function clearImages()
{
	var i;
	
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_on\.(gif|jpg)/) > 0 )
			document.images[i].src = document.images[i].src.replace("_on.", "_off.");
	}
	return;
}

function openWindow(url, name, width, height, resize, scroll, center)
{
	var sParams = '';
	name = (name == null) ? '' : name;

	sParams += 'width=' + width;
	sParams += ',height=' + height;
	sParams += (resize || resize == 'true') ? ',resizable=yes' : ',resizable=no';
	sParams += (scroll || scroll == 'true') ? ',scrollbars=yes' : ',scrollbars=no';
	sParams += (center || center == 'true') ? ',left=' + ((screen.width - width) / 2) : '';
	sParams += (center || center == 'true') ? ',top=' + ((screen.height - height) / 2) : '';

	window.name = 'opener';
	var popupWin = window.open(url, name, sParams);
	popupWin.focus();
	return;
}

function showFaq(id){	

	document.getElementById(id).style.visibility = "visible";
	document.getElementById(id).style.display = "block";
}

function hideFaq()
{
	for (i=1; i < 12; i++) 
	{
		document.getElementById('faq' + i).style.visibility = "hidden";
		document.getElementById('faq' + i).style.display = "none";
	}
	
}

function swapImg(val)
{
    document.maing.src = val.src;          
}

function openRules()
{
	window.open('/Promotions/Tropic-Thunder-Sweeps-Rules.htm','Rules','scrollbars=yes,status=no,width=500,height=400')
}


function openTrailer()
{
	window.open('/Promotions/Tropic-Thunder-Movie-Trailer.aspx','Trailer','scrollbars=no,status=no,width=750,height=520')
}

/* AddThis Configuration */
var addthis_options = 'favorites,facebook, twitter, email, delicious, myspace, aim, digg, more';
var addthis_header_color = "#ffe2a9";
var addthis_header_background = "#4c2200";

var addthis_width = 100;
var addthis_localize = {
    share_caption: "<div align='center'><strong>Bookmark & Share</strong></div>"
}

var addthis_config ={  
    ui_hover_direction: "1"
   }

function getObject(objectID) {
    if (document.all != null) {
        return document.all[objectID];
    } else if (document.getElementById) {
        return document.getElementById(objectID);
    }
}

function showDIV(divID) {
    var divPop = getObject(divID);
    divPop.style.display = "block";
}

function hideDIV(divID) {
    var divPop = getObject(divID);
    divPop.style.display = "none";
}

function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

    return true;
}