//-----------------
// Image rollover and swap
// must put var imageRoot="image/location/";
// & var selection='first_1';
// in document
//-----------------

var lat_location;
var lat_location2;
var lat_ab;
var swap;
var i=1;
var over=0;
function flash_in() {
var intro_flash =document.getElementById('flash');
if (flash >= 5) {
	intro_flash.innerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="348" height="167"><param name="movie" value="img/flash/celebrate.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="img/flash/celebrate.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="348" height="167" wmode="transparent"></embed></object>';
	}
}


function rollSwap(location, location2, ab) {
	var imageRoot="img/"+location+"/";
	var root = location + location2;
	var lat_imageRoot="img/"+lat_location+"/";
	var lat_root = lat_location + lat_location2;
	var lat_style = document.getElementById('a'+lat_location2);
	var cur_style = document.getElementById('a'+location2);
	var flashSwap = document.getElementById('c_mf');
	
	document.images[root + '_bar'].src=imageRoot + location + '_bar_' + ab + '.gif';
	document.images[root].src=imageRoot + location + location2 + '_' + ab + '.gif';
	if (flash >= 5) {
	flashSwap.innerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="186" height="124"><param name="movie" value="img/mf/animation/mf1.swf?myImage=img/mf/mf' + location2 + '.jpg" /><param name="quality" value="high" /><embed src="img/mf/animation/mf1.swf?myImage=img/mf/mf' + location2 + '.jpg" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="186" height="124"></embed></object>';
	}
	else
	 flashSwap.innerHTML='<img src="img/mf/'+location+location2+'.jpg" />';
	if (lat_location2 != location2){
	document.images[lat_root + '_bar'].src=lat_imageRoot + lat_location + '_bar_' + 'a' + '.gif';
	document.images[lat_root].src=lat_imageRoot + lat_location + lat_location2 + '_' + 'a' + '.gif';
	lat_style.setAttribute("className", "marketLink");
	cur_style.setAttribute("className", "marketLink2");
	lat_style.setAttribute("class", "marketLink");
	cur_style.setAttribute("class", "marketLink2");


	lat_location=location;
	lat_location2=location2;
	}
}

function swapIt() {
	if (over==0) {
	rollSwap('mf', swap[i], 'b');
	i++;
	if (i>5) i=0;
	}
	else if (over >5) i=0; else i=over;
}

function autoSwap(l1,l2,l3,l4,l5,l6) {
swap = new Array(l1, l2, l3, l4, l5, l6);
over=0;
setTimeout("setInterval('swapIt()', 3000)",15000);

}

function clearSwap() {
	clearInterval();
	over=0;
}

function swapElements(tLocation,selectionNew)
{
	document.images[selection].src=imageRoot + selection + '_b.gif';
	document.images[selection].src=imageRoot + selection + '_a.gif';
	selection=selectionNew;
	document.images.imgPhoto.src="img/site/spacer.gif";
	document.images.imgPhoto.src=tLocation;

}

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its
    if(document.getElementById && document.getElementById(objectId)) {
        // W3C DOM
        return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
        // MSIE 4 DOM
        return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
        // NN 4 DOM.. note: this won't find nested layers
        return document.layers[objectId];
    } else {
        return false;
    }
}

function MM_preloadImages() {
  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];}}
}
