	$(document).ready(function() {			   
	
	
	/* Home Image Banner */	
				
		if ($('#top-image-banner img').length > 1) {
					
			$('#top-image-banner') 
			.after('<div id="top-banner-pager">') 
			.cycle({ 
				fx:     'fade', 
				speed:  'slow', 
				timeout: 5000, 
				pager:  '#top-banner-pager'
				//next:   '#next', 
				//prev:   '#prev'			
			});
				
		}
		
	/* News Archive */
		
		//$('#news-archive li:first').find("ul").show();
		
		$('#news-archive li').click(function() {
			 
			// if ($(this).hasClass("topLvl")) {		 
				 $(this).find("ul").slideToggle('slow');
			// }
		});


	/* show hide news articles */ 
		$('div.article-date').click(function() {						 
			 $(this).parent().parent().find("div.content").slideToggle('slow', function(){

				var eleClass = $(this).parent().attr("class");
				
				if ($(this).parent().hasClass("closed")) {
					
					eleClass = eleClass.replace("closed","open");
					$(this).parent().attr("class", eleClass);
					
				} else {					
					eleClass = eleClass.replace("open","closed");
					$(this).parent().attr("class", eleClass);
				}
			
			});
		});
		
	/* toggle search results */
	
	$('.result-item h3.search-product-title').click(function(){
		
		if ($(this).parent().hasClass('open')) {
			$(this).parent().removeClass('open');			
		} else {
			$(this).parent().addClass('open');
		}
		$(this).parent().find('.result-item-content').slideToggle();
	
	})
	

	/* drop down menu */	
	
	
	$('#top-nav ul li.current-parent').find("a:first").css({
		'color' : '#FFFFFF',
		'background-color' : '#CEBD64'
	});	
	
	
		
		$('#top-nav ul li').hover(							  

		function(){
			
			$(this).find("a:first").addClass("current");
			
			isSelected = false;			
			if ($(this).hasClass("current-parent")) {
				isSelected = true;
			}
			
			if (($(this).hasClass("child")) && (!$(this).hasClass("selected"))) {
				//do not display menu			
			} else {
				$(this).find("ul:first").show();		
			}
			
		},
		function(){
			
			if (!$(this).hasClass("child")) {
				$(this).find("ul:first").hide();	
			}
			if (!isSelected) {
				$(this).removeClass("current-parent");
			}
			
			$(this).find("a:first").removeClass("current");
			
		}
		
		)

	})
	
	/* add favourite */

		function bookmarksite(title, url){
			
			if((navigator.appName == "Microsoft Internet Explorer")) {
				window.external.addfavorite(url, title);
			} else {
				window.sidebar.addPanel(title, url, "");
			}
		}
		
	/* empty form element strings */
		
		function clearText(element) {
			if (element.value) {
				element.value = "";
			}
		}

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function validateSignupForm(formId){

    //Make sure id is passed in
    if(formId == "" || formId == undefined){
        return false;
    }
    //Make sure values are set
    if(document.getElementById('signup-name').value == "" ||
       document.getElementById('signup-name').value == "Name" ||
       document.getElementById('signup-name').value == undefined ||
       document.getElementById('signup-email').value == "" ||
       document.getElementById('signup-email').value == "Email" ||
       document.getElementById('signup-email').value == undefined){
       alert('Please Enter Name and Email');
        return false;
       }

       return true;

}
