function getSize(passed_id){
	picId=document.getElementById(passed_id)
	num=100
	if (picId) {
		if (picId.name=="prog")num=200
		if (picId.name=="news")num=200
		if (picId.name=="interview")num=120
		if (picId.name=="whats new")num=140
		if (picId.width > num){
			//alert("was: "+picId.width)
			picId.width = num		
		}	
		picId.id = "changed"
	}
}

function showComp() {
	var objVideo = document.getElementById('watch_expo_video');
	var objComp  = document.getElementById('xmas_comp');

	if (objComp.style.display != 'block') {
		
		objComp.style.display = 'block';
		objVideo.style.display = 'none';
	}
}

function popupWindow() {
    var $compForm = $("#xmas_comp_form");
	var popLeft = ($(document).width() - $compForm.width())/2
	$("#xmas_comp_form")
		.css({left: popLeft, zIndex: 101})
		.slideDown();

	if ($("#xmas_comp_mask").length > 0) {
		$("#xmas_comp_mask").fadeIn('100');
	} else {
		var w = document.body.clientWidth + 'px';
		var h = $(document).height() + 'px';
		var mask = $("<div id='xmas_comp_mask'></div>");
		mask
			.css( {
				width: w,
				height: h,
				left: 0,
				top: 0,
				position: 'absolute',
				backgroundColor: '#000000',
				zIndex: 100,
				opacity: 0.5
			});
		$("body").append(mask);
		
		$(window).resize(function() {
			var popLeft = $("#xmas_comp").offset().left;
			$("#xmas_comp_form").css({left: popLeft});
			
			$(mask)
				.css({
					width: $(document).width() + 'px',
					height: $(document).height() + 'px'
			});
		});
	}
}
function closeWindow() {
	$("#xmas_comp_form")
		.slideUp('fast', function() {$("#xmas_comp_mask").fadeOut('100');});
}
$(document).ready(function() {
	$("#btn_comp_click").click(function() {
		$("#frmCompetition").show();
		$("#form_errors").html('');
		$("#comp_form_success").hide();
		popupWindow();
	});
	$("#btn_comp_close").click(function() {
		closeWindow();
	});
	$("#btn_comp_submit").click(function() {
		var params = $("#frmCompetition").serialize();
		var opts = {
			type : 'POST',
			url  : 'competitions/competition.php',
			data : params,
			beforeSend : function() {$("#form_errors").html("<div class='form_loading'></div>");},
			success : function(data) {
				data = $.trim(data);
				if (data == 'success') {
					$("#frmCompetition")[0].reset();
					$("#comp_form_success").show();
					$("#frmCompetition").hide();
				} else {
					$("#form_errors").html("Errors: " + data);
				}
			}
		};
		$.ajax(opts);
	});
});



