$(document).ready( function(){
	/*
	----------------------------------------------------------
	01. GENERAL
	---------------------------------------------------------- */
	
	// EXTERNAL WINDOWS
	$('A[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });


	// ROUNDED CORNERS
	$("#contact #contact-info").corners("20px"); // contact info box


	// LOGO FADE
	$(function() {
		// set opacity to nill on page load
		$("#logo span").css("opacity","0");
		// on mouse over
		$("#logo span").hover(function () {
			// animate opacity to full
			$(this).stop().animate({
				opacity: 1
			}, 'normal');
		},
		// on mouse out
		function () {
			// animate opacity to nill
			$(this).stop().animate({
				opacity: 0
			}, 'normal');
		});
	});
	
	
	// MAKE ENTIRE BLOCK CLICKABLE
	$("#program-list td").click(function(){
    	window.location=$(this).find("a").attr("href");return false;
	});
	
	
	// CLIENT LOGOS SCROLLER
	// $("#clients").scrollable({size:4, hoverClass: 'hover'}).circular().navigator().autoscroll({
	// 		steps:4,
	// 		interval:8000		
	// 	});
	
	
	
	/*
	----------------------------------------------------------
	03. FORMS: CLEAR VALUE ONFOCUS
	---------------------------------------------------------- */
	$('.labelvalue').each(function() {
	    var default_value = this.value;
	    $(this).focus(function() {
	        if(this.value == default_value) {
	            this.value = '';
	        }
	    });
	    $(this).blur(function() {
	        if(this.value == '') {
	            this.value = default_value;
	        }
	    });
	});

	
	
	/*
	----------------------------------------------------------
	04. FONT REPLACEMENT
	---------------------------------------------------------- */
	Cufon.replace('h1')('h2')('body#faqs dl.slider dt');
	
	
	
	/*
	----------------------------------------------------------
	05. FAQS
	---------------------------------------------------------- */
	$("dl.slider dt").click(function(){ //toggle 
		$(this).next("dd").slideToggle("normal");
		$(this).toggleClass("active");
		return false;
	});
	
	// hide all FAQs
	$("dl.slider dd").hide(); 
	

});  // END ON READY



/*
----------------------------------------------------------
05. POPUP FOR SUPPORT PAGE
---------------------------------------------------------- */
jQuery.fn.popupwindow = function(p)
{
	var profiles = p || {};

	return this.each(function(index){
		var settings, parameters, mysettings, b, a;
		
		// for overrideing the default settings
		mysettings = (jQuery(this).attr("rel") || "").split(",");
		
		settings = {
			height:700, // sets the height in pixels of the window.
			width:1050, // sets the width in pixels of the window.
			toolbar:1, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
			scrollbars:1, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
			status:1, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
			resizable:1, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
			left:0, // left position when the window appears.
			top:0, // top position when the window appears.
			center:1, // should we center the window? {1 (YES) or 0 (NO)}. overrides top and left
			createnew:1, // should we create a new window for each occurance {1 (YES) or 0 (NO)}.
			location:1, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
			menubar:1 // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
		};

		// if mysettings length is 1 and not a value pair then assume it is a profile declaration
		// and see if the profile settings exists

		if(mysettings.length == 1 && mysettings[0].split(":").length == 1)
		{
			a = mysettings[0];
			// see if a profile has been defined
			if(typeof profiles[a] != "undefined")
			{
				settings = jQuery.extend(settings, profiles[a]);
			}
		}
		else
		{
			// overrides the settings with parameter passed in using the rel tag.
			for(var i=0; i < mysettings.length; i++)
			{
				b = mysettings[i].split(":");
				if(typeof settings[b[0]] != "undefined" && b.length == 2)
				{
					settings[b[0]] = b[1];
				}
			}
		}

		// center the window
		if (settings.center == 1)
		{
			settings.top = (screen.height-(settings.height + 110))/2;
			settings.left = (screen.width-settings.width)/2;
		}
		
		parameters = "location=" + settings.location + ",menubar=" + settings.menubar + ",height=" + settings.height + ",width=" + settings.width + ",toolbar=" + settings.toolbar + ",scrollbars=" + settings.scrollbars  + ",status=" + settings.status + ",resizable=" + settings.resizable + ",left=" + settings.left  + ",screenX=" + settings.left + ",top=" + settings.top  + ",screenY=" + settings.top;
		
		jQuery(this).bind("click", function(){
			var name = settings.createnew ? "PopUpWindow" + index : "PopUpWindow";
			window.open(this.href, name, parameters).focus();
			return false;
		});
	});

};

$(function()
{ $(".popup").popupwindow(); }); // INITIALIZE POPUP