/******************************************************
	jCarousel CONFIGURATION
******************************************************/

/**
* matty_nopobox()
* Validate against P.O Box addresses in form fields.
**/
/*
function matty_nopobox(addressline) {
	var check_value = addressline.val().toLowerCase();
	// var pattern = /^([pP]{1}(.*?)[oO]{1}(.*?))?([bB][oO]?[xX])(\s+)([0-9]+)/g;
	
	// var pattern = /^([pP]{1}(.*?)[oO]{1}(.*?))?([bB][oO]?[xX])/; // Check for any variation of P.O Box
	var pattern 			= /^([pP]{1}(.*?)[oO]{1}(.*?))/; // Check for any variation of P.O or PO
	var pattern_fulltext 	= /^([pP]{1}[oO]{1}[sS]{1}[tT]{1}(.*?)[oO]{1}[fF]{1}[fF]{1}[iI]{1}[cC]{1}[eE]{1}(.*?))/; // Check for any variation of Post Office
	
	var result 				= pattern.test(addressline.val());
	var result_fulltext 	= pattern_fulltext.test(addressline.val());
	
	if (result === true || result_fulltext === true) {
		alert('P.O Box addresses are not permitted for courier. Please enter a physical address.');
		addressline.attr('value', '');
		addressline.focus();
		return false;
	}

} // End matty_nopobox()
*/

/**
* matty_nopobox()
* Validate against P.O Box addresses in form fields.
**/

function matty_nopobox(addressline) {
	var check_value = addressline.val().toLowerCase();
	// var pattern = /^([pP]{1}(.*?)[oO]{1}(.*?))?([bB][oO]?[xX])(\s+)([0-9]+)/g;
	
	// var pattern = /^([pP]{1}(.*?)[oO]{1}(.*?))?([bB][oO]?[xX])/; // Check for any variation of P.O Box
	// var pattern = /^([pP]{1}(.*?)[oO]{1}(.*?))/; // Check for any variation of P.O or PO
	
	var pattern = /^(p.o|.p.o.|.po|p.o.|post.*office)/i;
	// var pattern_02 = /(p[. ]+o[. ]+box|PO|p.?o.|post.*office)/i;
	
	// var pattern_fulltext 	= /^([pP]{1}[oO]{1}[sS]{1}[tT]{1}(.*?)[oO]{1}[fF]{1}[fF]{1}[iI]{1}[cC]{1}[eE]{1}(.*?))/; // Check for any variation of Post Office
	
	var result 				= pattern.test(addressline.val());
	// var result_02 			= pattern_02.test(addressline.val());
	// var result_fulltext 	= pattern_fulltext.test(addressline.val());
	
	var result_03 = false;
	
// alert(check_value.substring(0, 2));
	
	// check_value = jQuery.trim( check_value );
	
	// alert("'" + check_value + "'");
	
	if ( 
			check_value.substring(0, 3) == 'po ' || 
			check_value.substring(0, 4) == ' po ' || 
			check_value.substring(0, 4) == 'p o ' || 
			check_value.substring(0, 5) == ' p o '
		) { result_03 = true; } // End IF Statement
	
	if ( result || result_03 ) {
		alert('P.O Box addresses are not permitted for courier. Please enter a physical address.');
		addressline.attr('value', '');
		addressline.focus();
		return false;
	}

} // End matty_nopobox()

