function loaded(){
		
	if($('iframe_iFrame') && $('iframe_iFrame').src !=window.location && $('iframe_iFrame').src != ""){
		if($('loading') && ! $('loading').hasClassName("dn")){
			new Effect.Fade('loading',{ duration:1.0, from:0.75, to:0.0  });
			$('loading').addClassName("dn");
		
			if(getCookie("loaded")){
				var url = "/media/x/menu.xml";
				var opt = {
					method: "get",
					onSuccess: function(transport) {
						var source=$('iframe_iFrame').src;
						var links = transport.responseXML.getElementsByTagName("link");
						for(var i=0; i< links.length;i++){
							if(links[i].getAttribute("pageName") && source.endsWith(links[i].getAttribute("href")) ){
								var pageName = links[i].getAttribute("pageName");
								trackPage(pageName);
							}	
						}
					}
				};
				new Ajax.Request(url, opt);
			}else{
				setCookie("loaded","yes",10000);
			}
		}
	}
  }
 
function showLoading(label,src){
	clearIframe();
	if($('loading')){
		$('loading').removeClassName("dn");
		new Effect.Appear('loading',{ duration:0.1, from:0.0, to:0.75 });
	}
	if($('loading-label') && label){
		$('loading-label').firstChild.nodeValue = "Loading: "+label;
	}
//	console.info($('iframe_iFrame'));
	if($('iframe_iFrame') && src){
		setTimeout("$('iframe_iFrame').src='"+src+"'",500);
	}
  }
 
function clearIframe(){
	
	if($('iframe_iFrame') ){
		$('iframe_iFrame').src="";
	}
  }
  
  
function hideScroll(){
	if($('iframe_iFrame') &&  navigator.userAgent.indexOf('Firefox') > -1){
		$('iframe_iFrame').scrolling="no";
	}
	if($('iFrame') && !Prototype.Browser.IE){
		$('iFrame').style.left="auto";
	}
}

function showScroll(){
	if($('iframe_iFrame') && navigator.userAgent.indexOf('Firefox') > -1){
		$('iframe_iFrame').scrolling="auto";
	}
	
	if($('iFrame') && !Prototype.Browser.IE){
		$('iFrame').style.left="159px";
	}
}


if(!Prototype.Browser.IE){
	document.loadIFrame="";
	}

loadIFrame = function (frameID, iframeID, url,label)
{
  if(document.getElementById(iframeID)){
  		$(iframeID).parentNode.removeChild($(iframeID));
	}else{
     document.getElementById(frameID).innerHTML = "<div id='loading'><div><img src='/images/loading.gif' /><p id='loading-label'>Loading ...</p></div></div><div id='shadow-bg'>&#xA0;</div>";
    }
    if($('loading-label')){
		$('loading-label').firstChild.nodeValue="Loading: "+label;
	}
    var newIframe=document.createElement("iframe");
	newIframe.id=iframeID;
	newIframe.frameborder=0;
	$(frameID).appendChild(newIframe);
	newIframe.src=url;
	newIframe.onload=function(){loaded()};
}


var swfObj = new Array();

var version='9.0.0.0';
var expressInstall='/media/swf/expressinstall.swf';
var flashsrc="/media/assets/chevy/chevyBanners_Camaro/";
swfObj["dueling-top"] = {
	movie:flashsrc + "dueling/728x90_R_2010_CHV_CC_INM_GM_LAUNCH_DUEL.swf",
	width:"728",
	height:"90",
	params: {
		quality: 'high',
		pluginspage: 'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',
		scale: 'exactfit',
		hspace:'18',
		vspace:'0' 
	},
	flashvars : {
		clickTag:'/olm/',
		filePath:flashsrc+"dueling/"
	}
	
};


swfObj["dueling-right"] = {

	movie:flashsrc + "dueling/160x600_R_2010_CHV_CC_INM_GM_LAUNCH_DUEL.swf",
	width:"160",
	height:"600",
	 params: {
		quality: 'high',
		pluginspage: 'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',
		hspace:'660',
		vspace:'38'
	},
	flashvars : {
		clickTag:'/olm/',
		filePath:flashsrc+"dueling/"
	}
};


swfObj["implosion"] = {

	movie:flashsrc + "implosion/300x250R_2010_CHV_CC_INM_GM_LAUNCH_IMPL.swf",
	width:"460",
	height:"270",
	 params: {
		quality: 'high',
		pluginspage: 'http://www.macromedia.com/go/getflashplayer',
		align: 'middle',
		play: true,
		loop: true,
		bgcolor: '#d9dcd1',
		scale: 'showall',
		wmode: 'window',
		name:'00x250R_2010_CHV_CC_INM_GM_LAUNCH_IMPL',
		devicefont: false,
		menu: true,
		allowFullScreen:false,
		allowScriptAccess:'sameDomain',
		salign:'',
		filePath:flashsrc+"implosion/"
	},
	flashvars : {
		clickTag:'/olm/',
		filePath:flashsrc+"implosion/"
	}
	
};


/*
function initOLM(){

	$$('.flash').each(function(item){
		var swfObjName = item.id;
		if(swfObj[swfObjName]){
			swfobject.embedSWF(swfObj[swfObjName].movie, item.id, swfObj[swfObjName].width, swfObj[swfObjName].height, version, expressInstall, swfObj[swfObjName].flashvars, swfObj[swfObjName].params,swfObj[swfObjName].attributes);
		}
	})
	
}*/

function initOLM(){
	$$('a').each(function(item){
		if(item.name && item.name!=""){
			
			Event.observe(item, 'click', function(event) {
                trackLink(item);
            });
		}
	})
	
}

var params = {
	wmode: "opaque",
	quality: "high",
	allowFullScreen: "true",
	menu: "true",
	play: "true",
	loop: "true",
	menu: "false",
	bgcolor: "#383838",
	scale: "showall",
	devicefont: "false",
	allowScriptAccess: "sameDomain"
	
};
var flashvars = {
	
};
var attributes = {
	align: "left",
  	width: "100%",
	height: "100%",
	salign: "lt"
};

document.observe("dom:loaded", function() {
	if($('flash-container')){
	/*	var loaded = getCookie("loaded");
		
		if(!loaded){
			loaded="no"
		}
		var flashvars = {
				loaded :loaded
			};*/
		var swf = "CampbellEwald"+$('flash-container').className.toUpperCase()+".swf";
		swfobject.embedSWF('/media/swf/'+swf,'flash-container','100%','100%', version, expressInstall, flashvars, params, attributes);
		document.body.className="flash";
	}
	if(top != self && $('logo')){
	
		$('logo').addClassName("dn");
	} 
	initOLM();
//	initTrackLinks();
});	

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

// Retrieve the value of a cookie that matches a given name 
function getCookie(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;
}