/**
 * DoubleSidedPrint.com javascript
 * Using jQuery 1.4
 */

// when we're ready
$(document).ready(function() {

	// show tabs and tabify the intro div
	//$('#intro > ul').style.display = 'inline';
	$('#intro').tabs();

    // curve corners of header
    $('#header').corner({
        tl: { radius: 12 },
        tr: { radius: 12 },
        bl: { radius: 12 },
        br: { radius: 12 }}
    );

    // make nav items equal height
    $('#nav li a').equalHeights();

    // make blocks equal height
    $('#content div.contentblock').equalHeights();

	// AJAX File uploader
	var upload = new AjaxUpload('#userfile', {
		//upload script
		action: 'upload.php', //uploads NOT disabled for security
		onSubmit : function(file, extension){
				//show loading animation
				$("#loading").show();
				//check file extension
				if (! (extension && /^(jpg|png|jpeg|gif)$/.test(extension))){
						// extension is not allowed
						$("#loading").hide();
						$("<span class=\"error\">Error: Not a valid file extension</span>").appendTo("#file_holder #errormes");
						// cancel upload
						return false;
				} else {
						// get rid of error
						$('.error').hide();
				}
				//send the data
				upload.setData({'file': file});
		},
		onComplete : function(file, response){
				//hide the laoding animation
				$("#loading").hide();
				//add display:block to success message holder
				$(".success").css("display", "block");

				//find the div in the iFrame and append to error message
				var oBody = $(".iframe").contents().find("div");
				//add the iFrame to the errormes td
				$(oBody).appendTo("#file_holder #errormes");
		}
	});

});

$(window).resize(function() {
    // rescale
});