<!--//
//Cross Browser Object Retrieval
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 showConfirm(showIt){
	if (showIt){
		showDIV("pnlConfirm");
	} else {
		hideDIV("pnlConfirm");
	}
}

function popRelease(showIt){
	if (showIt){
		showDIV("pnlRelease");
	} else {
		hideDIV("pnlRelease");
	}
}

/*Popup Window Functions*/
var popUpWin;
var popDefWidth = 570;
var popDefHeight = 400;
var lastWidth;
var lastHeight;

//Open URL in new window with fixed dimensions
function openWin(url, pixWidth, pixHeight, canScroll){
	var winFeatures = "width=" + pixWidth + ",height=" + pixHeight + "," + getCentered(pixWidth,pixHeight) + ",resizable=no,scrollbars=";
	if (canScroll){
		winFeatures += "yes";
	} else {
		winFeatures += "no";
	}
	if (popUpWin != null){
		if (popUpWin.closed){
			popUpWin = window.open(url, "popwin", winFeatures);
			popUpWin.focus();
		} else if ((lastWidth == pixWidth) && (lastHeight == pixHeight)){
			popUpWin.location.href = url;
			popUpWin.focus();
		} else {
			popUpWin.close();
			var timeDelay = 0;
			if (navigator.userAgent.indexOf("Safari") != -1){
				timeDelay = 1000;
			}
			var winWait = window.setTimeout('popUpWin = window.open("' + url + '", "popwin", "' + winFeatures + '");popUpWin.focus();', timeDelay);
		}	
	} else {
		popUpWin = window.open(url, "popwin", winFeatures);
		popUpWin.focus();
	}
	lastWidth = pixWidth;
	lastHeight = pixHeight;
}

//Get coordinates for centering window
function getCentered(popupWidth, popupHeight){
	var indentNetscapeWidth = 'screenX=' + getIndent(popupWidth, false);
	var indentNetscapeHeight = 'screenY=' + getIndent(popupHeight, true);
	var indentMSIEWidth = 'left=' + getIndent(popupWidth, false);
	var indentMSIEHeight = 'top=' + getIndent(popupHeight, true);
	var centerCoordinates = indentNetscapeWidth + ',' + indentNetscapeHeight + ',' + indentMSIEWidth + ',' + indentMSIEHeight;
	return centerCoordinates;
}

//Determine top and left margins for window
function getIndent (popupDimension, isHeight){
	if (isHeight){
		return ((screen.availHeight - popupDimension) / 2);
	} else {
		return ((screen.availWidth - popupDimension) / 2);
	}
}

function popRelease(){
	openWin("release.aspx", 518, 509, false);
}

function popRules(version){
	openWin(version + "_rules.aspx", 478, 509, false);
}

//Close popup and redirect parent to URL
function closeAndGo(url){
	var newWin;
	if (window.opener != null){
		if (window.opener.closed){
			newWin = window.open(url,'newwin','width=' + screen.availWidth + ',height=' + screen.availHeight + ',toolbar=yes,status=yes,directories=yes,location=yes,menubar=yes,personalbar=yes,resizable=yes,scrollbars=yes');
			newWin.focus();
		} else {
			window.opener.location.href = url;
			window.opener.focus();
		}
	} else {
		newWin = window.open(url,'newwin','width=' + screen.availWidth + ',height=' + screen.availHeight + ',toolbar=yes,status=yes,directories=yes,location=yes,menubar=yes,personalbar=yes,resizable=yes,scrollbars=yes');
		newWin.focus();
	}
	window.close();
}

function playLogoSheen(){
	var logoSheen = window.document.logosheen;
	logoSheen.GotoFrame(2);
	logoSheen.Play();
}

//Floating Warning Label Setup
whereY = 275;


/* RANDOM PROMO DISPLAY */
var tmpPromo;
var brandPromos = new Array();
var brandPrefix = "/images/";
var brandSuffix = ".png";

tmpPromo = new Object();
tmpPromo.brand = "promo_beheard";
tmpPromo.alt = "Be Heard: See what other Red Seal Guys are saying and put in your own two cents. Show me!";
tmpPromo.href = "/beheard.aspx";
brandPromos.push(tmpPromo);

tmpPromo = new Object();
tmpPromo.brand = "promo_trivia";
tmpPromo.alt = "All New Trivia: Series 4 is here. See if you can stand up to the test. Play!";
tmpPromo.href = "/trivia.aspx";
brandPromos.push(tmpPromo);

