// Kohl's Corporate Landing Slider //

$(document).ready(function () {

	// CORPORATE PAGES RANDOM MILWAUKEE IMAGE
	var p = 12;
	var randImg = Math.ceil(Math.random()*(p));
	$("#mw-leadin-img").css("background","url(/images/milwaukee/corp-imgs/"+randImg+".jpg)");
	

	// CORPORATE HOME SLIDER
	$("#carousel li a").mouseover(function(){
		$(this).css("color","#45640a");
	});
	$("#carousel li a").mouseout(function(){
		$(this).css("color","#ffffff");
	});

	var pos = 0;
	var slideCount = $('#carousel ul').children().size();
	var slides = Math.ceil(slideCount/3);
	var slide = 1;
	
	if ( slide == slides ) {
		$("#next").css("opacity",.4);
		$("#next").css("cursor","default");
	}
	if ( slide == 1 ) {
		$("#previous").css("opacity",.4);
		$("#previous").css("cursor","default");
	}	
	
	$("#next").click(function(){
		if (slide != slides) {
			slide += 1;
			pos -= 690;
			$("#carousel ul").animate({left: pos+"px"}, {duration: 500, easing: "easeInOutCirc"});
			$(this).css("opacity",1);
			$(this).css("cursor","pointer");
			$("#previous").css("opacity",1);
			$("#previous").css("cursor","pointer");
		};
		if ( slide == slides ) {
			$(this).css("opacity",.4);
			$(this).css("cursor","default");
		}
	});

	$("#previous").click(function(){
		if (slide != 1) {
			slide -= 1;
			pos += 690;
			$("#carousel ul").animate({left: pos+"px"}, {duration: 500, easing: "easeInOutCirc"});
			$(this).css("opacity",1);
			$(this).css("cursor","pointer");
			$("#next").css("opacity",1);
			$("#next").css("cursor","pointer");
		};
		if ( slide == 1 ) {
			$(this).css("opacity",.4);
			$(this).css("cursor","default");
		}
	});
	//detects flash
    if (jQuery("#videochunk").length > 0) {
        if (FlashDetect.installed && FlashDetect.major >= 9) {   
            var strVideoBox = '<div id="vid-left">&nbsp;</div>\n';
            strVideoBox = strVideoBox + '<div id="two-video">\n';
            strVideoBox = strVideoBox + '\t<div class="video"><div id="meet1">&nbsp;</div></div>\n';
            strVideoBox = strVideoBox + '\t<div class="video"><div id="meet2">&nbsp;</div></div>\n';
            strVideoBox = strVideoBox + '</div>\n';
            strVideoBox = strVideoBox + '<div id="vid-right">&nbsp;</div>\n';
            strVideoBox = strVideoBox + '<div class="clear"></div>\n';
    		
            jQuery("#videochunk").html(strVideoBox);
            
            //inserts flash
            var flashvars = {};
            var params = {};
            var attributes = {};
            params.allowScriptAccess="always";
            params.wmode="opaque";
            
            jQuery.get("videos.xml", function(data){
                if (jQuery(data).find("videopath")[0] != null && jQuery(jQuery(data).find("videopath")[0]).text() != "") {
                    flashvars.xmlpath = jQuery(jQuery(data).find("videopath")[0]).text();
                    flashvars.divid = "meet1";
                    swfobject.embedSWF("/videodata/swfs/videoplayer.swf", "meet1", "340", "192", "9.0.0", "", flashvars, params, attributes);
                }
                if (jQuery(data).find("videopath")[1] != null && jQuery(jQuery(data).find("videopath")[1]).text() != "") {
                     flashvars.xmlpath = jQuery(jQuery(data).find("videopath")[1]).text();
                    flashvars.divid = "meet2";
                    swfobject.embedSWF("/videodata/swfs/videoplayer.swf", "meet2", "340", "192", "9.0.0", "", flashvars, params, attributes);
                }
            });
        }
    }
});
var arrFlashIDs = new Array();
arrFlashIDs.push("meet1");
arrFlashIDs.push("meet2");

function videoplay(strDivID){
    for (var i = 0; i < arrFlashIDs.length; i++) {
        if (arrFlashIDs[i] != strDivID) {
            if (document.getElementById(arrFlashIDs[i])) {
                if (document.getElementById(arrFlashIDs[i]).pauseplayback) {
                    document.getElementById(arrFlashIDs[i]).pauseplayback();
                }
            }
        }
    }
}