﻿var strVideoPlayerTitle = "Workscape Video Player";
var strVideoPlayerUrlBase = "/VideoPlayer.aspx?src=";


$(document).ready
(
    function()
    {
        var aryTxt = $('input[type="text"], textarea');
        
        aryTxt.each
        (
            function()
            {
                $(this).blur
                (
                    function()
                    {
                        var txt = $(this);
                        txt.val(jQuery.trim(txt.val()));        
                    }
                );
            }
        );
    
        $('a.video320').each
        (
            function(i)
            {
                var a = $(this);
                
                a.data('vid', a.attr("href")); 
                a.attr('href', "javascript:void(0);");
                
                a.click
                (
                    function()
                    {
                        return GB_showCenter(strVideoPlayerTitle, strVideoPlayerUrlBase + a.data('vid'), 290, 320);
                    }
                );   
            }
        );
        $('a.video427').each
        (
            function(i)
            {
                var a = $(this);
                
                a.data('vid', a.attr("href")); 
                a.attr('href', "javascript:void(0);");
                
                a.click
                (
                    function()
                    {
                        return GB_showCenter(strVideoPlayerTitle, strVideoPlayerUrlBase + a.data('vid'), 290, 427);
                    }
                );   
            }
        );
        $('a.video640').each
        (
            function(i)
            {
                var a = $(this);
                
                a.data('vid', a.attr("href")); 
                a.attr('href', "javascript:void(0);");
                
                a.click
                (
                    function()
                    {
                        return GB_showCenter(strVideoPlayerTitle, strVideoPlayerUrlBase + a.data('vid'), 530, 640);
                    }
                );   
            }
        );
        
        $('a.video').each
        (
            function(i)
            {
                var a = $(this);
                
                a.data('vid', a.attr("href")); 
                a.attr('href', "javascript:void(0);");
                
                a.click
                (
                    function()
                    {
                        var iWidth = parseInt(a.attr('flv_width'));
                    
                        if(isNaN(iWidth))
                            iWidth = 640;
                        
                        var iHeight = parseInt(a.attr('flv_height'));
                        
                        if(isNaN(iHeight))
                            iWidth = 530;
                    
                        return GB_showCenter(strVideoPlayerTitle, strVideoPlayerUrlBase + a.data('vid'), iHeight, iWidth);
                    }
                );   
            }
        );
	
	    $('a.bookmark').each
	    (
		    function()
		    {
			    var a = $(this);
			    
			    a.data('url', a.attr('href'));
			    a.attr('href', 'javascript:void(0);');
    			
			    a.click
			    (
				    function()
				    {
					    var link = $(this);
    					
					    var strTitle = link.html();
    					
					    if(link.attr('title'))
						    strTitle = link.attr('title');
						    
						if(link.data('url'))
						    strHref = link.data('url');
    					
					    if(strTitle && strHref && addToFavorites)
						    addToFavorites(strHref, strTitle);
				    }
			    );
		    }
	    );
    	
	    $('a.bookmark_me').each
	    (
		    function()
		    {
			    var a = $(this);
    			
			    a.attr('href', 'javascript:void(0);');
    			
			    a.click
			    (
				    function()
				    {
					    var link = $(this);
    					
					    var strTitle = link.html();
    					
					    if(link.attr('title'))
						    strTitle = link.attr('title');
    					
					    if(strTitle && addToFavorites)
						    addToFavorites(window.location.href, strTitle);
				    }
			    );
		    }
	    );
    }
);
