$(document).ready(function() {
	$('#ValidationErrors > li').each(function(e) {
		if (!$("form.yform fieldset div[rel='" + key + "']").hasClass("error"))
		{
			var key = $(this).attr("rel-key");			
			var message = $(this).text();	
			if ($(key).attr("rel-message"))
			{
				message = $(this).attr("rel-message");
			}	
			$("form.yform fieldset div[rel='" + key + "']").addClass("error");
			$("form.yform fieldset div[rel='" + key + "']").prepend('<strong class="message">' + message + '</strong>');
		}
	});
	
	$(".program .choices > input").bind('click', function() {
		var box = $(this).attr("checked");
		var n = $(this).attr("name");
		$(".program .choices > input[name='" + n + "']").attr("checked", "");
		if (box) {
		    $(this).attr("checked", "true");
		}
		$("#form-choices").submit();
	});

	/*
	$("#imagesbottom > div").bind('click', function() {
		var src = $(this).attr("rel");
		var code = '<img src="' + src + '"/>';
		$("#imagedisplay").html(code);
	});
	
	$("#imagedisplay").html('<img src="' + $("#imagesbottom div:first").attr("rel") + '" alt="" />');	
	
	
	    $("#header").bind('click', function() {
	    	location.href = '/';
	    }); */	
	
	var folderId = $("#flasher").attr("rel");
	
	$.getJSON("/api/image/list/?id=" + folderId,
		function(images){
			var i = 0;
			$.each(images.data, function(i,item){
				var code = '<img src="/Data/0/' + item.id + '.' + item.extension + '" border="0" width="979" height="202" />';
				if (i == 0) 
				{
					$("#flasher").html(code);
				}
				else
				{
					$("#flasher").append(code);
				}
				i++;
			});
			
			$('#flasher').cycle({ 
			    fx:    'fade', 
                                    pause:  50,
				    speed: 5000
			    
			});

		});

	$("#flasher").bind('click', function() {
		location.href = "/";
	});
	    
});

function buylink(url) {
	var MyWindow = window.open(url,'MyWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=630,height=600,left=20,top=20'); 
	MyWindow.focus();
	return false;
}