// Global Variable Declarations
ns4 = (document.layers)? true:false; // netscape 4?
ie4 = (document.all)? true:false; // internet explorer 4/5?
ns6 = (ns4|ie4)? false:true; // (Netscape 6)

var isLoaded=false;

var screen_top=(screen.height/2)-(500/2);
var screen_left=(screen.width/2)-(300/2);

// Image Functions

function image_swap(in_name,in_state) {
	if (!isLoaded) {
		return true;
	}
	document.images[in_name].src = eval(in_name + "_" + in_state + ".src");
}

// Popups

// Specific functions
function setPopupPosition(in_height,in_width) {
	screen_top=(screen.height/2)-(in_height/2);
	screen_left=(screen.width/2)-(in_width/2);
	if (screen_top<0) {
		screen_top=0;
	}
	if (screen_left<0) {
		screen_left=0;
	}
}

// Window openers
function openContact(in_brand, in_lang) {
	contact_width=417;
	contact_height=550;
	popupWin = window.open('popups/contact.aspx?brand=' + in_brand + '&lang=' + in_lang,'contact','width=' + contact_width + ',height=' + contact_height + ',scrollbars=yes,resize=no');
}

function openNewsletter(in_brand, in_lang, in_email) {
	news_width=417;
	news_height=550;
	popupWin = window.open('popups/newsletter.aspx?brand=' + in_brand + '&lang=' + in_lang + '&email=' + in_email,'newsletter','width=' + news_width + ',height=' + news_height + ',scrollbars=yes,resize=no');
}

function openResponsibility(in_brand, in_lang) {
	resp_width=417;
	resp_height=550;
	popupWin = window.open('popups/responsibility.aspx?brand=' + in_brand + '&lang=' + in_lang,'responsibility','width=' + resp_width + ',height=' + resp_height + ',scrollbars=yes,resize=no');
}

function openTerms() {
	terms_width=500;
	terms_height=550;
	popupWin = window.open('http://www.bacardi.com/BacardiGlobal/global_master.html','terms','width=' + terms_width + ',height=' + terms_height + ',scrollbars=yes,resize=no');
}

function openPrivacy() {
	terms_width=500;
	terms_height=550;
	popupWin = window.open('http://www.bacardi.com/BacardiGlobal/global_master.html','terms','width=' + terms_width + ',height=' + terms_height + ',scrollbars=yes,resize=no');
}

function openWheel() {
	js_width=770;
	js_height=550;
	if (screen.width>800) {
		js_width=819;
		js_height=725;
	}

	wheelWindow = window.open('redirects/wow_wheel_redirect.aspx?access=wow.a.wheel!','wheel','width=' + js_width + ',height=' + js_height + ',scrollbars=yes,resize=no,resizable=no');
	wheelWindow.focus();
}

// Global Init

function global_init() {
}

// Tracking Changes
function submitLDA(in_context)
{
	if (in_context!="yearchange") {
		document.forms[0].elements["SubmitContext"].value=in_context;
		document.forms[0].submit();
	}
}
// Send an LDA tag
function sendLDATrack(in_context, in_market)
{
    // Make sure we have values
    if (in_market=="" || in_market==null)
    {
        in_market="All";
    }
    if (in_context=="" || in_context==null)
    {
        in_context="pre";
    }
    
    // Send tags
	if (in_context=="pre")
	{
		dcsMultiTrack('DCS.dcssip', 'www.dewars.com', 'DCS.dcsuri', 'lda', 'WT.ti', 'LDA Page', 'WT.sp', in_market);
	}
	else
	{
		dcsMultiTrack('DCS.dcssip', 'www.dewars.com', 'DCS.dcsuri', 'post_lda', 'WT.ti', 'LDA Post Page', 'WT.sp', in_market);
	}
}

// Init
function lda_tracking_init()
{
	if (js_hasPassedAgeCheck)
	{
	    try
	    {
    		sendLDATrack("post",js_trackingMarket);
		}
		catch(e)
		{
		}
		
		if (js_redirectString!="" && js_redirectString!=null)
		{
			document.location=js_redirectString;
		}
		else
		{
			document.forms[0].elements["SubmitContext"].value="agecheck";
			document.forms[0].elements["RedirectPageAfterSubmit"].value="true";
			document.forms[0].submit();
		}				
	}
	else
	{
		if (js_throwLDATag)
		{
			sendLDATrack("pre",js_trackingMarket);
		}
	}
	isLoaded=true;
}