// JavaScript Document

var lastDiv = "";
var chosenScenario = "";
function showDiv(divName) {
	if (lastDiv) {
		document.getElementById(lastDiv).className = "hiddenDiv";
		document.getElementById('Step1_2').className = "hiddenDiv";
  		document.getElementById('Step1_1').className = "hiddenDiv";
//		document.getElementById('ScenarioSelect').className = "hiddenDiv";
		document.getElementById('returnToStep1_1').className = "visibleDiv";
	}
	if (divName && document.getElementById(divName)) {
		document.getElementById(divName).className = "visibleDiv";
		document.getElementById('Step1_2').className = "visibleDiv";
 		 document.getElementById('Step1_1').className = "hiddenDiv";
//		document.getElementById('ScenarioSelect').className = "hiddenDiv";
		document.getElementById('returnToStep1_1').className = "visibleDiv";
		lastDiv = divName;
		chosenScenario = divName;
	}
}


function changeCaption(captionDropdown) {
	showStep1_3_new(); 
	var caption= captionDropdown.options[captionDropdown.selectedIndex].value;
	document.getElementById('getCaption').value = caption; 
        if (document.getElementById('getIllustration').value == null || document.getElementById('getIllustration').value == "") {
		document.getElementById('getIllustration').value = "illustrationSelect_01";
	}
	var imageId = document.getElementById('getIllustration').value.replace("Select_0", "");
	//document.getElementById('preview').style.background='url(/global/images/previews/illustration1_'+caption+'.jpg)';
	document.getElementById('preview').style.background='url(/global/images/previews/'+imageId+'_'+caption+'.jpg)';
}

function displayCaptionDropDown(scenarioValue) {
	var mySelect = document.getElementById('CaptionSelect');
	switch (scenarioValue){
	case "Scenario_01":
	     mySelect.options[0]=new Option("-- Select --", "null" );
	     mySelect.options[1]=new Option("Remember when I said I could handle this? Yeah, about that...", "caption_1" );
	     mySelect.options[2]=new Option("Consider this me officially saying 'uncle'. Uncle.", "caption_2" ) ;
	     mySelect.options[3]=new Option("Many hands make light work. And this is some heavy-@$$ work.", "caption_3" );
	     mySelect.options[4]=new Option("We need some new eyes on this, preferably attached to bodies.", "caption_8" );
	     mySelect.options[5]=new Option("Can't teach an old dog new tricks, but you can always hire new dogs.", "caption_9" ) ;
	     mySelect.options[6]=new Option("This T-E-A-M just lost an 'I'.", "caption_14" );
	     mySelect.options[7]=new Option("Admitting we need help is our first step towards hiring that help.", "caption_15" );
	     mySelect.options[8]=new Option("Here's a crazy idea: Let's get the talent to do this ourselves.", "caption_31" );
	     mySelect.options[9]=new Option("If you want something done right, hire someone to do it themselves.", "caption_32" ) ;
	     mySelect.options[10]=new Option("We could use a few more turtleneck-and-jeans types to help with this launch.", "caption_24" ) ;
	     mySelect.options.length=11;
	break;
	case "Scenario_02":
	     mySelect.options[0]=new Option("-- Select --", "null" );
	     mySelect.options[1]=new Option("What this project needs is more people who know things.", "caption_4" );
	     mySelect.options[2]=new Option("Can we get that team that built Rome in a day?", "caption_5" ) ;
	     mySelect.options[3]=new Option("The more things change, the more people we need to fix the changes.", "caption_6" );
	     mySelect.options[4]=new Option("Let's make a deal: I'll make the logo bigger if they make the day longer.", "caption_7" ) ;
	     mySelect.options[5]=new Option("This target would be way easier to hit if it would quit moving.", "caption_30" ) ;
	     mySelect.options.length=6;
	break;
	case "Scenario_03":
	     mySelect.options[0]=new Option("-- Select --", "null" );
	     mySelect.options[1]=new Option("Tis' the season for us to be totally shorthanded.", "caption_10" );
	     mySelect.options[2]=new Option("All I want for Christmas is some extra help.", "caption_11" ) ;
	     mySelect.options[3]=new Option("I'm suffering from Busy Seasonal Affective Disorder.", "caption_12" ) ;
	     mySelect.options[4]=new Option("We're down to the wire. And it's around our throats.", "caption_19" );
	     mySelect.options[5]=new Option("Change request: Make 32 the number of hours in a day.", "caption_20" ) ;
	     mySelect.options.length=6;
	break;
	case "Scenario_04":
	     mySelect.options[0]=new Option("-- Select --", "null" );
	     mySelect.options[1]=new Option("We’re in dire need of some trained pig makeup artists.", "caption_21" ) ;
	     mySelect.options[2]=new Option("If the product is being rebranded, why are we the ones getting burned?", "caption_22" ) ;
	     mySelect.options[3]=new Option("This new product is gonna change the world. We just need to figure out how.", "caption_23" );
	     mySelect.options[4]=new Option("I want us to see other disciplines.", "caption_25" );
	     mySelect.options[5]=new Option("Let's spice up our work life - let's try some new technology.", "caption_26" ) ;
	     mySelect.options[6]=new Option("Hey, that thing we did? Did it do anything?", "caption_27" );
	     mySelect.options.length=7;
	break;
	case "Scenario_05":
	     mySelect.options[0]=new Option("-- Select --", "null" );
	     mySelect.options[1]=new Option("When it rains, it pours...and it's raining problems right now.", "caption_13" );
	     mySelect.options[2]=new Option("Someone should be chekcing this prject for errorrs.", "caption_17" );
	     mySelect.options[3]=new Option("Good thing we spent all that time designing the 404 page.", "caption_18" ) ;
	     mySelect.options[4]=new Option("This job has \"out of my wheelhouse\" written all over it.", "caption_33" ) ;
	     mySelect.options.length=5;
	break;
	case "Scenario_06":
	     mySelect.options[0]=new Option("-- Select --", "null" );
	     mySelect.options[1]=new Option("Let's find out what the void thinks of all our shouting.", "caption_28" ) ;
	     mySelect.options[2]=new Option("Sometimes you gotta break the rules. Hire someone to do the breaking.", "caption_29" );
	     mySelect.options[3]=new Option("Apparently HR hasn't been getting my smoke signals.", "caption_16" ) ;
	     mySelect.options[4]=new Option("How did I get in this creek? And who has my paddle?", "caption_34" );
	     mySelect.options[5]=new Option("Chicken Little was RIGHT.", "caption_35" ) ;
	     mySelect.options[6]=new Option("Sometimes, there IS a wolf.", "caption_36" );
	     mySelect.options[7]=new Option("All hands on deck! And by deck, we mean keyboards.", "caption_37" ) ;
	     mySelect.options[8]=new Option("This square peg ain't digging the new round holes.", "caption_38" );
	     mySelect.options[9]=new Option("Can I get some ketchup for this dog food?", "caption_39" ) ;
	     mySelect.options.length=10;
	break;
	}
}

