/*
url:flash url
w:width
h:height
st:css's class
wm:wmode
tw:true:write html , false :return string
*/
function fun_flash_output(url,w,h,st,wm,tw){
var out;
var outhtm;
var _ssl = 'http';
if (!location.href.indexOf('https:')){_ssl = 'https';}
if (!st) {st='';}
wm = (!wm)?'transparent':'opaque';
outhtm = "<OBJECT  width='"+w+"' height='"+h+"' class='"+st+"' " + out + " id=crazd classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='" + _ssl + "://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'>\n";
outhtm +="<PARAM NAME=movie VALUE='"+url+"'>\n";
outhtm +="<PARAM NAME=quality VALUE=high>\n";
outhtm +="<PARAM NAME=wmode VALUE='"+wm+"'>\n";
outhtm +="<PARAM NAME=bgcolor VALUE=#FFFFFF>\n";
outhtm +="<EMBED quality=high width="+w+" height="+h+" NAME=crazd src='"+url+"' quality=high wmode='"+wm+"' bgcolor=FFFFFF TYPE='application/x-shockwave-flash' PLUGINSPAGE='" + _ssl + "://www.macromedia.com/go/getflashplayer' />\n";
outhtm +="</OBJECT>\n";
if (!tw){
document.write(outhtm);
}else{
return outhtm;
}
}


function show_ads(adJosnObj ,adTemplate ,adWidth ,adHeight ){

	if (typeof(adJosnObj) != "undefined"){

		var show_ad_content = function (){
			if (adJosnObj.length==0){   // no ads
				return;
			}
			var rnd = -1;  rnd = Math.floor(  Math.random() * adJosnObj.length  );
			if (adJosnObj[rnd].FILETYPE.toLowerCase() == "swf"){
				fun_flash_output(adJosnObj[rnd].IMAGE,adWidth,adHeight);
			}else{
				var adNewContent = adTemplate.replace("$URL$",adJosnObj[rnd].URL)
											 .replace("$IMAGE$",adJosnObj[rnd].IMAGE)
											 .replace("$ALT$",adJosnObj[rnd].ALT)
											 .replace("$ALT$",adJosnObj[rnd].ALT)
											 .replace("$WIDTH$",adWidth)
											 .replace("$HEIGHT$",adHeight)
											 .replace("$URCHIN$",adJosnObj[rnd].ONCLICK);
				document.write(adNewContent);
			}
		}
		show_ad_content();
	}

}
