var isMovieMuted = false;
 
function openVerify() {
    window.open("verify.html",'secure','width=517,height=500,menubar=0,toolbar=0,location=0,directories=0,scrollbars=0,status=0,resizable=0');
}
function openSecurity() {
    window.open("security.html",'secure','width=520,height=500,menubar=0,toolbar=0,location=0,directories=0,scrollbars=0,status=0,resizable=0');
}

// Shuts the current popup window
function shutme(){
    self.close();
}

// Catch all function for Flash calls
function openPopup(type){
	switch(type.toLowerCase()) {
		case "animal attach popup":
    		window.open("/MobileForm.aspx","mobile","location=0,status=0,scrollbars=0,width=607,height=492");
		    break;
		case "peperami_desktop_wallpapers.zip":
		    window.open("/download.html","download","location=0,status=0,scrollbars=0,width=607,height=300");
		    break;
		case "peperami_desktop_wallpapers_2.zip":
		    window.open("/download2.html","download2","location=0,status=0,scrollbars=0,width=607,height=300");
		    break;
		case "download mobile popup":
		    window.open("/GimmeTreats.aspx","Treats","location=0,status=0,scrollbars=0,width=607,height=492");
		    break;
	}
}
/*/ JS for popping up new window
function launchWindow(fileName){
    var windowName = "peperamiWindow";
    var windowProperties = "width=607,height=492,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no"
    var newwindow = window.open(fileName,windowName,windowProperties);
    if (window.focus) {newwindow.focus()}
}*/

// JS function for popups
function launchPopup(fileName){
    var windowName = "_blank";
    var windowProperties = "width=680,height=600,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no"
    var newWindow = window.open(fileName,windowName,windowProperties);
    if (window.focus) {newWindow.focus()}
}


// Toggle mute button depending on 
// global var isMovieMuted
function toggleMuteButton() {
	var muteButton = document.getElementById("Mute").getElementsByTagName("a")[0];
	if(isMovieMuted) {
		muteButton.className = "on";
		isMovieMuted = false;
	}
	else {
		muteButton.className = "off";
		isMovieMuted = true;
	}
}

// Calls muteSounds() external interface
function muteSounds(){
	var movie;
	try {
		movie = document.getElementById("OuterBase");
		movie.muteSounds();
		toggleMuteButton();		
	}
	catch(e) {
		try {
			movie = document.getElementById("InnerBase");
			movie.muteSounds();
			toggleMuteButton();
		}
		catch(ie) { //external interface not available 
		}
	}
}

/* JQuery - Unobtrusive JS Events */
$(function() {
    // Click event to launch popup for all links that popup a new window (finding links with class="launchPopup")
    $("a.launchPopup").click(function() {
        launchPopup(this.href);
        return false;
    });
    $("a.goBack").click(function() {
        history.back();
        return false;
    });
     $("a.closeWindow").click(function() {
        window.close();
    });
    
});

/* JQuery - Unobtrusive JS Events for WebTrends */
$(function() {
	$("a.downloadWallpapers").click(function() {
	 	dcsMultiTrack('DCS.dcsuri','/gimme_the_treats/desktop/download_wallpaper.link','WT.ti','Peperami - Desktop wallpaper','DCSext.brand','Peperami','DCSext.site','Peperami','WT.cg_n','Gimme the treats','WT.cg_s','Wallpaper - Download');
	 	return false;
	});
});
