﻿window.onload = function() {
//    $("#rss").jticker({ delay: 4000,         url: "/rsstitles/",        transition: "fade",        speed: "slow"    });

    $('#windowOpen').bind(
			'click',
			function() {
			    if ($('#window').css('display') == 'none') {
			        $(this).TransferTo(
						{
						    to: 'window',
						    className: 'transferer2',
						    duration: 300,
						    complete: function() {
						        $('#window').show();
						        $('#txtUser').focus();
						    }
						}
					);
			    }
			    this.blur();
			    return false;
			}
		);

    $('#windowClose').bind(
			'click',
			function() {
			    $('#window').TransferTo(
					{
					    to: 'windowOpen',
					    className: 'transferer2',
					    duration: 300
					}
				).hide();
			}
		);

    $('#window').Resizable(
			{
			    minWidth: 200,
			    minHeight: 60,
			    maxWidth: 700,
			    maxHeight: 400,
			    dragHandle: '#windowTop',
			    handlers: {
			        se: '#windowResize'
			    }
			}
		);

    //Fade pictures		
    $('#s1').cycle({ fx: 'fade', pause: 0, speed: 1800 });
    $('#footer').corner("round 6px");
    $('img[@src$=.png], #window').ifixpng();
}

var returnURL = "";

function sLogin(e) { var keycode;var keychar;var numcheck;if(window.event) {keycode = e.keyCode;}else if(e.which) {keycode = e.which;} else { return true; }if (keycode == 13){doLogin();return false;}else return true;}
function redirect(url) { var version = parseInt(navigator.appVersion); if (version>=4 || window.location.replace) { window.location.replace(url); } else { window.location.href = url; }}
function doLogin()
{
    var txtUser = $("#txtuser").val();
    var txtPassword = $("#txtpass").val();
    if ((txtUser.length >= 3) && (txtPassword.length >= 3))
    {
        $('#divsignin').hide();
        $('#divsigninprocess').show();
        $.getIfModified("/authenticate/", { u: txtUser, p: txtPassword }, function(data) {
            if (data != "no_auth") {
                $.getIfModified("/authenticate/", { at: data }, function(data) {
                    if (returnURL == "") { redirect('/'); }
                    else { redirect(returnURL); }
                });
            }
            else {
                alert('The e-mail address or password you entered is not valid. Please try again.');
                $('#txtuser').val('');
                $('#txtpass').val('');
                $('#divsignin').show();
                $('#divsigninprocess').hide();
            }
        });
    }
}