function write_flash(mv,w,h) {
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+w+"' height='"+h+"'>");
	document.write("<param name='movie' value='"+mv+"'>");
	document.write("<param name='quality' value='high'>");
	document.write("<embed src='"+mv+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+w+"' height='"+h+"'></embed>");
	document.write("</object>");
}

function write_flash_color(mv,w,h,color) {
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+w+"' height='"+h+"'>");
	document.write("<param name='movie' value='"+mv+"'>");
	document.write("<param name='quality' value='high'>");
	document.write("<param name='bgcolor' value='"+color+"'>");
	document.write("<embed src='"+mv+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+w+"' height='"+h+"'></embed>");
	document.write("</object>");
}

function flex_write_flash(mv,w,h,fprm) {
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+w+"' height='"+h+"'>");
	document.write("<param name='movie' value='"+mv+"'>");
	document.write("<param name='quality' value='high'>");
	document.write("<param name='wmode' value='opaque'>");
	if(fprm) document.write("<param name='FlashVars' value='"+fprm+"'>");
	document.write("<embed src='"+mv+"' wmode='opaque' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+w+"' height='"+h+"'");
	if(fprm) document.write(" FlashVars='"+fprm+"' ");
	document.write("></embed>");
	document.write("</object>");
}

function clipp(obgname) {
	value = document.getElementById(obgname).style.clip;
  var res = value.match(/rect\((\d+)px[,]?[ ]+(\d+)px[,]?[ ]+(\d+)px[,]?[ ]+(\d+)px\)/i);
  if (!res) return [0,100,100,0];
  return [parseInt(res[1]), parseInt(res[2]), parseInt(res[3]), parseInt(res[4])];
}

var timerId=Array();	

function toggle_floating(obgname,state,timer,max_width,max_height,init_width,init_height,close_scroll_left,open_scroll_left,cliptop,clipright,clipbottom,clipleft,clipstep) {

	ifr = document.getElementById(obgname+"_iframe");
	
	clipar = clipp(obgname);
	
	cur_cliptop = clipar[0];
	cur_clipleft = clipar[3];
	cur_clipbottom = clipar[2];
	cur_clipright = clipar[1];

	if(state==1) {
		if(cur_cliptop > 0) {
			cur_cliptop=cur_cliptop-clipstep;
			if(cur_cliptop < 0) cur_cliptop=0;
		}
		if(cur_clipleft > 0) {
			cur_clipleft=cur_clipleft-clipstep;
			if(cur_clipleft < 0) cur_clipleft=0;
		}
		if(cur_clipbottom < max_height) {
			cur_clipbottom=cur_clipbottom+clipstep;
			if(cur_clipbottom > max_height)  cur_clipbottom=max_height;
		}
		if(cur_clipright < max_width) {
			cur_clipright=cur_clipright+clipstep;
			if(cur_clipright > max_width) cur_clipright=max_width;
		}			
	} else {
		if(cur_cliptop < cliptop) {
			cur_cliptop=cur_cliptop+clipstep;
			if(cur_cliptop > cliptop) cur_cliptop=cliptop;
		}
		if(cur_clipleft < clipleft) {
			cur_clipleft=cur_clipleft+clipstep;
			if(cur_clipleft > clipleft) cur_clipleft=clipleft;
		}
		if(cur_clipbottom > clipbottom) {
			cur_clipbottom=cur_clipbottom-clipstep;
			if(cur_clipbottom < clipbottom)  cur_clipbottom=clipbottom;
		}
		if(cur_clipright > clipright) {
			cur_clipright=cur_clipright-clipstep;
			if(cur_clipright < clipright) cur_clipright=clipright;
		}	
	}
	
	document.getElementById(obgname).style.clip = "rect("+cur_cliptop+"px,"+cur_clipright+"px,"+cur_clipbottom+"px,"+cur_clipleft+"px)";

	
	if(state==1) {
		if(cur_cliptop==0 && cur_clipleft==0 && cur_clipbottom==max_height && cur_clipright==max_width) { 	
			return;
		}
	}	else {
		if(cur_cliptop==cliptop && cur_clipleft==clipleft && cur_clipbottom==clipbottom && cur_clipright==clipright) { 
			ifr.width = init_width;
			ifr.height = init_height;
			ifr.contentWindow.document.getElementById("iframe_div").style.left = close_scroll_left+"px";				
			return 
		}
	}
	timerId[obgname] = setTimeout('toggle_floating(\"'+obgname+'\",'+state+','+timer+','+max_width+','+max_height+','+init_width+','+init_height+','+close_scroll_left+','+open_scroll_left+','+cliptop+','+clipright+','+clipbottom+','+clipleft+','+clipstep+')',timer);
}
	
function toggle_floating_banner(obgname,state,timer,max_width,max_height,init_width,init_height,close_scroll_left,open_scroll_left,cliptop,clipright,clipbottom,clipleft,clipstep) {
	ifr = document.getElementById(obgname+"_iframe");

	if(state==1)  {
		ifr.width = max_width;
		ifr.height = max_height;		
		ifr.contentWindow.document.getElementById("iframe_div").style.left = open_scroll_left+"px";
	} 

	try {
		 clearTimeout(timerId[obgname]);
	} catch(e) {}

	timerId[obgname] = setTimeout('toggle_floating(\"'+obgname+'\",'+state+','+timer+','+max_width+','+max_height+','+init_width+','+init_height+','+close_scroll_left+','+open_scroll_left+','+cliptop+','+clipright+','+clipbottom+','+clipleft+','+clipstep+')',timer);
}
