 
/*
        -------------------------------------------------------------------------------------------------------
        Properties:	TTI: Objects
        Overview:	These properties allowing the operating of the Gadgets
        -------------------------------------------------------------------------------------------------------
*/
        var Gadgets = new Object();     
        var Site = new Object();  
        var App = new Object();
        var AppLoader = new Object();
/*
        -------------------------------------------------------------------------------------------------------
        Properties:	News page onLoadHandler
        Overview:	This function will get triggered once the content has loaded.
        -------------------------------------------------------------------------------------------------------
*/
/*
function Error (errmsg, url, linenumber){return true;};
window.onerror = Error; 
*/
     
var lastBlock = null;
var maxWidth = 310;
var minWidth = 129;
var toolsrunning=false;	
           	
jQuery(document).ready(function(){
   
        //Assign Preferences Link
        jQuery("#customNewsLink").click
        (
                function () 
                {
                        
                        if (jQuery("#PrefSettingsWindow").css('display') == 'block')
                        {
                                jQuery("#PrefSettingsWindow").slideUp(
                                        "normal",
                                        function ()
                                        {
                                                jQuery("#PrefSettingsWindow").css({"display":"none" }); 
                                        }
                                );     
                                jQuery("#customNewsLink .status").html('[Expand]'); // Change Text
                        }
                        else
                        {
                                jQuery("#PrefSettingsWindow").slideDown(
                                        "normal", 
                                        function ()
                                        {
                                                jQuery("#PrefSettingsWindow").css({"display":"block" }); 
                                        }
                                );  
                                jQuery("#customNewsLink .status").html('[Collapse]'); // Change Text
                        }    
                }
        );
        
        jQuery('.knob_holder').draggable
        ({ 
                        axis:'y', 
                        containment: 'parent', 
                        //grid: [5,5], 
                        //stop: function(e, ui) { UpdateNewsSettings(); }, 
                        drag: function(e, ui) 
                        { 
                                if(parseFloat(jQuery(this).css('top')) >= 0)
                                {
                                        jQuery(this).parent().find(".vslider_top").css({height:''+parseInt(jQuery(this).css('top'))+'px'}); 
                                        jQuery(this).parent().parent().parent().find(".newsprepStatus").html(''+parseInt(((parseInt(jQuery(this).css('top')))/69*100))+'%'); 
                                }
                        }
        });

        //Assign Tool Overlay Animations.
        lastBlock=jQuery("#a1");
        jQuery("#ToolsOverlay ul li a").hover
        (
                function()
                {
                        if (lastBlock!=this&&toolsrunning==false)
                        {
                                toolsrunning=true;
                                jQuery(lastBlock).animate({
                                        width: minWidth+"px"
                                        }, 
                                        400
                                );
                                jQuery(this).animate({
                                        width: maxWidth+"px"
                                        }, 
                                        400,
                                        function()
                                        {
                                             toolsrunning=false;   
                                        }
                                );
                                lastBlock = this;    
                        }
                },
                function()
                {}
        );


        //Assign Preferences Link
        jQuery(".ToolsOverlayLink").click
        (
                function () 
                {
                        
                        if (jQuery("#ToolsOverlay").css('display') == 'block')
                        {
                                $("#ToolsOverlay").slideUp(
                                        "normal",
                                        function()
                                        {
                                                jQuery(".ToolsOverlayLink").html('Tools Overlay [Open]'); // Change Text
                                                jQuery("#ToolsOverlayContent").css({"display":"none" }); 
                                        }
                                );
                                
                        }
                        else
                        {
                                $("#ToolsOverlay").slideDown(
                                        "normal",
                                        function()
                                        {
                                                jQuery(".ToolsOverlayLink").html('Tools Overlay [Close]'); // Change Text
                                                jQuery("#ToolsOverlayContent").css({"display":"block" }); 
                                        }
                                );
                                
                        }    
                }
        );
        
        var h2count = $('#newscontent h3').length;
        jQuery('.tagArrow')
		.click(function()
                {
			var scrollTop = jQuery(window).scrollTop();
			jQuery('#newscontent h3').each(
                                function(i, h2)
                                {
        				h2top = jQuery(h2).offset().top;
        				if (scrollTop < h2top) 
                                        {
        					jQuery.scrollTo(h2, 800);
        					return false;
        				}
        			}
                        );
		});

                  
});

/*
        -------------------------------------------------------------------------------------------------------
        Functions:	TTI News Cust: Updating Adjustments
        Overview:	These functions and properties operate the gadgets	
        -------------------------------------------------------------------------------------------------------
        History:	Version:	Developer:	Details:
        No Chanages have beeen made
        -------------------------------------------------------------------------------------------------------
        Improvments to be carried out:
        Setup an ERROR Handler Method for error trapping the content on the site.
        -------------------------------------------------------------------------------------------------------
*/
        function UpdateNewsSettings()
        {
                //Build JSON
                //var rootArray;
                //rootArray = new Array();
                //rootArray[0] = ();
                //rootArray.push();
/*
                //Ajax Call
                var AjaxCall = new Framework.Ajax();
                AjaxCall.page = ""+TTI_domain+"settings.php";
                AjaxCall.parameters = "act=UpdateNewsOrder&settings="+JSON.stringify(rootArray)+"";  
                AjaxCall.method = "get";
                AjaxCall.callback = function(responseText, responseStatus, responseXML)
                {
                         //alert(responseText);
                }
                AjaxCall.Call(); // Actaul Call   
                */
                return;   
        }
        
        var currentNewsSection=0;
        var currentNewsScrolling=false;
        function scrollNewsPref(intDir)
        {             
                if (intDir==0 && currentNewsSection==0)
                {
                        return;
                }   
                
                if (intDir==1 && currentNewsSection==2)
                {
                        return;
                }
                
                if (currentNewsScrolling==false)
                {
                        currentNewsScrolling=true; 
                        if (intDir==0)
                        {
                                //Left
                                currentNewsSection--;
                        }
                        else
                        {
                                //Right
                                currentNewsSection++;
                        }
                                           
                        jQuery("#newsPrefScroll").animate
                        (
                                { 
                                        marginLeft: "-"+(315*currentNewsSection)+"px" 
                                }, 
                                "normal", 
                                function()
                                { 
                                        //alert("int "+currentNewsSection+"");
                                        if (currentNewsSection>0)
                                        {
                                                if (currentNewsSection==2)
                                                {
                                                        jQuery("#arrowHandRight").addClass("arrowHandRightOff");
                                                        jQuery("#arrowHandRight").removeClass("arrowHandRight");
                                                }
                                                else
                                                {
                                                        jQuery("#arrowHandRight").addClass("arrowHandRight");
                                                        jQuery("#arrowHandRight").removeClass("arrowHandRightOff");
                                                }
                                                
                                                jQuery("#arrowHandLeft").addClass("arrowHandLeft");
                                                jQuery("#arrowHandLeft").removeClass("arrowHandLeftOff");
                                        }
                                        else
                                        {
                                                if (currentNewsSection==0)
                                                {
                                                        jQuery("#arrowHandLeft").addClass("arrowHandLeftOff");
                                                        jQuery("#arrowHandLeft").removeClass("arrowHandLeft");
                                                }
                                                else
                                                {
                                                        jQuery("#arrowHandLeft").addClass("arrowHandLeft");
                                                        jQuery("#arrowHandLeft").removeClass("arrowHandLeftOff");
                                                }
                                                
                                        }
                                        currentNewsScrolling=false;
                                 });
                }
        }
