// JavaScript Document

function add_onclick()
{
	for (iter=1;iter<=3;iter++)
	{
		jQuery(".small_"+iter).bind("mousedown",showMain);
	}
}

function showMain()
{
	var supp_src=jQuery(this).attr("src");
	var image_name=supp_src.split('/')[7].replace("small_","");
	var dir_src="http://";
	for (iter=2;iter<7;iter++)
	{
		dir_src=dir_src+supp_src.split('/')[iter]+"/";
		}
	getElementsByClassName("main_image")[0].src=dir_src+image_name;
}

function load_flesh ()
{
	if (jQuery(".isplaying", this).html()=="0")
	{
		jQuery(".flash_div", this).css("display","block");
		jQuery(".stop_image", this).css("display","block");
	}
	jQuery(".isplaying", this).html("0");
}

function Stopplay()
{
	jQuery(this).parent().parent().find(".flash_div").css("display","none");
	//jQuery(".flash_div").css("display","none");
	jQuery(".stop_image").css("display","none");
	jQuery(".isplaying").html("1");
}

function load_div()
{
	var height=jQuery(this).attr("height");
	var width=jQuery(this).attr("width");
	var src=jQuery(this).attr("src");
	var top=(height-50)/2;
	var left=(width-50)/2;
	var div_str='<div';
	div_str+=' style="height:'+height+'px; width:'+width+'px; background:url(\''+src+'\'); text-align:center; position:relative;" class="banner_img">';
	div_str+='<div class="overlay_img"></div>'
	div_str+='<div style="position:absolute; top:'+top+'px; left:'+left+'px;"><img src="/loader.png" / ></div>';
	div_str+='<div class="flash_div">';
	src=jQuery(this).attr("src").replace(".jpg",".swf");
	var id=jQuery(this).attr("src").split("/")[7].replace(".jpg","");
	var to_replace='<object id="'+id+'" width="'+width+'" height="'+height+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">';
	to_replace+='<param name="quality" value="high" />';
	to_replace+='<param name="wmode" value="opaque" />';
	to_replace+='<param name="base" value="." />';
	to_replace+='<param name="src" value="'+src+'" />';
	to_replace+='<embed name="'+id+'" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" src="'+src+'" quality="high" wmode="opaque" base=".">'
	to_replace+='</embed></object>';
	div_str+=to_replace;
	div_str+='</div>';
	div_str+='<div class="stop_image">';
	div_str+='<img src="/stop.png" height="30" width="30" class="stop_img">';
	div_str+='<img src="/loader.png" height="30" width="30" onclick="window.document.'+id+'.Play()">';
	div_str+='</div>';
	div_str+='<span class="isplaying" style="display:none;">0</span>';
	div_str+='</div>';
jQuery(this).replaceWith(div_str);
}

jQuery(document).ready(function() {
	jQuery(".banner_img").each(load_div);
	jQuery(".banner_img").bind('click', load_flesh).css("cursor","pointer");
	jQuery(".stop_image img.stop_img").bind('click', Stopplay).css("cursor","pointer");
});
