﻿/* UI scripts */

// Uses http://jQuery.com

// Subscription form tabs - works in combination with CSS
$(document).ready(function() {
	$("#panelgroup1 > ul a").click(
		function() {
			$(this).parents("#panelgroup1")
			.removeClass("tab1").removeClass("tab2").removeClass("tab3")
			.addClass($(this).parent().attr("class"));
			return false;
		});
});

function makeThisMyHomepage(el)
{
	if(document.all)
	{
		globalstartpage.setHomePage(location.href);
	}
	else
	{
		window.open(el.href,'Window1','menubar=no,width=430,height=360,toolbar=no');
	}
	return false;
}


function SetLabelClass(validator)
{
    if(!validator.isvalid)
    {
        $(document).ready(function() {
            $("body").find("#"+validator.id).siblings("label")
                    .addClass("error")
            .end();
        });
    }
    else
    {
        $(document).ready(function() {
            $("body").find("#"+validator.id).siblings("label")
                    .removeClass("error")
            .end();
        });
    }
}


function AddHtmlAfter(insertafter, htmltoinsert, count, defaultinsertbefore)
{
    htmltoinsert = htmltoinsert.replace(/COUNT/g,count).replace(/###/g,"'");
    $(document).ready(function() {
        if (document.getElementById(insertafter))
        {
            $("body").find("#"+insertafter)
                .after(htmltoinsert)
            .end();
        }
        else
        {
            
            $("body").find("#"+defaultinsertbefore)
                .before(htmltoinsert)
            .end();
        }
    });
}

function RemoveHtml(id)
{
    $(document).ready(function() {
        $("body").find("#"+id)
            .remove()
        .end();
    });
}
