function writeFlash(url,w,h,id,bg,trans) {
var html = "";
html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="' + w + '" height="' + h + '" id="'+ id + '">\n';
html += '<param name="movie" value="' + url + '" />\n';
html += '<param name="quality" value="high" />\n';
html += '<param name="bgcolor" value="' + bg + '" />\n';
html += '<param name="scale" value="noscale" />\n';
if (trans == 1) {html += '<param name="wmode" value="transparent" />\n';}
html += '<!--[if !IE]> <-->\n';
html += '<object data="' + url + '" width="' + w + '" height="' + h + '" type="application/x-shockwave-flash" name="'+ id + '">\n';
html += '<param name="quality" value="high" />\n';
html += '<param name="scale" value="noscale" />\n';
html += '<param name="bgcolor" value="' + bg + '" />\n';
html += '<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer" />\n';
if (trans == 1) {html += '<param name="wmode" value="transparent" />\n';}
html += ' FAIL (the browser should render some flash content, not this).\n';
html += ' </object>\n';
html += '<!--> <![endif]-->\n';
html += '</object>\n';
document.write(html);
}

function visit(newURL) {
  var site = window.open(newURL, 'website','scrollbars=1, resizable=1, location=1, menubar=1, status=1, toolbar=1, height=768, width=1024');
  site.window.focus();
}

function popup(newURL) {
  var popuper = window.open(newURL, 'popup','scrollbars=0, resizeable=0, width=425, height=550');
  popuper.window.focus();
}
function rand(min,max){
	var $min = min;
	var $max = max + 1;
	random_num = Math.floor($min + ($max-$min)*Math.random());
	return random_num;
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function verticalPos(){
	var height = $(window).height();
	if ( height <= 652 ){
		$("#outerWrapper").css({
			top: "10px",
			marginTop: "0px"
		});
	}
	else{
		$("#outerWrapper").css({
			top: "50%",
			marginTop: "-340px"
		});
	}
}

$(document).ready(function(){
	//external link setup
	$("a[href^='http://']").each(function(){
		$(this).attr({
			href: "javascript:visit('" + $(this).attr('href') + "')"
		});
	});
	//mainmenu current
	var loc = location.pathname;
	var x = loc.lastIndexOf("/")+1;
	loc = loc.substring(0,x);

	$("#mainmenu a[href='"+loc+"']").addClass("current");
	//mainmenu rollovers setup
	$("#mainmenu a:not(.current)").hover(
		function () {
			var h = "0px -" + $(this).css("height");
			$(this).css("background-position",h);
			$("#mainmenu a.current").css("background-position","0px 0px");
		},
		function () {
			$(this).css("background-position","0px 0px");
			var h = "0px -" + $(this).css("height");
			$("#mainmenu a.current").css("background-position",h);
		}
	);
	loc = location.pathname;
	//submenu current 
	$("#submenu a[href='"+loc+"']").addClass("current").parent().append("<div class='sub_marker'></div>");
	//submenu rollovers setup
	$("#submenu a:not(.current)").hover(
		function () {
			$(this).parent().append("<div class='sub_marker'></div>");
			$("#submenu .current").parent().contents(".sub_marker").css("display","none");
		},
		function () {
			$(this).parent().contents().remove(".sub_marker");
			$("#submenu .current").parent().contents(".sub_marker").css("display","block");
		}
	);
	//image rollovers setup
	$(".imgRollover").hover(
		function () {
			var h = "-" + $(this).css("height");
			$(this).children("img").css("top",h);
		},
		function () {
			$(this).children("img").css("top","0px");
		}
	);
	//mailto setup
	$(".mailto").each(function(){
		var name = $(this).attr("title");
		var html = "<a href='mailto:" + name + "@98thavenue.com'>" + name + "@98thavenue.com</a>";
		$(this).html(html);
	});
	//vertical positioning
	verticalPos();
	//png fix
	$(".png").pngfix();

});
$(window).load(function(){
	//scrollbox setup
	$("#contentScroll").css("width","657px");
	$(".jScrollbox").jScrollPane({
		arrowSize: 12,
		showArrows: true
	});
})
$(window).resize(function(){
	verticalPos();
})