function changeScenario(scenarioDropdown) {
	displayCaptionDropDown(scenarioDropdown.options[scenarioDropdown.selectedIndex].value); 
	showDiv("Caption_01");
	document.getElementById('image').value = ''; 
	document.getElementById('randomDone').className = 'hiddenDiv'; 
//	document.getElementById('preview').style.background='url(/global/images/previews/blank.jpg)';
}


function returnToStep1_1_new() {
		document.getElementById('Step1_1').className = "visibleDiv";
		document.getElementById('Step1_2').className = "hiddenDiv";
		document.getElementById('Step1_3').className = "hiddenDiv";
		document.getElementById('ScenarioSelect').className = "visibleDiv";
		document.getElementById('Caption_01').className = "hiddenDiv";
//		document.getElementById('preview').style.background="url(images/previews/blank.jpg)";
//		document.getElementById('Scenario').value = "null";
		document.getElementById('CaptionSelect').value = "null";
		document.getElementById('returnToStep1_2').className = "hiddenDiv";
		document.getElementById('illustrationSelect_01').className = "hiddenDiv";
		document.getElementById('illustrationSelect_02').className = "hiddenDiv";
		document.getElementById('illustrationSelect_03').className = "hiddenDiv";
		document.getElementById('illustrationSelect_04').className = "hiddenDiv";
		document.getElementById('illustrationSelect_05').className = "hiddenDiv";
		document.getElementById('illustrationSelect_06').className = "hiddenDiv";
		document.getElementById('illustrationSelect_07').className = "hiddenDiv";
		document.getElementById('illustrationSelect_08').className = "hiddenDiv";
		document.getElementById('image').value = "";
 		document.getElementById('randomDone').className = 'hiddenDiv';
		document.getElementById('Step2').className = "hiddenDiv";
		document.getElementById('deliverForm').className = "hiddenDiv";
		document.getElementById('gobackButton').className = "hiddenDiv";
		document.getElementById('senditButton').className = "hiddenDiv";
		document.getElementById('randomCard').className = "visibleDiv";
		//document.getElementById('Step3').className = "hiddenDiv";
		document.getElementById('Scenario').disabled = false;
}

