var docArray=["index.php","home.php"];

$(document).ready(function(){

        if(CurrentDocName()==docArray[1]){
            $('.frm_upload_sec .msk').animate({opacity:.9},{duration:10,queue:false});
        }
        else{$('.liBox').centreElm({aniSpeed:10,easing:'linear'});}

	$(window).bind("load", function(){
            if(CurrentDocName()==docArray[1]){SetMainHeight();}
	});

        $(window).bind("resize",function(){            
            if(CurrentDocName()==docArray[1]){SetMainHeight();}
            else{$('.liBox').centreElm();}
        });


        $('#frmLogin').submit(function(){
            elmName=$('#frmLogin .txtbox');
            liFrmVals=new Array(elmName.eq(0).val(),elmName.eq(1).val());
            if(CheckEmail(liFrmVals[0]) && liFrmVals[1]!=""){
                 $.ajax({
                   type: "POST",url: "media/scripts/php/li.php",data: "func=li&vals="+liFrmVals.toString(),
                   success: function(data){
                       if(data){$('#frmLogin #uliresult').text("Redirecting...");window.location=docArray[1];}
                       else{$('#frmLogin #uliresult').text("User was not found.");}
                   }
                 });
            }
            return false;
        });

	$('a').click(function(){
		thisLink=$(this).attr('href');
		thisRel=$(this).attr('rel');
		if(thisLink!="" && thisLink!=" " && thisLink!="#")
		{
			if(thisRel=="nw"){window.open(thisLink);}
			else{window.location=thisLink;}
		}
		return false;
	});

        $('.frm_upload_sec').submit(function(){
           $(this).children('.msk').show().parent().children('#uploadres').text("Processing...").show();
        });
});


//Jquery extended functions
(function($) {
    $.fn.extend({
        centreElm:function(options){
            var defaults = {easing:'easeInOutExpo',aniSpeed:300};
            var options = $.extend(defaults, options);
            return this.each(function() {
                var aniType=options.easing;
                var timeout=options.aniSpeed;
                var thisElmName=$(this);
                var thisElmHeight=thisElmName.height();
                var thisElmWidth=thisElmName.width();
                var windHeight=$(window).height();
                var windWidth=$(window).width();
                thisElmName.animate({top:((windHeight/2)-(thisElmHeight/2)),left:((windWidth/2)-(thisElmWidth/2))},{duration:timeout,easing:aniType});
            });
        }
    });
})(jQuery);

//standard javascript functions
function CheckEmail(inputemail) {
	AtPos = inputemail.indexOf("@");
	StopPos = inputemail.lastIndexOf(".");
	if (AtPos == -1 || StopPos == -1){return false;}
	else{return true;}
}

function SetMainHeight(){
    winHeight=$(window).height();
    $('.wrap960').css({height:winHeight});
}

function CurrentDocName()
{
    thisURL=document.location.href;
    strUrl=thisURL.split('/');
    strUrl=strUrl.pop().split('?');
    strUrl=strUrl[0].split('#');
    return strUrl[0];
}
