// <![CDATA[

/******************************************************************************
 This is the flash detection script.
 ******************************************************************************/
var required = 6;
var hasFlash = false;
if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Windows") != -1){
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	// AFAIK creating an instance of an older version of the Flash object 
	// will return succeed even if the actual installed version is newer.
	document.write('hasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & required))) \n');  
	document.write('<'+'/scr' + 'ipt\> \n');
	}
else {
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])?navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin:0;
	if (plugin) {
		var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
		var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		hasFlash = flashVersion >= required;
		}
	}


/******************************************************************************
 This classes the <html> element as `hasFlash` if flash is found. This style
 hook can be used to hide our to-be-replaced content before it even comes down
 the datapipe and eliminate the FOPSC ("Flash of Partially Styled Content")
 
 I've determined that the lighter the page weight the greater chance of a FOPSC.
 ******************************************************************************/
if (hasFlash && document.getElementsByTagName && document.getElementsByTagName('html')[0]) {
	document.getElementsByTagName('html')[0].className += (document.getElementsByTagName('html')[0].className=='')?'hasFlash':' hasFlash';
	}
	
	
/******************************************************************************
 Some utility functions. Look at them--aren't they useful?
 ******************************************************************************/
 
function SI_normalizeWhiteSpace(txt) {
	var rE = /\s+/gi;
	return txt.replace(rE,' ');
	}
function SI_forceRedraw() {
	// Corrects a margin-bottom sum bug in Mozilla
	var d = document;
	if (d.body && d.body.style) {
		d.body.style.height = "1px";
		d.body.style.height = "auto";
		}
	}
	

/******************************************************************************
 This is the function that finds and replaces the appropriate elements.
 
 
 SI_replaceElement(elem,swf,w,h,afv)
 
	elem (string) :
		`div#header` will replace the `div` with the id of header
		`div#content>h1` will replace any `h1` tag whose direct parent is a `div` with an id of `content`
		`h2.replaceme` will replace any `h2` tag with a className of `replaceme`
	swf (string) :
		full path to the swf
	w (int) :
		width
	h (int) :
		height
	afv (string) :
		used to pass additional flashVars to the movie
	 
 The new replaced element will be placed in a div 
 with a className of `'replaced-'+r.e.tagName`
 ******************************************************************************/
