/*
 *
 * PhotoShakr website JS
 *
 * version 0.1
 * last revision 2006 11 19
 *  
 * Copyright (C) 2006 by Davide 'Folletto' Casali.
 *    mail: <folletto AT gmail DOT com>
 *    web: http://digitalhymn.com
 *
 * REQUIRES jQuery.
 */


/******************************************************************************************
 * Check Start form
 * The E-Mail field must be present
 * 
 */
function chkFormStart() {
	email = document.getElementById("email");
	
	if (email && email.value.match(/[^@]+@[^.]+\..+/i)) {
		return true;
	}
	
	$("#start-hint").html("The E-Mail address seems invalid.<br />Please check it again.");
	return false;
}

/******************************************************************************************
 * Check Start form
 * The E-Mail field must be present
 * 
 */
function getSets(root, set) {
	$('#flickr-set-list').html('<br />Asking Flickr...');
	//$('#flickr-set-list').load(root + 'form/sets?user=' + $('#email').attr('value') + '&set=' + set);
	$('#flickr-set-list').load(root + 'form/sets', {user: $('#email').attr('value'), set: set});
}

/******************************************************************************************
 * Set for the onchange evento of the size select box.
 * 
 */
function customSize(item) {
	if (item && item.value) {
		// ****** Selection WxH
		if ($('#custom-size').css('display') != 'none') $('#custom-size').slideUp();
		size = item.value.split("x");
		$('#width').val(size[0]);
		$('#height').val(size[1]);
	} else {
		// ****** Custom
		if ($('#custom-size').css('display') == 'none') $('#custom-size').slideDown();
	}
}

/******************************************************************************************
 * Select the correct option reading the text fields width and height.
 * 
 */
function customSizeSelect() {
	var width = $('#width').val();
	var height = $('#height').val();
	
	if ($('#size').val(width + "x" + height).val() == "") {
		customSize(null);
	}
}