// JavaScript Document
var gen_auto = 1;

if(jQuery.browser.msie && parseInt(jQuery.browser.version, 10) == 6) {
	notIE6 = false;
}
else
{
	notIE6 = true;
}

function isdefined(object, variable)
{
	return (typeof(eval(object)[variable]) != 'undefined');
}
function nextbox(target)
{
	if (gb[target]['autoint']) {window.clearInterval(gb[target]['autoint']);}
	if (gb[target]['cur'] < gb[target]['cnt']) {
		var targetid = gb[target]['cur'] + 1;
	}
	else
	{
		var targetid = 1;
	}
	gen_change(target, targetid);
	gb[target]['cur'] = targetid;
}
function prevbox(target)
{
	if (gb[target]['autoint']) {window.clearInterval(gb[target]['autoint']);}
	if (gb[target]['cur'] > 1) {
		var targetid = gb[target]['cur'] - 1;
	}
	else
	{
		var targetid = gb[target]['cnt'];
	}
	gen_change(target, targetid);
	gb[target]['cur'] = targetid;
}
function gen_change(target, targetid)
{
	if (gb[target]['auto'] == 1)
	{
		if (gb[target]['autoint']) {window.clearInterval(gb[target]['autoint']);}
	}
	else
	{

		var img = new Image();
		img.src = gb[target]['img'][targetid];
		img.border = "0";
		img.width = "126";
		img.height = "126";
		$('div#'+target+" a.bnr").html(img);

		if (img.complete) 
		{ 
			if (notIE6) {gb[target]['autoint'] = window.setInterval("nextbox('"+target+"')",gb[target]['dur'][targetid] * 1000);}
			img = null;
		}
		else
		{
			img.onload = function() {
				$('#'+target+"_bnr").html(img);
				if (notIE6) {gb[target]['autoint'] = window.setInterval("nextbox('"+target+"')",gb[target]['dur'][targetid] * 1000);}
				img = null;
			}; 
		}
		$('div#'+target+" a.bnr").attr('href',gb[target]['link'][targetid]);
		$('div#'+target+" a.bnr").attr('target',gb[target]['tWin'][targetid]);
	}
}

var gb = new Array();

$(window).load(function() { 
	if(isdefined(window,'rot_i'))
		for (value in gb)
		{
			window.gb[value]['auto'] = 0;
			window.gb[value]['cur'] = 1;
			if (notIE6)
				{ window.gb[value]['autoint'] = window.setInterval("nextbox('"+value+"')",gb[value]['dur'][1] * 1000); }	
			else {window.clearInterval(gb[value]['autoint']);}
		}
	if ((notIE6) && (isdefined(window,'mainimage'))) {edi_autoid = window.setTimeout('showart(2);',5000);}
	
});