// JavaScript Document
$(document).ready(function() {
	$('.jqmWindow').jqm();
	$('.jqmTrigger').click(function(){
		$(this).next().jqmShow();						   
	});
	$('.Text').click(function(){
		$('.RssList').find('ul').toggle();
	});
	$('.Arrow').click(function(){
		$('.RssList').find('ul').toggle();
	});
});

if (document.images) {
     button1 = new Image
     button2 = new Image
	 
	 button3 = new Image
     button4 = new Image

	 button5 = new Image
     button6 = new Image
	 
	 button7 = new Image
     button8 = new Image
	 
	 button9 = new Image
     button10 = new Image
	 
	 button11 = new Image
     button12 = new Image
	 
	 button13 = new Image
     button14 = new Image
	 
	 button15 = new Image
     button16 = new Image
	 
	 button17 = new Image
     button18 = new Image

     button1.src = '/wp-content/themes/edelman_digital/img/aha.jpg'
     button2.src = '/wp-content/themes/edelman_digital/img/aha_over.jpg'
	 
	 button3.src = '/wp-content/themes/edelman_digital/img/axe.jpg'
     button4.src = '/wp-content/themes/edelman_digital/img/axe_over.jpg'
	 
	 button5.src = '/wp-content/themes/edelman_digital/img/brita.jpg'
     button6.src = '/wp-content/themes/edelman_digital/img/brita_over.jpg'
	 
	 button7.src = '/wp-content/themes/edelman_digital/img/dmi.jpg'
     button8.src = '/wp-content/themes/edelman_digital/img/dmi_over.jpg'
	 
	 button9.src = '/wp-content/themes/edelman_digital/img/hp.jpg'
     button10.src = '/wp-content/themes/edelman_digital/img/hp_over.jpg'
	 
	 button11.src = '/wp-content/themes/edelman_digital/img/kona_blue.jpg'
     button12.src = '/wp-content/themes/edelman_digital/img/kona_blue_over.jpg'
	 
	 button13.src = '/wp-content/themes/edelman_digital/img/dove.jpg'
     button14.src = '/wp-content/themes/edelman_digital/img/dove_over.jpg'
	 
	 button15.src = '/wp-content/themes/edelman_digital/img/natures_path.jpg'
     button16.src = '/wp-content/themes/edelman_digital/img/natures_path_over.jpg'
	 
	 button17.src = '/wp-content/themes/edelman_digital/img/ben_and_jerrys.jpg'
     button18.src = '/wp-content/themes/edelman_digital/img/ben_and_jerrys_over.jpg'
 }
 
function opendiv(name)
{
	var str = document.getElementById(name).className;
	var result = (str.indexOf('open') < 0);
	
	//CLOSE ALL BEFORE OPPENING
	document.getElementById('officesAtlanta').className = 'Offices';
	document.getElementById('officesChicago').className = 'Offices';
	document.getElementById('officesLA').className = 'Offices';
	document.getElementById('officesMexico').className = 'Offices';
	document.getElementById('officesMontreal').className = 'Offices';
	document.getElementById('officesNY').className = 'Offices';
	document.getElementById('officesPortland').className = 'Offices';
	document.getElementById('officesSanFrancisco').className = 'Offices';
	document.getElementById('officesSaoPaulo').className = 'Offices';
	
	document.getElementById('officesSeattle').className = 'Offices';
	document.getElementById('officesToronto').className = 'Offices';
	document.getElementById('officesVancouver').className = 'Offices';
	document.getElementById('officesWashington').className = 'Offices';
	document.getElementById('officesAmsterdam').className = 'Offices';
	document.getElementById('officesBarcelona').className = 'Offices';
	document.getElementById('officesDublin').className = 'Offices';
	document.getElementById('officesHamburg').className = 'Offices';
	document.getElementById('officesLondon').className = 'Offices';
	document.getElementById('officesMadrid').className = 'Offices';
	document.getElementById('officesMilan').className = 'Offices';
	document.getElementById('officesMoscow').className = 'Offices';
	document.getElementById('officesParis').className = 'Offices';
	document.getElementById('officesStockholm').className = 'Offices';
	document.getElementById('officesWarsaw').className = 'Offices';
	
	document.getElementById('officesHongKong').className = 'Offices';
	document.getElementById('officesJakarta').className = 'Offices';
	document.getElementById('officesMelbourne').className = 'Offices';
	document.getElementById('officesMumbai').className = 'Offices';
	document.getElementById('officesSeoul').className = 'Offices';
	document.getElementById('officesKorea').className = 'Offices';
	document.getElementById('officesShanghai').className = 'Offices';
	document.getElementById('officesSingapore').className = 'Offices';
	document.getElementById('officesSydney').className = 'Offices';
	document.getElementById('officesTokyo').className = 'Offices';
	
	
	if(result)
	{
		document.getElementById(name).className = 'Offices open';
	}
}

