$(document).ready(function() {
	$("input[alt]").click(function() {
		window.location = $(this).attr('alt');
	});
	function newWindows(url, varWidth, varHeight, wName) {
		var options = "width=" + varWidth + ",height=" + varHeight + ",";
		options += "resizable=no,scrollbars=yes,status=yes,menubar=no,toolbar=no,location=no,directories=no,";
		options += "left="+(screen.width-varWidth)/2+",top="+((screen.height-varHeight)/2-20);
		newWin = window.open(url, wName, options);
		newWin.focus();
	}
	$("a[accesskey]").click(function() {
		if($(this).attr('accesskey') == 'H') {
			newWindows($(this).attr('href'), 500, 500, 'Helper');
			return false;
		}
	});
	$("#reg_ag").click(function() {
		if($(this).attr('checked') == true) $("#reg_sub").attr('disabled', false);
		else $("#reg_sub").attr('disabled', true);
	});
	$(".g_close a").click(function() {
		$("#baker").css('width', '0px');
		$("#baker").css('height', '0px');
		$("#alert").hide();
		return false;
	});
	
	$(".goto").hover(function() {
		$(this).children("a").css('visibility', 'visible'); },
	function() {
		$(this).children("a").css('visibility', 'hidden');
	});
	
	$("#prev a").click(function() {
		for(var i = 1; i <= all; i++) {
			if(dir + pic[i] == cur) {
				if(i == 1) _gallery(dir + pic[all]);
				else _gallery(dir + pic[i - 1]);
				break;
			}
		}
		return false;
	});
	$("#next a").click(function() {
		for(var i = 1; i <= all; i++) {
			if(dir + pic[i] == cur) {
				if(i == all) _gallery(dir + pic[1]);
				else _gallery(dir + pic[i + 1]);
				break;
			}
		}
		return false;
	});
	
	$(".showd a").click(function() {
		$(".hiddens").show(200);
		$(".showd").html('');
		return false;
	});
	
	$(".mod_list_m").click(function() {
		$("#s" + $(this).attr('id')).toggle(50);
	});
	
	$(".sub_tit_bar_f").click(function() {
		$("#d" + $(this).attr('id')).toggle(100);
	});
	
	$(".sub_menu").slideDown(500);
});

// Render flash object for SEO
function swf(m, d, w, h, p) {
	var sw = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+w+'" height="'+h+'" align="middle">';
	sw += '<param name="allowScriptAccess" value="sameDomain" />'; sw += '<param name="wmode" value="transparent" />';
	sw += '<param name="movie" value="'+m+'" />'; sw += '<param name="quality" value="high" />'; sw += '<param name="Flashvars" value="'+p+'" />'; 
	sw += '<embed src="'+m+'" wmode="transparent" align="middle" quality="high" '; sw += 'Flashvars="'+p+'" '; 
	sw += 'width="'+w+'" height="'+h+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	$("#" + d).html(sw);
}

function _gallery(a) {
	cur = a;
	var winH = $(window).height();
	var winW = $(window).width();
	// Baker
	$("#baker").css('width', winW + 'px');
	$("#baker").css('height', ($(window).scrollTop() + winH) + 'px');
	// Alert
	$(".g_img").html('<img src="/includes/img.php?view:480:360:/upload/' + a + '" width="480" height="360" />');
	$("#alert").css('top',  $(window).scrollTop() + winH / 2 - $("#alert").height() / 2);
	$("#alert").css('left', winW / 2 - $("#alert").width() / 2);
	
	$("#alert").show();
}