
function jquiform() {
		var form = jQuery('form.customcontactform'); //assign variable for all forms
		if(form !== null){
		form.removeClass(); //remove existing classes
		form.children().removeClass(); //remove existing classes of children elements
		form.children().children().removeClass() // remove existing classes of 'grandchildren' elements
		form.wrap("<div class='ui-widget ui-widget-content ui-corner-all form-all' />");
		form.find('h4').addClass('ui-widget-header ui-corner-top form-header');
		form.parent().prepend(form.find('h4'));
		form.addClass('form-inside'); // add widget class to form
		//style the input boxes
		form.find(':input').addClass('ui-state-default ui-corner-all').focusin(function(){
			jQuery(this).toggleClass('ui-state-focus');
			}).focusout(function(){
			jQuery(this).toggleClass('ui-state-focus');
			}).hover(function(){
			jQuery(this).addClass('ui-state-hover');
			},function(){
			jQuery(this).removeClass('ui-state-hover');
			});
		//style the checkboxes using ui-icon
		form.find(':checkbox').addClass('ui-helper-hidden').after('<span class="ui-icon ui-icon-check" />').next().wrap("<div class='form-icon ui-state-default ui-corner-all' />").parent().hover(function(){
			jQuery(this).addClass('ui-state-hover');
			},function(){
			jQuery(this).removeClass('ui-state-hover');
			}).click(function(){
			jQuery(this).toggleClass("ui-state-active");
			jQuery(this).prev().click();
			});
		//style the radio buttons using ui-icons
		form.find(':radio').addClass('ui-helper-hidden').after('<span class="ui-icon ui-icon-radio-off" />').next().wrap("<div class='form-icon ui-state-default ui-corner-all' />").parent().hover(function(){
			jQuery(this).addClass('ui-state-hover');
			},function(){
			jQuery(this).removeClass('ui-state-hover');
			}).click(function(){
			form.find(':radio').next().removeClass('ui-state-active').children().removeClass('ui-icon-bullet').addClass('ui-icon-radio-off');
			jQuery(this).addClass('ui-state-active').children().addClass("ui-icon-bullet").removeClass('ui-icon-radio-off');
			jQuery(this).prev().click();
			}).mousedown(function(){jQuery(this).addClass('ui-state-highlight');}).mouseup(function(){jQuery(this).removeClass('ui-state-highlight');});
			}}
			
		jQuery(document).ready(function(){
		
		jQuery('div.bvdwidget, div#sliding_cart, div.textwidget').prev().addClass('ui-widget-header ui-corner-top bible-header');
		jQuery('div.bvdwidget, div#sliding_cart, div.textwidget').wrap('<div class="bible-all ui-widget ui-corner-all ui-widget-content" />');
		jQuery('div.bvdwidget').parent().prepend(jQuery('div.bvdwidget').parent().prev());
		jQuery('div.textwidget').parent().prepend(jQuery('div.textwidget').parent().prev());
		jQuery('div#sliding_cart').parent().prepend(jQuery('div#sliding_cart').parent().prev());
		
		
	
		
		jQuery('ul.menu > li').animate({opacity: .9}, "fast");
	
		jQuery('ul.menu > li').hover(function() {
			jQuery(this).animate({opacity: 1}, "fast");
			}, function() {
			jQuery(this).animate({opacity: .9}, "fast");
		});	
		
		jQuery('h1 > a, h2 > a, h3 > a').hover(function() {
			jQuery(this).animate({opacity: .7}, "fast");
			}, function() {
			jQuery(this).animate({opacity: 1}, "fast");
		});	
	
	
		var hash = window.location.hash.substr(1);
		if(hash !== null){
		jQuery('ul.menu > li.lnk > a').each(function(){
			var href = jQuery(this).attr('href');
			if(hash===href){
				var toLoad = hash+' #content';
				jQuery('#contentholder').load(toLoad, function(){
					jquiform();
					})
				}
			});
			}
	
								
	
	function randombg(){
		var randomnumber=Math.floor(Math.random()*3);
		jQuery('div.main-page').css('background-image','url(http://www.shaunp.co.za/wp-content/themes/shaun_p/images/back-image' + randomnumber + '.jpg)');
		}


	
	jQuery('ul.menu > li.lnk > a').click(function(){
								  
		var toLoad = jQuery(this).attr('href')+' #content';
		jQuery('#content').fadeOut('slow', loadContent);
		jQuery('#load').remove();
		jQuery('#contentholder').prepend('<div id="load"><img src="http://www.shaunp.co.za/wp-content/themes/shaun_p/images/47.gif" /></div>');
		jQuery('#load').fadeIn('normal');
		window.location.hash = jQuery(this).attr('href');
		function loadContent() {
			jQuery('#contentholder').load(toLoad, function() {
				jQuery('#content').fadeIn(1000);
				jquiform();
				//jQuery('div.gallery > dl > dt > a').colorbox();
				jQuery('#load').fadeOut('normal');
				randombg();
			});	
		}
	
		
		return false;
		
	});

            	jQuery('ul.menu > li.lnkhome > a').click(function(){

		var toLoad = jQuery(this).attr('href')+' #content';
		jQuery('#content').fadeOut('slow', loadContent);
		jQuery('#load').remove();
		jQuery('#contentholder').prepend('<div id="load"><img src="http://www.shaunp.co.za/wp-content/themes/shaun_p/images/47.gif" /></div>');
		jQuery('#load').fadeIn('normal');
		window.location.hash = jQuery(this).attr('href');
		function loadContent() {
			jQuery('#contentholder').load(toLoad, function() {
				jQuery('#content').fadeIn(1000);
				jquiform();
				//jQuery('div.gallery > dl > dt > a').colorbox();
				jQuery('#load').fadeOut('normal');
				jQuery('div.main-page').css('background-image','');
			});
		}


		return false;

	});
	
	
	//jQuery('div.gallery > dl > dt > a').colorbox();
	jquiform();
    jQuery('button, input:submit').button();
	
	});