function dropdown1click()
{
	var val = document.getElementById('dropdown1').value;
	
	//alert(val);
	
	document.getElementById('2dropdown').style.display = "none";
	document.getElementById('textfieldName').style.display = "none";
	document.getElementById('textfieldEmail').style.display = "none";
	document.getElementById('textfieldPhone').style.display = "none";
	document.getElementById('textfieldMessage').style.display = "none";
	document.getElementById('submitbuttoncontactus').style.display = "none";
	document.getElementById('contactForm').target = "_self";
	
	switch(val)
	{
		case 0:
			//do nothing
			break;
		case '1':
			//alert("TRACE 1");
			document.getElementById('textfieldName').style.display = "";
			document.getElementById('textfieldEmail').style.display = "";
			document.getElementById('textfieldPhone').style.display = "";
			document.getElementById('textfieldMessage').style.display = "";
			document.getElementById('submitbuttoncontactus').style.display = "block";
			break;
		case '2':	
			//alert("TRACE 2");
			document.getElementById('textfieldName').style.display = "";
			document.getElementById('textfieldEmail').style.display = "";
			document.getElementById('textfieldPhone').style.display = "";
			document.getElementById('textfieldMessage').style.display = "";
			document.getElementById('submitbuttoncontactus').style.display = "block";
			break;
		case '3':
			//alert("TRACE 3");
			document.getElementById('2dropdown').style.display = "block";
			document.getElementById('textfieldName').style.display = "";
			document.getElementById('textfieldEmail').style.display = "";
			document.getElementById('textfieldPhone').style.display = "";
			document.getElementById('textfieldMessage').style.display = "";
			document.getElementById('submitbuttoncontactus').style.display = "block";
			break;
		case '4':
			//alert("TRACE 4");
			document.getElementById('submitbuttoncontactus').style.display = "block";
			document.getElementById('contactForm').target = "_blank";
			break;
	}
}

function initSlideShow()
{
	$('.slideShow').each(function() {
		var ID = $(this).attr('id');
		//alert(ID);
		var flashvars = {
			paramXMLPath: "param.php?id=" + ID,
			initialURL: escape(document.location.href)
		};
		var params = { 
			base: ".",
			bgcolor: "#121212",
			wmode: "transparent",
			allowfullscreen: "true"
		};        
		var attributes = {};
		swfobject.embedSWF("/wp-content/themes/edelman_digital/swf/slideshowpro.swf", ID, "489", "333", "9.0.0", false, flashvars, params, attributes);
	});
}

$(document).ready(function() {
	initSlideShow();
	setTooltip();
	applyGroupToggleBehavior();
	if ($('#FridayFiveInnerBox').size() > 0) {
		hideFridayFive();
		applySignUp();
	}
});

function hideFridayFive() {
	$('#fridayFive').parent().css('display', 'none');
}

function applySignUp() {
	$('#FridayFiveInnerBox').click(function(){
		$('#MainInnerBoxText').hide();
		$('#SignUpBox').show();
	});
}

function applyGroupToggleBehavior() {
		$('.Offices').click(function(){
			if($(this).next('div.subInfo').css('display') == 'none') {
				$('.subInfo').hide();
				$(this).next('div.subInfo').show();
				$('.officesInfoOpen').attr('class','officesInfo');
				$(this).find('.officesInfo').attr('class','officesInfoOpen');
			} else {
				$('.subInfo').hide();
				$('.officesInfoOpen').attr('class','officesInfo');
			}
		});
}

function setTooltip() {
	jQuery('#viewpoints').attr('title', 'Industry voices and opinions');
	jQuery('#imagination').attr('title', 'Sharing all the interesting stuff we find');
	jQuery('#aboutus').attr('title', 'Who we are and what we do');
	jQuery('#careers').attr('title', 'Work with the best and brightest');
	
	jQuery("body").append('<div id="eddTooltip"><span><em>tootip</em></span><?div>');
	
	var tooltipTarget;
	jQuery('#viewpoints, #imagination, #aboutus, #careers, #ourwork').hover(
		function (e) {
			if (tooltipTarget != null && tooltipTarget != jQuery(this) && !tooltipTarget.hasClass('current')) {
				tooltipTarget.css({backgroundPosition:'top left'});
			}
			tooltipTarget = jQuery(this);
//			alert(jQuery('.current').eq(0).html());
//			alert(tooltipTarget.html());
			
			jQuery('#eddTooltip').css({display:''});
			jQuery('#eddTooltip span em').eq(0).html(jQuery(this).attr('title')).parent().parent().css({left: jQuery(this).offset().left + 10, top: jQuery(this).offset().top - 40});
			
			jQuery('body').mousemove(
				function (e) {
					if(e.pageX < tooltipTarget.offset().left || e.pageY < tooltipTarget.offset().top || e.pageX > tooltipTarget.offset().left + tooltipTarget.width() || e.pageY > tooltipTarget.offset().top + tooltipTarget.height()) {
						if (!tooltipTarget.hasClass('current')) {
							tooltipTarget.css({backgroundPosition:'top left'});
						}
						jQuery('#eddTooltip').css({display:'none'});
					} else {
						tooltipTarget.css({backgroundPosition:'top right'});
					}
				}
			);
		}
	);
	
	//jQuery("#menus a").tTips();
	//jQuery("#menus a").tooltip()
	//alert( typeof(jQuery.shadowbox) );
	//alert(typeof(jQuery.tTips))
}

/*
var SHARETHIS = { };
SHARETHIS.addEntry = function(){}
*/


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