function showStep1_2() {

		document.getElementById('Scenario').disabled = true;
		document.getElementById('CaptionSelect').disabled = false;
}

function returnToStep1_2() {
		document.getElementById('Step1_1').className = "hiddenDiv";
		document.getElementById('Step1_2').className = "visibleDiv";
		document.getElementById('Step1_3').className = "hiddenDiv";
		document.getElementById('CaptionSelect').className = "visibleDiv";
		document.getElementById('illustrationSelect_01').className = "hiddenDiv";
		document.getElementById('illustrationSelect_02').className = "hiddenDiv";
		document.getElementById('illustrationSelect_03').className = "hiddenDiv";
		document.getElementById('illustrationSelect_04').className = "hiddenDiv";
		document.getElementById('illustrationSelect_05').className = "hiddenDiv";
		document.getElementById('illustrationSelect_06').className = "hiddenDiv";
		document.getElementById('illustrationSelect_07').className = "hiddenDiv";
		document.getElementById('illustrationSelect_08').className = "hiddenDiv";
		document.getElementById('image').value = "";
//		document.getElementById('randomDone').className = 'hiddenDiv';
		document.getElementById('CaptionSelect').disabled = false;
		document.getElementById('Scenario').disabled = true;
}

function returnToStep1_3() {
		var chosenIllustration = document.getElementById('getIllustration').value;
		document.getElementById(chosenIllustration).className = "visibleDiv";
		document.getElementById('Step1_1').className = "hiddenDiv";
		document.getElementById('Step1_2').className = "visibleDiv";
		document.getElementById('Step1_3').className = "visibleDiv";
		document.getElementById('ScenarioSelect').className = "visibleDiv";
		document.getElementById('Caption_01').className = "visibleDiv";
		document.getElementById('returnToStep1_2').className = "visibleDiv";
		document.getElementById('returnToStep1_1').className = "visibleDiv";
		document.getElementById('image').value = "";
 		document.getElementById('randomDone').className = 'hiddenDiv';
		document.getElementById('Step2').className = "hiddenDiv";
		document.getElementById('deliverForm').className = "hiddenDiv";
		document.getElementById('gobackButton').className = "hiddenDiv";
		document.getElementById('senditButton').className = "hiddenDiv";
		document.getElementById('randomCard').className = "visibleDiv";
		//document.getElementById('Step3').className = "visibleDiv";
		document.getElementById('CaptionSelect').disabled = true;
		document.getElementById('Scenario').disabled = true;
}

function showStep1_3_new() {
                if (document.getElementById('getIllustration').value == null || document.getElementById('getIllustration').value == "") {
			document.getElementById('getIllustration').value = "illustrationSelect_01";
		}
		document.getElementById('Step1_2').className = "hiddenDiv";
		document.getElementById('Step1_3').className = "visibleDiv";
		document.getElementById(document.getElementById('getIllustration').value).className = "visibleDiv";
		var imageId = document.getElementById('getIllustration').value.replace("Select_0", "");
		document.getElementById('preview').style.background="url(/global/images/previews/'+imageId+'_'+this.value+'.jpg)";
//		document.getElementById('Caption_01').className = "hiddenDiv";
		document.getElementById('returnToStep1_1').className = "visibleDiv";
		document.getElementById('returnToStep1_2').className = "visibleDiv";
		document.getElementById('CaptionSelect').disabled = true;
		document.getElementById('Scenario').disabled = true;
}