function SI_replaceElement(elem,swf,w,h,afv) {
	var d = document;
	
	if (!hasFlash || !d.getElementsByTagName) return;
	
	var r = new Object();
	r.p = new Object();
	r.e = new Object();
	
	if (elem.indexOf('>')!=-1) {
		// alert('Reference to parent found...');
		elemArray = elem.split('>');
		elem = elemArray[1];
		if (elemArray[0].indexOf('#')!=-1) {
			// alert('Reference to parent's id found...');
			parentArray = elemArray[0].split('#');
			r.p.id 		  = parentArray[1];
			r.p.tagName	  = parentArray[0];
			r.p.className = false;
			}
		else if (elemArray[0].indexOf('.')!=-1) {
			// alert('Reference to parent's className found...');
			parentArray = elemArray[0].split('.');
			r.p.id 		  = false;
			r.p.tagName	  = parentArray[0];
			r.p.className = parentArray[1];
			}
		else {
			r.p.id		  = false;
			r.p.tagName	  = elemArray[0];
			r.p.className = false;
			}
		}
	else {
		// alert('No reference to parent found...');
		r.p.id		  = false;
		r.p.tagName	  = false;
		r.p.className = false;
		}
	
	if (elem.indexOf('#')!=-1) {
		// alert('Reference to element's id found...');
		elemArray = elem.split('#');
		r.e.id 		  = elemArray[1];
		r.e.tagName	  = elemArray[0];
		r.e.className = false;
		}
	else if (elem.indexOf('.')!=-1) {
		// alert('Reference to element's className found...');
		elemArray = elem.split('.');
		r.e.id 		  = false;
		r.e.tagName	  = elemArray[0];
		r.e.className = elemArray[1];
		}
	else {
		r.e.id		  = false;
		r.e.tagName	  = elem;
		r.e.className = false;
		}
	
	if (afv!='') {
		afv = SI_normalizeWhiteSpace(afv);
		afv = '&'+afv;
		}
	
	var elems = d.getElementsByTagName(r.e.tagName);
	var count = elems.length;
	for (var i=0; i<count; i++) {
		e = elems[i];
		
		if (!r.p.tagName || (((r.p.tagName && !r.p.id && !r.p.className && e.parentNode.nodeName==r.p.tagName.toUpperCase()) || ((r.p.id && e.parentNode.id==r.p.id) || (r.p.className && e.parentNode.className==r.p.className))))) {
			if ((r.e.tagName && !r.e.id && !r.e.className) || (r.e.id && e.id==r.e.id) || (r.e.className && e.className==r.e.className)) {
				
				// alert('Make replacement');
				var txt;
				txt = SI_normalizeWhiteSpace(e.innerHTML);
				var c = d.createElement('div');
				c.className = 'replaced-'+r.e.tagName;
				e.parentNode.replaceChild(c,e);
				// The replaceChild acts like shift() on the
				// array that holds all of our elems. Meaning it
				// removes the first index and the remaining indexes
				// move up one.
				// The length or our elems array decreases by one
				count--;
				// Override the increment on loop index too.
				// We could just use e = elems[0]; above if we knew that
				// every instance of this particular element was going 
				// to be replaced--but there's no way of knowing that's
				// how it will play out.
				i--;
				
				txt = txt.replace(/&amp;/g, '%26');
				txt = txt.replace(/"/g, '%22');
				fv = 'txt='+txt+afv;
				
				var swfHTML;
				swfHTML  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+w+'" height="'+h+'">';
				swfHTML += '	<param name="movie" value="'+swf+'" />';
				swfHTML += '	<param name="flashvars" value="'+fv+'" />';
				swfHTML += '	<embed src="'+swf+'" flashvars="'+fv+'" width="'+w+'" height="'+h+'TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />';
				swfHTML += '<'+'/object>';
				c.innerHTML = swfHTML;
				txt='';
				}
			}
		
		}
	}
	
/******************************************************************************
 This is where the magic happens. This should really be the only part of this
 script you need to modify. Just add the necessary SI_replaceElement() calls 
 and make sure this sucker is called onload.
 ******************************************************************************/
function SI_flashReplacement() {
	//
	//
	/////////////////////html code replamenet (depends on class vs id),call swf,textField Width, textField Height, call style with text parameters)
	// H1 AND H2 FORMATTING
	//COMMENTED OUT for SPANISH //SI_replaceElement('div#content>h1','swf/din.swf',250,24,'style=big_red&textwidth=250');
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div#content>h2','swf/akz.swf',540,24,'style=big_grey&textwidth=540');
	//
	//General Feature
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.featureHead>h1','swf/din.swf',600,24,'style=big_red&textwidth=600');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.featureHead>h2','swf/akz.swf',540,24,'style=med_grey&textwidth=540');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.featureHead>h2','swf/akz.swf',540,24,'style=med_grey&textwidth=540');
	//
	//Top level pages
	////Three column
	
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.three_spanTwoLeft>h1','swf/din.swf',390,24,'style=big_red&textwidth=390');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.three_spanTwoLeft>h2','swf/akz.swf',390,18,'style=med_grey&textwidth=390');
	
	//SI_replaceElement('div.grayHeaderThree>h2','swf/din_gray.swf',180,10,'style=small_grey&textwidth=180');
	//SI_replaceElement('div.grayHeaderThird>h2','swf/din_gray.swf',180,10,'style=small_grey&textwidth=180');
	//SI_replaceElement('div.whiteHeaderThree>h2','swf/din.swf',150,10,'style=small_grey&textwidth=190');
	////Four Column
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.four_spanTwoLeft>h1','swf/din.swf',280,24,'style=big_red&textwidth=390');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.four_spanTwoLeft>h2','swf/akz.swf',280,18,'style=med_grey&textwidth=390');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.four_spanThreeLeft>h1.english','swf/din.swf',280,24,'style=big_red&textwidth=390');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.four_spanThreeLeft>h2','swf/akz.swf',400,18,'style=med_grey&textwidth=400');
	//SI_replaceElement('div.grayLinks4_2>h2','swf/din_lt_gray.swf',180,10,'style=small_grey&textwidth=180');
	//SI_replaceElement('div.grayHeader4_2>h2','swf/din_gray.swf',180,10,'style=small_grey&textwidth=180');
	//SI_replaceElement('div.whiteHeaderFour>h2','swf/din.swf',140,10,'style=small_grey&textwidth=140');
	//SI_replaceElement('div.whiteHeaderFive>h2','swf/din.swf',100,10,'style=small_grey&textwidth=100');
	//
	//Homepage IFR Calls
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.home_spanLeft>h1','swf/din.swf',200,54,'style=big_red&textwidth=200');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.home_spanLeft>h2','swf/akz.swf',200,18,'style=med_grey&textwidth=200');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.home_spanRight>h2','swf/din.swf',200,18,'style=med_red&textwidth=200');
	/*SI_replaceElement('td.homeFive_first>h2','swf/din_lt_gray.swf',100,10,'style=small_grey&textwidth=100');
	SI_replaceElement('td.homeFive_second>h2','swf/din_lt_gray.swf',100,10,'style=small_grey&textwidth=100');
	SI_replaceElement('td.homeFive_third>h2','swf/din_lt_gray.swf',100,10,'style=small_grey&textwidth=100');
	SI_replaceElement('td.homeFive_fourth>h2','swf/din_lt_gray.swf',100,10,'style=small_grey&textwidth=100');
	SI_replaceElement('td.homeFive_fifth>h2','swf/din_lt_gray.swf',100,10,'style=small_grey&textwidth=100');*/
	//COMMENTED OUT for SPANISH //SI_replaceElement('td.gs_one>h4','swf/akz.swf',80,10,'style=xsmall_grey&textwidth=80');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.homeSpacer>h3','swf/din_red.swf',400,14,'style=med_white&textwidth=400');
	
	//
	//Checkout and shopping
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.ecomHead>h1','swf/din.swf',400,24,'style=big_red&textwidth=400');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.cartHead>h1','swf/din.swf',400,24,'style=big_red&textwidth=400');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.checkout_Head>h1','swf/din.swf',400,24,'style=big_red&textwidth=400');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.receipt_Head>h1','swf/din.swf',400,24,'style=big_red&textwidth=400');
	//
	//Grillfinder IMG replacement
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.gFinderHead>h1','swf/din.swf',400,24,'style=big_red&textwidth=400');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.findCalls>h2','swf/akz.swf',540,18,'style=med_grey&textwidth=540');
	//
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.helpHead>h1','swf/din.swf',280,42,'style=med_red&textwidth=280');
	//SI_replaceElement('div.helpColumn>h2','swf/akz.swf',120,16,'style=small_grey&textwidth=120');
	//SI_replaceElement('div.helpColumn2>h2','swf/akz.swf',120,16,'style=small_grey&textwidth=120');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.doubleHelp>h2','swf/akz.swf',120,16,'style=small_grey&textwidth=120');
	//
	////////////PART DISPLAY FORMATTING
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.partHead>h1','swf/din.swf',400,24,'style=big_red&textwidth=400');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.onethirdcolumn>h2','swf/akz.swf',180,48,'style=med_grey&textwidth=180');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.onethirdcolumn>h3','swf/akz.swf',180,24,'style=med_grey&textwidth=180');
	///////////
	//
	// TOP FORMATTING
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.top_half_grey>h3.akz_grey','swf/akz.swf',230,130,'style=med_grey&textwidth=230');
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.top_twothirds_grey>h3.akz_grey','swf/akz.swf',340,130,'style=med_grey&textwidth=340');
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.top_quarter_grey>h4.akz_grey','swf/akz.swf',125,130,'style=med_grey&textwidth=125');
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.top_twothirds_grey>h4.akz_grey','swf/akz.swf',340,130,'style=med_grey&textwidth=340');
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.top_onethird>h5.din_grey','swf/din.swf',160,20,'style=small_grey&textwidth=160');
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.top_quarter_grey>h5.din_grey','swf/din.swf',125,20,'style=small_grey&textwidth=125');
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.top_quarter_grey>h5.akz_grey','swf/akz.swf',125,130,'style=small_grey&textwidth=125');
	//
	//
	// CONTENT FORMATTING
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.fullcolumn>h2.akz_grey','swf/akz.swf',540,24,'style=big_grey&textwidth=540');
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.onethirdcolumn>h5.din_red','swf/din.swf',180,9,'style=small_red&textwidth=180');
	// 
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.onethirdcolumn>h5.din_grey','swf/din.swf',180,9,'style=small_grey&textwidth=180');
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.quartercolumn>h5.din_grey','swf/din.swf',130,9,'style=small_grey&textwidth=130');
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.quartercolumn>h5.din_red','swf/din.swf',130,9,'style=small_red&textwidth=130');
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.twothirdscolumn>h2.akz_grey','swf/akz.swf',350,48,'style=big_grey&textwidth=350');
	//
	//
	// ECOMMERCE FORMATTING
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.productdescript>h4.akz_grey','swf/akz.swf',250,15,'style=small_black&textwidth=250');
	//
	//GRILL SECTION
	//
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.summHeaders>h1.english','swf/din.swf',302,24,'style=big_grey&textwidth=302');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.summBIHeaders>h1.english','swf/din.swf',310,24,'style=big_grey&textwidth=310');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.productHeaders>h1.english','swf/din.swf',300,24,'style=big_red&textwidth=300');
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.gg_SumLeft>h1.english','swf/din.swf',302,24,'style=big_grey&textwidth=302');
	//scott's tag:
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.gg_SumLeftGrey>h1.english','swf/din_lt_gray.swf',302,24,'style=big_grey&textwidth=302');
	//scott's tag:
	//COMMENTED OUT for SPANISH //SI_replaceElement('div.fullWhiteHead>h1.english','swf/din.swf',594,24,'style=big_grey&textwidth=594');
	//
	//
	//
	SI_forceRedraw();
	}
/******************************************************************************
 This sets the entire thing in motion. Place any other scripts that need to run
 onload in the SI_onload() function or add SI_flashReplacement to your own 
 onload handler.
 ******************************************************************************/
function SI_onload() {
	SI_flashReplacement();
	} window.onload = SI_onload;

// ]]>