var BaseUI = 
{
   Initialize : function () 
    {
		BaseUI.IntializeHero      ()
		BaseUI.InitializeAccordian()
		BaseUI.InitializeColorBox ()

       $('a').each(function(idx,el)
       {
           var theHref = el.getAttribute('href')

           if (theHref != null)
           {
               if (theHref.toLowerCase().indexOf('.synxis.com') != -1)
               {


                   el.onclick = function()
                   {


                       window.open(pageTracker._getLinkerUrl(this.href))
                        return false
                    }
                }
            }
        })
        if (BaseUI.GetCookie('hidesubhead') == null)
        {
            BaseUI.SetCookie('hidesubhead', 'true', 365)
        }
        else
        {
            $('.seo-subhead').hide()
        }
    },
	IntializeHero : function ()
	{
		$('#slideshow').cycle({
    			fx:           'fade',
    			timeout:      7000,
    			fadeOutSpeed: 'slow',
    			pager:        '#dots',
    			prev:         '#prev',
    			next:         '#next'
		})
	},
	InitializeAccordian : function ()
    {
        $('li.accordian_header a').click(function ()
        {
            if($(this).siblings('ul.accordian_body:visible').length) 
            {
                $(this).siblings('ul.accordian_body').slideUp('fast')
                $(this).parent('li').removeClass('arrow_R')
            }
            else 
            {
                $(this).siblings('ul.accordian_body').slideDown()
                $(this).parent('li').addClass('arrow_R')
            }
            return false
        })
    },
	InitializeColorBox : function ()
	{
		$(".gallery a").colorbox();
	},
    OpenWindow: function(url)
    {
        window.open(url,'','resizable,scrollbars,width=800,height=600,top=500,left=500,toolbar=yes');
    },
    OpenPopupWindow: function(url, width, height, top, left)
    {
	if (top  == null) top  = 500
        if (left == null) left = 500

        window.open(url,'','resizable,scrollbars,width=' + width + ',height=' + height + ',top=' + top + ',left=' + left + ',toolbar=yes');
    },
    GetCookie: function(cookieName)
    {
        var a_all_cookies  = document.cookie.split(';')
        var a_temp_cookie  = ''
        var cookie_name    = ''
        var cookie_value   = ''
        var b_cookie_found = false

        for (i = 0; i < a_all_cookies.length; i++) 
        {
            a_temp_cookie = a_all_cookies[i].split('=')
            cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '')

            if (cookie_name == cookieName) 
            {
                b_cookie_found = true;
                if (a_temp_cookie.length > 1) 
                {
                    cookie_value = decodeURIComponent(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''))
                }
                return cookie_value
                break
            }
            a_temp_cookie = null
            cookie_name = ''
        }

        if (!b_cookie_found) return null
    },
    SetCookie: function(cookieName, cookieValue, nDays) 
    {
        if (nDays != null)
        {
            var today  = new Date()
            var expire = new Date()
        
            if (nDays == null || nDays == 0) nDays = 1
        
            expire.setTime(today.getTime() + 3600000 * 24 * nDays)

            document.cookie = cookieName + "=" + encodeURIComponent(cookieValue) + ";path=/;expires=" + expire.toGMTString()
        }
        else
        {
            document.cookie = cookieName + "=" + encodeURIComponent(cookieValue) + ";path=/"
        }
    } 


}

$(document).ready(BaseUI.Initialize)