jQuery(document).ready( function() {


/*---Prevent special characters in street address fields. - 2010-06-10-*/

jQuery("input.input-text[title!='Email Address'][type!='password'][id!='login-email'][id!='email_address']").keypress(function (e) {
    if (e.which > 0 && // check that key code exists
            e.which != 8 && // allow backspace
            e.which != 32 && e.which != 45 && e.which != 46 && e.which != 44 && e.which != 43 && e.which != 95 && // allow space, dash, full stop and comma
            !(e.which >= 48 && e.which <= 57) && // allow 0-9
            !(e.which >= 65 && e.which <= 90) && // allow A-Z
            !(e.which >= 97 && e.which <= 121)   // allow a-z
            ) {
            e.preventDefault();
    }
});

/*
    jQuery("input#street_1,input#street_2,input[title*='Street Address']").keypress(function (e) {
        if (e.which > 0 && // check that key code exists
                e.which != 8 && // allow backspace
                e.which != 32 && e.which != 45 && e.which != 46 && e.which != 44 && // allow space, dash, full stop and comma
                !(e.which >= 48 && e.which <= 57) && // allow 0-9
                !(e.which >= 65 && e.which <= 90) && // allow A-Z
                !(e.which >= 97 && e.which <= 121)   // allow a-z
                ) {
                e.preventDefault();
        }
    });
*/
/*---End Prevent special characters in street address fields.----------*/


	jQuery('#image_holder_01').cycle({ 
		fx:     'fade', 
		delay:  -4000, 
		speed: 3000, 
		random: true
	});
	
	jQuery('#image_holder_02').cycle({ 
		fx:     'fade', 
		delay:  -7503, 
		speed: 7000, 
		random: true
	});

	jQuery(function() {
		jQuery(".scroller").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev"			
		});
	});
	
	jQuery(function() {
	  jQuery("ul.more").each(function() {
		jQuery("li:gt(4)", this).hide(); 
		jQuery("li:last", this).after("<li class='more'><a style='background: none !important; color: black !important; font-weight: bold; ' href='#'>More/Less</a></li>");
		jQuery("li:gt(4)", this).addClass('list-more'); 
		jQuery("li:last", this).removeClass('list-more'); 
	  });
	  
	  jQuery("li.more a").live("click", function() {
		var li = jQuery(this).parents("li:first");
		li.parent().children('.list-more').toggle();
		
		//li.remove();
		return false;
	  });
	});
	
	jQuery('input#street_1').blur( function () {
		
		if (jQuery(this).val().length > 1) {
			var tmpStr = jQuery(this);
			matty_nopobox(tmpStr);
		}
		
	});
	
	jQuery('input#street_2').blur( function () {
	
		if (jQuery(this).val().length > 1) {
			var tmpStr = jQuery(this);
			matty_nopobox(tmpStr);
		}
		
	});
	
	jQuery("input[title*='Street Address']").blur( function () {
		
		if (jQuery(this).val().length > 1) {
			var tmpStr = jQuery(this);
			matty_nopobox(tmpStr);
		}
		
	});

	jQuery("input[title*='Telephone']").mask("(999) 999-9999");
	
	jQuery('#slider_01').cycle({ 
		fx:     'fade', 
		delay:  -4000, 
		speed: 3000, 
		random: true
	});
	
	jQuery('#slider_02').cycle({ 
		fx:     'fade', 
		delay:  -7503, 
		speed: 7000, 
		random: true
	});
	
	jQuery('#slider_03').cycle({ 
		fx:     'fade', 
		delay:  -8000, 
		speed: 5000, 
		random: true
	});
	
	jQuery('.faqpage h4').css('display', 'block').css('cursor', 'pointer');
	jQuery('.faqpage h4').next().hide();
	jQuery('.faqpage h4').addClass('faq-arrow-down');
	
	jQuery('.faqpage h4').click ( function () {
		jQuery(this).next().toggle();
		if ( jQuery(this).hasClass('faq-arrow-down') ) {
			jQuery(this).removeClass('faq-arrow-down');
			jQuery(this).addClass('faq-arrow-up');
		} else if ( jQuery(this).hasClass('faq-arrow-up') ) {
			jQuery(this).removeClass('faq-arrow-up');
			jQuery(this).addClass('faq-arrow-down');
		}
	} );
	
	var open_graphicmail = function () {
		
	  window.open('http://www.graphicmail.co.za/RWCode/subscribe.asp?SiteID=11010&Mode=subscribe','','top=-200,left=75,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=350');
	  
	 } // End OpenGM()
	  
	 jQuery('.graphicmail').unbind('click');
	 
	 jQuery('.graphicmail').bind('click', open_graphicmail);
	/*
	jQuery('.faqpage ul li h3').click (function (e) {
		
		if ( jQuery(this).hasClass('faq-arrow-down') ) {
			jQuery(this).removeClass('faq-arrow-down');
			jQuery(this).addClass('faq-arrow-up');
		} else if ( jQuery(this).hasClass('faq-arrow-up') ) {
			jQuery(this).removeClass('faq-arrow-up');
			jQuery(this).addClass('faq-arrow-down');
		}
		
		var eventCaller;
		
		if (window.addEventListener) {
			eventCaller = e.target;
		} else {
			eventCaller = window.event.srcElement;
		}
		
		var nextSibling = eventCaller.nextSibling;
		
		while(nextSibling != undefined) {
			if ( typeof (nextSibling.tagName) == 'string' ) {
				nextSibling.style.display = (nextSibling.style.display == 'none' || nextSibling.style.display == '') ? 'block' : 'none';
				// jQuery(this).next().toggle();
			}
			nextSibling = nextSibling.nextSibling;
		}
	});
	*/

});
/******************************************************/
/******************************************************
	FUNCTIONS TO EMPTY AND RE-FILL A TEXT FIELD
******************************************************/

function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
	thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
	thisfield.value = defaulttext;
	}
}

/******************************************************/
/******************************************************
	FUNCTION TO VALIDATE SITE SEARCH FORM
******************************************************/

/*
function validate_sitesearch(){
	
	var bError = 0
	
	if(document.frm_search.txt_search.value == "" || toLowerCase(document.frm_search.txt_search.value) == 'search site'){
		if(bError==0){
			alert("Please enter a search.")
			bError=1
			return false
		}
	}

	
				
	if(bError==0){
		document.frm_search.submit()
	}
}
*/


/******************************************************/
