var MM_contentVersion = 4;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i]; 
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}

function getFlash(width, height, file, loop, alternate, classid, secure)
{
	var code_base;
	if (secure == 'true') {
		code_base = 'https';
	}
	else {
		code_base = 'http';
	}
	if (MM_FlashCanPlay)
	{
		var oeTags = '<OBJECT CLASSID="' + classid + '"'
         + 'WIDTH="' + width + '" HEIGHT="' + height + '"'
         + 'CODEBASE="' + code_base + '://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
         + '<PARAM NAME="MOVIE" VALUE="' + file + '">'
         + '<PARAM NAME="PLAY" VALUE="true">'
         + '<PARAM NAME="LOOP" VALUE="' + loop + '">'
         + '<PARAM NAME="QUALITY" VALUE="high">'
         + '<PARAM NAME="MENU" VALUE="false">'
         + '<EMBED SRC="' + file + '"'
         + 'WIDTH="' + width + '" HEIGHT="' + height + '"'
         + 'PLAY="true"'
         + 'LOOP="' + loop + '"'
         + 'QUALITY="high"'
         + 'MENU="false"'
         + 'TYPE="application/x-shockwave-flash"'
         + 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
         + '</EMBED>'
         + '</OBJECT>';
		document.write(oeTags);
	}
	else
	{
		var alternateContent = '<IMG SRC="' + alternate + '" HEIGHT="' + height + '" WIDTH="' + width + '" BORDER="0">'
		document.write(alternateContent);
	}
}


function switchMenu(targetId) {
  if(document.getElementById) {
    target = document.getElementById('menu0');
    target.style.display = "none";
    target = document.getElementById('menu2');
    target.style.display = "none";
    target = document.getElementById('menu3');
    target.style.display = "none";
    target = document.getElementById(targetId);
    target.style.display = "inline";
  }
}

function switchImage(image_id, num_images) {
	if (document.getElementById) {
		for (i=1; i <= num_images; i++) {
			var image = 'image' + i;
			document.getElementById(image).style.display = "none";
		}
		document.getElementById(image_id).style.display = "inline";
	}
}

var imagepopup;
var otherpopup;
function popupView(url, features, popup_type) {
	switch (popup_type) {
		case 'image':
		if (!imagepopup || imagepopup.closed) {
	  		imagepopup = window.open(url,'imagepopup',features);
		}
		else {
			imagepopup.close();
		    imagepopup = window.open(url, 'imagepopup', features);
		}
		break;
		
		case 'other':
		if (!otherpopup || otherpopup.closed) {
	  		otherpopup = window.open(url,'otherpopup',features);
		}
		else {
			otherpopup.close();
		    otherpopup = window.open(url, 'otherpopup', features);
		}
		break;
		
		default:
		return false;
		break;
	}	
}

function loadLink(method, region, cat, resource, city) {
	var r;
    r = '/location/' + method + '/' + region + '/' + cat + '/';
	if (resource) {
		r = r + resource + '/';
	}
	if (city) {
		r = r + '?city=' + city;
	}
    document.location.href = r;
}

function loadGlobalResourceLink(resource_name, cat) {
	var r;
	r = '/' + resource_name + '/' + cat + '/';
	document.location.href = r;
}

function logClick(evnt, campaign_id) {
    var left = true;
    if ((evnt) && evnt.which) {
        if (evnt.which != 1) {
            left = false;
        }
    }
    else if (event && event.button) {
        if (event.button != 1) {
            left = false;
        }
    }
    if (left) {
		var img = new Image();
		img.src = "/ad/log/" + campaign_id + "/";
    }   
}

function logListingClick(evnt, lid, type, tid1, tid2) {
	var left = true;
    if ((evnt) && evnt.which) {
        if (evnt.which != 1) {
            left = false;
        }
    }
    else if (event && event.button) {
        if (event.button != 1) {
            left = false;
        }
    }
    if (left) {
		var img = new Image();
		img.src = "/listing/log_stat/" + lid + "?type=" + type + "&tid1=" + tid1 + "&tid2=" + tid2;
    }   
}

function swapIdDisplay(show_me, hide_me, type) {
	if (document.getElementById) {
		if (type != 'inline') {
			type = "";
		}
	    target = document.getElementById(show_me);
	    target.style.display = type;
	    target = document.getElementById(hide_me);
	    target.style.display = "none";
	  }
}