function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function randomCard_new() {
var illustrationRandom = (Math.round((Math.random()*6)+1));
var captionRandom = (Math.round((Math.random()*37)+1));
if (captionRandom == 1 || captionRandom == 2 || captionRandom == 3 || captionRandom == 8 || captionRandom == 9 || captionRandom == 14 || captionRandom == 15 || captionRandom == 31 || captionRandom == 32 || captionRandom == 24 )
{
	document.getElementById('Scenario').selectedIndex=1;
} else if (captionRandom == 4 || captionRandom == 5 || captionRandom == 6 || captionRandom == 7 || captionRandom == 30)
{
	document.getElementById('Scenario').selectedIndex=2;
} else if (captionRandom == 10 || captionRandom == 11 || captionRandom == 12 || captionRandom == 19 || captionRandom == 20)
{
	document.getElementById('Scenario').selectedIndex=3;
} else if (captionRandom == 21 || captionRandom == 22 || captionRandom == 23 || captionRandom == 25 || captionRandom == 26 || captionRandom == 27)
{
	document.getElementById('Scenario').selectedIndex=4;
} else if (captionRandom == 13 || captionRandom == 17 || captionRandom == 18 || captionRandom == 33)
{
	document.getElementById('Scenario').selectedIndex=5;
} else {
	document.getElementById('Scenario').selectedIndex=6;
}
document.getElementById('Scenario').disabled = true;
var scenarioValue = 'Scenario_0'+ document.getElementById('Scenario').selectedIndex;
displayCaptionDropDown(scenarioValue);
var myselect = document.getElementById('CaptionSelect');
var captionValue = "caption_"+ captionRandom;
for (var i=0; i<myselect.options.length; i++){
 if (myselect.options[i].value==captionValue){
  myselect.selectedIndex=i;
 } 
}
document.getElementById('CaptionSelect').disabled = true;
document.getElementById('image').value = "http://iameffed.com/global/images/ecards/illustration"+illustrationRandom+"_caption_"+captionRandom+".jpg";
document.getElementById('preview').style.background = "url(/global/images/previews/illustration"+illustrationRandom+"_caption_"+captionRandom+".jpg)";
document.getElementById('getCaption').value=captionValue;
		document.getElementById('Step1_1').className = "visibleDiv";
		document.getElementById('Step1_2').className = "visibleDiv";
		document.getElementById('Step1_3').className = "visibleDiv";
		document.getElementById('ScenarioSelect').className = "visibleDiv";
		document.getElementById('Caption_01').className = "visibleDiv";
		document.getElementById('returnToStep1_1').className = "visibleDiv";
		document.getElementById('returnToStep1_2').className = "visibleDiv";
		document.getElementById('illustrationSelect_01').className = "hiddenDiv";
		document.getElementById('illustrationSelect_02').className = "hiddenDiv";
		document.getElementById('illustrationSelect_03').className = "hiddenDiv";
		document.getElementById('illustrationSelect_04').className = "hiddenDiv";
		document.getElementById('illustrationSelect_05').className = "hiddenDiv";
		document.getElementById('illustrationSelect_06').className = "hiddenDiv";
		document.getElementById('illustrationSelect_07').className = "hiddenDiv";
		document.getElementById('illustrationSelect_08').className = "hiddenDiv";
		document.getElementById('illustrationSelect_0'+illustrationRandom).className = "visibleDiv";
		
}

function randomCardDone() {
if (document.getElementById('randomDone').className == 'hiddenDiv') {
document.getElementById('randomDone').className = 'visibleDiv';
}
}

function goToDeliver_new() {
document.getElementById('Step1_1').className = "hiddenDiv";
		document.getElementById('Step1_2').className = "hiddenDiv";
		document.getElementById('Step1_3').className = "hiddenDiv";
		document.getElementById('ScenarioSelect').className = "hiddenDiv";
		document.getElementById('Caption_01').className = "hiddenDiv";
		document.getElementById('returnToStep1_1').className = "hiddenDiv";
		document.getElementById('returnToStep1_2').className = "hiddenDiv";
		document.getElementById('illustrationSelect_01').className = "hiddenDiv";
		document.getElementById('illustrationSelect_02').className = "hiddenDiv";
		document.getElementById('illustrationSelect_03').className = "hiddenDiv";
		document.getElementById('illustrationSelect_04').className = "hiddenDiv";
		document.getElementById('illustrationSelect_05').className = "hiddenDiv";
		document.getElementById('illustrationSelect_06').className = "hiddenDiv";
		document.getElementById('illustrationSelect_07').className = "hiddenDiv";
		document.getElementById('illustrationSelect_08').className = "hiddenDiv";
		document.getElementById('randomDone').className = "hiddenDiv";
		document.getElementById('randomCard').className = "hiddenDiv";
		document.getElementById('Step2').className = "visibleDiv";
		document.getElementById('deliverForm').className = "visibleDiv";
		document.getElementById('gobackButton').className = "visibleDiv";
		document.getElementById('senditButton').className = "visibleDiv";
}
 
function showAnonWarning()
{
	if(document.efail2010.Anonymous.checked)
	{
		document.getElementById('message').className = "hiddenDiv";
		document.getElementById('anonWarning').className = "visibleDiv";
	}
else
	{
		document.getElementById('message').className = "visibleDiv";
		document.getElementById('anonWarning').className = "hiddenDiv";
	}
} 

