$(document).ready(function () {
    var flashvars = false;
	var params = {};
	var attributes = {};

	bodyID =  $("body").attr("id");
	li_on = bodyID.replace("Body", "");
	
	if (bodyID == "homeBody") {
			params.menu = "false";
			params.wmode = "transparent";
			swfobject.embedSWF("DudnykHomepage.swf", "flash", "920", "640", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
	}
	
	if(bodyID == "aboutBody"){
		if($("#peopleDiv").length > 0){
			$("#peopleDiv div").bind("mouseenter",function(){
				this.className += " over";
			}).bind("mouseleave",function(){
						this.className = this.className.replace("over", "");
			});											  
															  
		}
		if($("#overlayDiv").length > 0){
			$("#closeOverlay").bind("click",function(){
				$("#overlayDiv").addClass("invisible");								 
			});
			$("#overlayshow").bind("click",function(){
				$("#overlayDiv").removeClass("invisible");									
			});
		}
	}
	
	if (bodyID == "workBody"){
		if($("#mobaDiv").length > 0){
			params.menu = "false";
			params.wmode = "transparent";
			params.quality = "autohigh";
			swfobject.embedSWF("wall_of_fame_new_v2.swf", "flash", "867", "440", "9.0.0", "/expressInstall.swf", flashvars, params, attributes);

		}
		
		if($("#expCall").length > 0){
			$("div.logoWrapper").scrollable({vertical:true, size: 3, easing:"easeInOutBack", speed: 1000, items:".logos"});
		}
		
		else if($("div.logoWrapper").length > 0){
			$("div.logoWrapper").scrollable({vertical:true, size: 4, easing:"easeInOutBack", speed: 1000, items:".logos"});
			client = "default";
			
			if($("#jqueryBox").length > 0){
				$.history( 'cache.php' );
				
				$.history.callback = function ( reinstate, cursor ) {
					// reinstate is the actual object to reinstate
					
					if (typeof(reinstate) == 'undefined'){
						client = "default";
					}else{
						client = reinstate.client;
						if (client == "") client = "default";
					}
					
					myURL = "../includes/work/" + client + ".html";
					$.ajax({
						url: myURL,
						cache: false,
						success: function (html){
							$("#jqueryBox").html(html);
							$("div.workSpace").scrollable({vertical:true, size: 1, easing:"easeInOutBack", speed: 1000});
							if($("#icons").length > 0){
								$('#icons').imghover({suffix: '_on'});
								
								$("#icons a").bind("click",function(){
									
									client = (this.id).substring(2);
									
									$("#" + client).click();
								
								});
							}
						}
					});
				}
			}
			
			$("div.logos div a").bind("click", function(){
				$("div.logos div a").removeClass("on");
				this.className += "on";
				
				$.history( {'client': client });
				
				client = this.id;
				myURL = "../includes/work/" + client + ".html";
				$.ajax({
					url: myURL,
					cache: false,
					success: function (html){
						$("#jqueryBox").html(html);
						$("div.workSpace").scrollable({vertical:true, size: 1, easing:"easeInOutBack", speed: 1000});
					}
				});
			});
			
			if(location.search && location.search.length != 0){
				client = (location.search).substring(8);
				$("#" + client).click();
			}
			
			if($("#icons").length > 0){
				$('#icons').imghover({suffix: '_on'});
				
				$("#icons a").bind("click",function(){
					
					client = (this.id).substring(2);
					
					$("#" + client).click();
				
				});
			}
		}
			
		if($("div.workSpace").length > 0){
			$("div.workSpace").scrollable({vertical:true, size: 1, easing:"easeInOutBack", speed: 1000});
		}
	}
	
	if(bodyID == "contactBody"){
		if($("#contactForm").length > 0){
			var whichform = document.getElementById("whichForm").value;
			document.getElementById("c_reason").selectedIndex = (whichform == "careers") ? 1 : (whichform == "vendors") ? 2 : (whichform == "brandfuel") ? 3 :  0;
			
			document.getElementById("c_name").value = myName;
			document.getElementById("c_email").value = myEmail;
			document.getElementById("c_phone").value = myPhone;
			document.getElementById("c_notes").value = myNotes;
			if($("#c_company").length > 0) document.getElementById("c_company").value = myCompany;

			$("#c_reason").bind("change", function(){
				type = this.options[this.selectedIndex].value;
				myURL = "../includes/contact/" + type + ".html";
				
				myName = document.getElementById("c_name").value;
				myEmail = document.getElementById("c_email").value;
				myPhone = document.getElementById("c_phone").value;
				myNotes = document.getElementById("c_notes").value;
				if($("#c_company").length > 0) myCompany = document.getElementById("c_company").value;
					
				$.ajax({
					url: myURL,
					cache: false,
					success: function (html){
						$("#jqueryBox").html(html);
						document.getElementById("c_name").value = myName;
						document.getElementById("c_email").value = myEmail;
						document.getElementById("c_phone").value = myPhone;
						document.getElementById("c_notes").value = myNotes;
						if($("#c_company").length > 0) document.getElementById("c_company").value = myCompany;
					}
				});
			});
		}
	}
	
	$('#content_bottom, #footer, #dudexchange, #lock, #logoImg, #contentAltBottom').ifixpng();
	
	$("#nav li").bind("mouseenter",function(){
				this.className += " over";
	}).bind("mouseleave",function(){
				this.className = this.className.replace("over", "");
	});
	
	if(li_on == "about" || li_on == "work" || li_on == "news" || li_on == "contact"){
		document.getElementById(li_on).className = "on";
		
		
	}
});

