/*
Uniform v1.0
Copyright © 2009 Josh Pyles / Pixelmatrix Design LLC
http://pixelmatrixdesign.com

Requires jQuery 1.3 or newer

Much thanks to Thomas Reynolds and Buck Wilson for their help and advice on this

License:
MIT License - http://www.opensource.org/licenses/mit-license.php
*/

jQuery(document).ready(function($) {
  $.uniform = {
    options: {
      selectClass:   'selector',
			radioClass: 'radio',
			checkboxClass: 'checker',
			checkedClass: 'checked',
      focusClass: 'focus'
    }
  };

	if($.browser.msie && $.browser.version < 7){
		$.selectOpacity = false;
	}else{
		$.selectOpacity = true;
	}

  $.fn.uniform = function(options) {
    
		options = $.extend($.uniform.options, options);
	
		function doSelect(elem){
			
			var divTag = $('<div />'),
	  			spanTag = $('<span />');
		
			divTag.addClass(options.selectClass);
			
			spanTag.html(elem.children(":selected").text());
			
			elem.css('opacity', 0);
			elem.wrap(divTag);
			elem.before(spanTag);
			
			//redefine variables
			
			divTag = elem.parent("div");
			spanTag = elem.siblings("span");
			
			elem.change(function() {
       	spanTag.text(elem.children(":selected").text());
     	})
     	.focus(function() {
      	divTag.addClass(options.focusClass);
     	})
     	.blur(function() {
      	divTag.removeClass(options.focusClass);
     	});
		}
		
		function doCheckbox(elem){
			
			var divTag = $('<div />'),
	  			spanTag = $('<span />');
			
			divTag.addClass(options.checkboxClass);
			
			//wrap with the proper elements
			$(elem).wrap(divTag);
			$(elem).wrap(spanTag);
			
			//redefine variables
			
			spanTag = elem.parent();
			divTag = spanTag.parent();

			//hide normal input and add focus classes
			$(elem)
			.css("opacity", 0)
			.focus(function(){
				
				divTag.addClass(options.focusClass);
			})
			.blur(function(){
				
				divTag.removeClass(options.focusClass);
			})
			.click(function(){
				
				if(!$(elem).attr("checked")){	
					//box was just unchecked, uncheck span
					spanTag.removeClass(options.checkedClass);	
				}else{
					//box was just checked, check span
					spanTag.addClass(options.checkedClass);
				}
			});

			//handle defaults
			if($(elem).attr("checked")){
				//box is checked by default, check our box
				spanTag.addClass(options.checkedClass);	
			}
		}
		
		function doRadio(elem){
			
			var divTag = $('<div />'),
	  			spanTag = $('<span />');
			
			divTag.addClass(options.radioClass);
			
			//wrap with the proper elements
			$(elem).wrap(divTag);
			$(elem).wrap(spanTag);

			//redefine variables
			
			spanTag = elem.parent();
			divTag = spanTag.parent();

			//hide normal input and add focus classes
			$(elem)
			.css("opacity", 0)
			.focus(function(){
				divTag.addClass(options.focusClass);
			})
			.blur(function(){
				divTag.removeClass(options.focusClass);
			})
			.click(function(){
				if(!$(elem).attr("checked")){
					//box was just unchecked, uncheck span
					spanTag.removeClass(options.checkedClass);	
				}else{
					//box was just checked, check span
					$("."+options.radioClass+" span."+options.checkedClass).removeClass(options.checkedClass);
					spanTag.addClass(options.checkedClass);
				}
			});

			//handle defaults
			if($(elem).attr("checked")){
				//box is checked by default, check span
				spanTag.addClass(options.checkedClass);	
			}
		}
		
    return this.each(function() {
			if($.selectOpacity){
				var elem = $(this);

				if(elem.is("select")){
					//element is a select
					doSelect(elem);

				}else if(elem.is(":checkbox")){
					//element is a checkbox
					doCheckbox(elem);

				}else if(elem.is(":radio")){
					//element is a radio
					doRadio(elem);
				}
			}
    });
  };
});

/**
 * Javascript - jQuery enabled
 * 
 * @package WPFramework
 * @subpackage Media
 */

/* Example jQuery
jQuery(document).ready(function()
{
	alert('jQuery + screen.js is loaded and ready to go!');
});
*/
			function SetCookie() {
				if(arguments.length < 2) { return; }
				var n = arguments[0];
				var v = arguments[1];
				var d = 0;
				if(arguments.length > 2) { d = parseInt(arguments[2]); }
				var exp = '';
				if(d > 0) {
						var now = new Date();
						then = now.getTime() + (d * 24 * 60 * 60 * 1000);
						now.setTime(then);
						exp = '; expires=' + now.toGMTString();
				}
				document.cookie = n + "=" + escape(String(v)) + '; path=/' + exp;
			}

			function ReadCookie(n) {
				var cookiecontent = new String();
				if(document.cookie.length > 0) {
					var cookiename = n+ '=';
					var cookiebegin = document.cookie.indexOf(cookiename);
					var cookieend = 0;
					if(cookiebegin > -1) {
						cookiebegin += cookiename.length;
						cookieend = document.cookie.indexOf(";",cookiebegin);
						if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
						cookiecontent = document.cookie.substring(cookiebegin,cookieend);
					}
				}
				return unescape(cookiecontent);
			}
jQuery(document).ready(function($)
{

$("#welcome").click(function(event) {
event.preventDefault();
$("#welcome-text").slideToggle();
});

$("#welcome-text a").click(function(event) {
event.preventDefault();
$("#welcome-text").slideUp();
});

$("#ViewIntro").click(function(event) {
event.preventDefault();
$("#intro-bg").toggle();
});
});

function hideintro() {
   SetCookie("HideIntro", "hide");
   jQuery(document).ready(function($)
{ $("#intro-bg").toggle(); });
}

jQuery(document).ready(function($)
{
	$("select").uniform();
});
jQuery(document).ready(function($)
{
	var pval = $("#countries").val();
	$("#"+pval).removeClass("hidden");
	$("#countries").change(function(){
		var nval = $("#countries").val();
		if (nval != "0")
		{
			$("#"+nval).removeClass("hidden");
			$("#"+pval).addClass("hidden");
			pval = nval;
		}
	})
	.change();
});

function initMenus() {
	jQuery(document).ready(function($)
{ $('ul.Amenu ul').hide();
	$.each($('ul.Amenu'), function(){
		$('#' + this.id + '.expandfirst ul:first').show();
	});
	$('ul.Amenu li a').click(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			if($('#' + parent).hasClass('noaccordion')) {
				$(this).next().slideToggle('normal');
				return false;
			}
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
	$('ul.extraN ul').hide();
	$.each($('ul.extraN'), function(){
		$('#' + this.id + '.expandfirst ul:first').show();
	});
	$('ul.extraN li a').click(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			if($('#' + parent).hasClass('noaccordion')) {
				$(this).next().slideToggle('normal');
				return false;
			}
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
	});
}

//$('#element').change(function() { $.post('url',{params},function(data) { doWhateverwith(data); })});