// JavaScript Document

var no_flash_img;
var checker = false;

function imageRollOver(imgID,newSrc){
   var image = document.getElementById(imgID);
   var oldSrc = image.setAttribute('title',image.src);
   image.src = newSrc;
}
function imageRollOut(imgID){
   var image = document.getElementById(imgID);
   var oldSrc = image.getAttribute('title');
   image.src = oldSrc;
   image.removeAttribute('title');
}
function loadMenu(){
}
function ToggleIt(currentID,divID) {
	var d1 = document.getElementById(currentID);
	var d2 = document.getElementById(divID);
		d1.className='chef_list_hidden';
		d2.className='chef_list_visible';
	var r1 = document.getElementById(currentID);
	var r2 = document.getElementById(divID);
		r1.className='chef_list_hidden';
		r2.className='chef_list_visible';
}
function setVideo(currentChef){
	//alert("chef number "+currentChef);
	var chef_list = new Array('&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName=swf/april_bloomfield&autoPlay=true&autoRewind=false',
						 '&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName=swf/gabriel_bremer&autoPlay=true&autoRewind=false',
						 '&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName=swf/matt_dillon&autoPlay=true&autoRewind=false',
						 '&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName=swf/gavin_kaysen&autoPlay=true&autoRewind=false',
						 '&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName=swf/johnny_monis&autoPlay=true&autoRewind=false',
						 '&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName=swf/sean_obrien&autoPlay=true&autoRewind=false',
						 '&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName=swf/gabe_rucker&autoPlay=true&autoRewind=false',
						 '&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName=swf/ian_schnoebelen&autoPlay=true&autoRewind=false',
						 '&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName=swf/paul_virant&autoPlay=true&autoRewind=false',
						 '&MM_ComponentVersion=1&skinName=Clear_Skin_2&streamName=swf/steve_corry&autoPlay=true&autoRewind=false'
						 );
  var FO = { 
	    //movie:        'swf/ChryslerCuisine.swf',
	    movie:        'FLVPlayer_Progressive.swf',
		width:        '480',
	    height:       '328',
	    name:	  "FLVPlayer_Progressive",
	    id:		  "FLVPlayer_Progressive",
	    allowscriptaccess:"sameDomain",
	    scale:        "noscale",
	    wmode:        "opaque",
	    play:         "true",
	    quality:      "high",
	    menu:         "false",
	    majorversion: '7', 
	    build:        "0", 
	    xi:           "false",
	    flashvars:    chef_list[currentChef-1]
	}; 
  
	var hasflash;
    
	if (checker == false) {
		if (UFO.hasFlashVersion(8, '14')) {
			hasflash = false;
			no_flash_img.style.visibility = "visible";
		} else {
			hasflash = true;
		}
	}
	
	if(hasflash || checker == true) {
		UFO.create(FO, 'flash_chef');
		
		//change first-time chekcer var to true
		checker = true;
	}
   
}



function intPage(){ 
  //grabing no flash image to toggle visiblity style on hasflash (below)
  var flash_chef = document.getElementById('flash_chef');
  no_flash_img = flash_chef.getElementsByTagName('img')[0];
  
  //cue chef movie
  checkChef();
  }
  
  
  
function viewChef(currentChef){
	for (x=1; x<=10; x++){
	//alert("hide chef # "+x);
		var d2 = document.getElementById("c"+x);
		var r2 = document.getElementById("r"+x);
		d2.className='chef_bio_off';
		r2.className='chef_recipe_off';		
	}
	var d1 = document.getElementById("c"+currentChef);
	var r1 = document.getElementById("r"+currentChef);
	//alert("Display chef # "+currentChef);
		d1.className='div. ';
		r1.className='div. ';
		setVideo(currentChef);
	}

function checkChef() {
	//alert(getParameter('chef'));
	if(getParameter('chef')){
		queryStringChef = getParameter('chef');
	}else{
		queryStringChef = 1;
	}
	viewChef(queryStringChef);
		//alert(queryStringChef);
}

function viewRecipe(currentRecipe){
	for (x=1; x<=1; x++){
	//alert("hide recipe # "+x);
		var d2 = document.getElementById(x);

		d2.className='div.full_recipe_off';		
	}
	var d1 = document.getElementById(currentRecipe);
		d1.className='div.full_recipe_on';
	//alert("Display recipe # "+currentRecipe);
	}
	

function checkRecipe() {
	if(getParameter('recipe')){
		queryStringRecipe = getParameter('recipe');
	}else{
		queryStringRecipe = 1;
	}
	viewRecipe(queryStringRecipe);
		//alert(queryStringRecipe);
}
 
function submitSignUp(id){
    var email = document.getElementById(id).value;
    regEx1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
    regEx2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
    if( ( email.length > 0 ) && ( !( !regEx1.test( email ) && regEx2.test( email ) ) ) ) {
      alert("Please enter a valid email address");
    } else{
      //valid Email address 
	 //var pid="Welcome to Chrysler Cuisine";
      var params = "";
      params += "A40$2$email="+email;
      params += "&A05$2$creative_id=";
      if(rid)params += rid; 
      params += "&A04$2$banner_id=";
      if(adid)params += adid;
      params += "&A03$2$site_id=";
      if(pid)params += pid;
      params += "&A15$2$address=";
      params += "&A08$2$name=";
      params += "&A07$1$customer=";
      params += "&A06$2$subchannel_id=www.chrysler.com/food";
      params += "&A02$2$program_id=CCCGR7";
      params += "&A01$1$marketing_info=";
      params += "&confirm_pg=/formbase/complete.jsp";
      params += "&form_type=hierarchy";
      params += "&success_pg=/flash/forms/thankyou.html";
      params += "&error_pg=/flash/forms/error.html";
      params += "&form_id=8";
      //alert(params);
      makeRequest('/formbase/FbFormInput', params, 'signUpResult(http_request[i].responseXML, http_request[i].responseText)');
    }
    
  }
 function signUpResult(xmlObj, xmlText){


	var was_success = xmlText.split("true");


    if (was_success[1]) {
	  
		var elementNode = document.getElementById("sign-up-form");
		elementNode.innerHTML = "Thanks for Registering";
    } else {
	   
	    var elementNode = document.getElementById("sign-up-form");
		elementNode.innerHTML = "Please try again later";
    };
    
  }