// Weather-Text
// November 2011, by Chris Dorward
$(document).ready(function () {
	var cookie_status = $( "#wt_phone_screen_text" ).text();
	$( "#wt_phone_screen_text" ).text('');
	if (cookie_status == 'no_cookie'){
		$( "#wt_phone_screen_text" ).load('/wp-content/themes/weather-text/php/form1.php');
	}
	$( "#dialog:ui-dialog" ).dialog( "destroy" );
	
	
	$( "#info_wt_user_number_dialog" ).dialog({
		resizable: true,
		autoOpen: false,
		width:300,
		height:200,
		modal: true,
		buttons: {
			OK: function() {
				$( this ).dialog( "close" );
			}
		}
	});
	$( "#info_wt_user_country_dialog" ).dialog({
		resizable: true,
		autoOpen: false,
		width:550,
		height:300,
		modal: true,
		buttons: {
			OK: function() {
				$( this ).dialog( "close" );
			}
		}
	});
	
	
	

	
	
});

function validate_form_1 (){
	//alert ('form 1 submitted');
	//alert ($( "#wt_user_country_field" ).val());
}


function set_timer (time_length, do_next){
	var timer = setInterval( per_second, 100);
	var time_length = time_length;
	var do_next = do_next;
	var counter = 0;
	function per_second (){
		counter ++;	
		if (counter == time_length){
			if (do_next == 'fade_out_loading'){
				fade_out_loading ();
			}else if (do_next == 'fade_in_loading'){
				fade_in_loading ();
			}
			clearInterval(timer);
		}
	}
	
}

function fade_out_loading (){
	$( "#wt_phone_screen_loading" ).fadeOut('fast', function() {
		//fade_in_loading ();
  	});	
}
function fade_in_loading (){
	$( "#wt_phone_screen_loading" ).fadeIn('fast', function() {
  	});
}
<!--
// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place
function numbersonly(myfield, e, dec){
	var key;
	var keychar;
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
		(key==9) || (key==13) || (key==27) )
	   return true;
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	   return true;
	// decimal point jump
	else if (dec && (keychar == ".")){
	   myfield.form.elements[dec].focus();
	   return false;
	}
	else
	   return false;
};
/////////////////////////////////////////////
