navHoverFix = function () {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i = 0; i < navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				node.onmouseover = function () {
					this.className += " over";
				}
				node.onmouseout = function () {
					this.className = this.className.replace(" over", "");
				}
			}
		}
	}
}

window.onload = navHoverFix;

$(document).ready(function () {
	$(".external").unbind("click").bind("click", function () {
		window.open(this.href);
		return false;
	});
});

featuredtechnologies_docready = function () {
    setTopNavOnState("featuredTechnologies");
    var flashvars = { swfPath: "./flash/featured_technologies.swf" };
    var params = { wmode: "transparent" };
    var attributes = {};
    swfobject.embedSWF("./flash/Preloader.swf", "container_flash", "1000", "700", "9.0.0", "", flashvars, params, attributes);
}

featuredmachines_docready = function () {
	setTopNavOnState("featuredMachines");
	var flashvars = {swfPath: "./flash/featured_machines.swf"};
	var params = { wmode: "transparent" };
	var attributes = {};
	swfobject.embedSWF("./flash/Preloader.swf", "container_flash", "1000", "700", "9.0.0", "", flashvars, params, attributes);
}

lunchandlearn_docready = function () {
	setTopNavOnState("lunchAndLearn");
}

lalregister_docready = function () {
	setTopNavOnState("lunchAndLearn");
	$("input[type='checkbox']").ezMark();
}

lalthankyou_docready = function () {
	setTopNavOnState("lunchAndLearn");
}

cvSeminars_Validate = function (source, args) {
	args.IsValid = ($("#seminars input:checked").length > 0);
}

cvEmail_Validate = function (source, args) {
	var email = args.Value;
	var re = /^(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})$/;
	args.IsValid = ($.trim(email) != '' && email.match(re));
}

makeanappointment_docready = function () {
	setTopNavOnState("makeAnAppointment");
	//$(".ddlDate").sSelect();
	//$(".ddlTime").sSelect();
	Cufon.replace(".selectedTxt", { fontFamily: "UniverseBlack" });
}

gallery_docready = function () {
    setTopNavOnState("gallery");
}

maathankyou_docready = function () {
	setTopNavOnState("makeAnAppointment");
}

findus_docready = function () {
	setTopNavOnState("findUs");
}

contactus_docready = function () {
	setGlobalNavOnState("contactUs");
}

contactusthankyou_docready = function () {
	setGlobalNavOnState("contactUs");
}

pressroom_docready = function () {
	setGlobalNavOnState("pressRoom");
}

setTopNavOnState = function (id) {
	$("#nav li a").each(function () {
		$(this).removeClass("on");
		if ($(this).attr("id") == id) {
			$(this).addClass("on");
		}
	});
}

setGlobalNavOnState = function (id) {
	$("#globalNav li a").each(function () {
		$(this).removeClass("on");
		if ($(this).attr("id") == id) {
			$(this).addClass("on");
		}
	});
}

var LimelightVideoPath;
playVideo = function (flvPath) {
    LimelightVideoPath = flvPath;
  

    //$("#videoFrame").attr("src", "playvideo.aspx?flvPath=" + flvPath);
    var modal = new NewWindow(
		{ id: "container_modal", overlayOpacity: .6, closeButton: "btnClose", shadowLevels: 0 }
	);
    modal.onWindowClose = function () {
        //$("#videoFrame").attr("src", "");
    }
    modal.open();
}


function delvePlayerCallback(playerId, eventName, data) {
    var id = "limelight_player_395841";
    if (eventName == 'onPlayerLoad' && (DelvePlayer.getPlayers() == null || DelvePlayer.getPlayers().length == 0)) {
        DelvePlayer.registerPlayer(id);
    }

    switch (eventName) {
        case 'onPlayerLoad':
            var MediaID;
            switch (LimelightVideoPath) {
                case "rtmp://hsrbtob.fcod.llnwd.net/a1758/o15/makino/imts2010/Advantige_Preview.mp4":
                    MediaID = "4da9caafc5db46c4add20498c443a469";
                    break;
                case "rtmp://hsrbtob.fcod.llnwd.net/a1758/o15/makino/imts2010/AluminumAerospaceMachining_Preview.mp4":
                    MediaID = "ccf43a0b84874b46a6275138f8ab8ea5";
                    break;
                case "rtmp://hsrbtob.fcod.llnwd.net/a1758/o15/makino/imts2010/ProductionMachining_Preview.mp4":
                    MediaID = "10e1777c117549729f402e7d1d192e17";
                    break;
                case "rtmp://hsrbtob.fcod.llnwd.net/a1758/o15/makino/imts2010/MicroMachining_Preview2.mp4":
                    MediaID = "d33109ccc3f04eaeac909b2eca186bfa";
                    break;
                case "rtmp://hsrbtob.fcod.llnwd.net/a1758/o15/makino/imts2010/DieMold_Preview.mp4":
                    MediaID = "448351389d4741a6a40df4c7cfd3aabf";
                    break;
                case "rtmp://hsrbtob.fcod.llnwd.net/a1758/o15/makino/imts2010/EDM_Preview.mp4":
                    MediaID = "e0332dea7d824a898468d399158052fd";
                    break;
                case "rtmp://hsrbtob.fcod.llnwd.net/a1758/o15/makino/imts2010/Automation_Preview.mp4":
                    MediaID = "f614f5d5e2064b4ba500f777ef4c4e27";
                    break;
            }
            DelvePlayer.doLoadMedia(MediaID, true);
            break;
    }
}