function displayPromo(){
	var promoIndex = Math.floor(Math.random() * brandPromos.length);
	var promo = brandPromos[promoIndex];
	document.write('<a href="' + promo.href + '"><img src="' + brandPrefix + promo.brand + brandSuffix + '" width="172" height="190" alt="' + promo.alt + '" border="0"></a>');
}


//-->

$(document).ready(function() {
     if(swfobject.getFlashPlayerVersion().major >= 10) {
        $('#noFlash').hide();
    }else{
        $('#noFlash').show().addClass("wtLoad-RS_Flash_Landing-Red_Seal-Flash");
    }
    externalLinks();
    openSitelet();
    closeChildOnLogout();
	trackWebTrends();
});

//Start Parent/Child Sitelet JS

function openSitelet() {
    $(".pocParentLink").click( function() {
       child = window.open('/GetMorePromo/GetMorePromo.aspx', 'sitelet', 'width=980,height=600,resizable=no,scrollbars=no');
        return false;
    });
}

//End Parent/Child Sitelet JS

function unloadPage()
{
 confirm("Page will be closed");
}

function externalLinks() {
    $(".external").click( function() {
        var location = $(this).attr("href");
        dcsMultiTrack("DCS.dcsuri", "RS_U_ExternalLink_Landing", "WT.cg_n", "Red_Seal", "WT.cg_s", "External_Link_UNAU");
        if (confirmNavigation()) {
            window.open(location);
            dcsMultiTrack("DCS.dcsuri", "RS_U_ExternalLink_OK", "WT.cg_n", "Red_Seal", "WT.cg_s", "External_Link_UNAU");
        } else {
            dcsMultiTrack("DCS.dcsuri", "RS_U_ExternalLink_Cancel", "WT.cg_n", "Red_Seal", "WT.cg_s", "External_Link_UNAU");
        }
        return false;
    });
}

function flashExternalLink(location) {
    if (confirmNavigation()) {
        window.open(location);
        return false;
    } else {
        return false;
    }
}

function closeChildOnLogout() {
    $(".logOutBtn").click( function() {
        if (typeof child == "undefined") {
        }
        else {
            child.close();
        }
    })
}

/* Flash to Open Modify Profile Popup */

function openProfile(){
	openWin("/update_profile.aspx", 891, 630, 1);
}

/* confirmation to new window and external links */
function confirmNavigation() {
    dcsMultiTrack("DCS.dcsuri", "RS_A_ExternalLink_Landing", "WT.cg_n", "Red_Seal", "WT.cg_s", "External_Link_AUTH");
    if(confirm('You have requested to leave GoRedSeal.com to visit another website. Continue?')){
        return true;
    } else {
        dcsMultiTrack("DCS.dcsuri", "RS_A_ExternalLink_Close", "WT.cg_n", "Red_Seal", "WT.cg_s", "External_Link_AUTH");
        return false;
    }
}

/* Text Area Custom Max Length */
function textAreaMaxLength() {
	$('#txtTestimonial').maxlength(
		{
			'useInput' : true
		}
	);
}

/* Webtrends Functions */

function trackWebTrends() {
	$("[class*='wtLoad']:parent").each(
		function() {
			parseWebTrendsClass($(this));
		}
	);
	
	$("[class*='wtClick']").click(
		function() {
			parseWebTrendsClass($(this));
		}
	);
};

function parseWebTrendsClass(classString) {
    var wtFields = $(classString).attr("class").split("-");
    var wtParams = new Array("trackType", "DCS.dcsuri", "WT.cg_n", "WT.cg_s", "promocode");
    var dcsArray = new Array();
    for (i = 1; i <= wtFields.length; i++) {
        if (wtFields[i] != null) {
            dcsArray.push(wtParams[i],wtFields[i]);
        }
    }
    
    if(gUserID != ""){
	    dcsArray.push('WT.dcsvid');
	    dcsArray.push(gUserID); 
	}
	
	if(gCCN != ""){
	    dcsArray.push('CV.ccn');
	    dcsArray.push(gCCN); 
	}
	
	if(gSessionID != ""){
	    dcsArray.push('CV.session_id');
	    dcsArray.push(gSessionID); 
	}

    dcsMultiTrack(dcsArray);
}