// JavaScript Document
(function($) {
		  
      
// body id
	$(function() {
		var page = '';
		if (/^http:\/\/([^\/]+\/)+$/.test(window.location.href)) {
			page = 'index';
		} else {
			page = (window.location.href).replace(/^http.+\/(?:[^\/]+\/)*([^\/]+)\.shtml$/, '$1');
		}
		$('body').attr('id', page);
	});
// end body id
		  
// menu
	$(document).ready(function(){
		jqueryslidemenu.buildmenu("main-menu-line", arrowimages)
	});
// end menu

// png fix
	$(document).ready(function(){ 
		$(document).pngFix(); 
	}); 
// end png fix

// clickdown
	$(document).ready(function($) {
		$('a.clickdown').each(function() {
			var $this = $(this);
			var index = $this.attr('id').match(/(\d+)$/, '');
			var number = parseInt(index[1]);
			$this.click(function() {
				$('#slickbox' + number).slideToggle(400);
				$this.toggleClass('opened').blur();
				return false;
			});
		});
	});
// end clickdown

// stripy table
	$(document).ready(function(){
		makeStripy('stripy', 'oddrows', 'evenrows');
	}); 
// end stripy table

// form
	$.validator.addMethod('hintText', function(value, element, hint) {
		var $elm = $(element);
		if ($.trim(value) == $.trim(hint)) {
			$elm.val('');
		}
		if ($elm.hasClass('required') && $elm.val() == '') {
			return false;
		}
		return true;
	}, 'This field is required.');
	
	function fillEmptyHints() {
		$('#contact_us_form .useHint').each(function() {
			var $elm = $(this);
			var hint = $elm.metadata().hintText;
			if ($elm.val() == '' && hint) {
				$elm.val(hint);
			}
		});
	}

	$(document).ready(function() {
		$('#contact_us_form').validate({
			submitHandler: function(form) {
				$('#ajax_loader').show();
				$('#invalid_captcha').hide();
				$(form).ajaxSubmit(function(response) {
					$('#ajax_loader').hide();
					if (response == 'captcha') {
						$('#invalid_captcha').show();
						fillEmptyHints();
					} else {
						$('#email_sent').show();
						$('#submit').attr('disabled', true);
						window.setTimeout('window.location.reload(true)', 5000);
					}
				});
			},
			rules: { // 'required' rules should not be used because of using the metadata's method "hintText" instead
//				'contact-name': 'required',
//				'telephone-number': 'required',
//				'captcha': 'required'
			}
		});
	});
// end form

// captcha
	$(document).ready(function() {
		$('#captcha_input').val('');
		$('<img src="scripts/captcha.php?'+Math.random()+'" title="Click to change captcha" alt="Click to change captcha" />').appendTo('#captcha_td').click(function(e){ $(e.target).attr('src', 'scripts/captcha.php?'+Math.random()) });
	});
// end captcha

// show hint texts for empty input fields
	$(document).ready(function() {
		if ($('#contact_us_form .useHint').length > 0) {
			$('#contact_us_form .useHint').hint();
		}
	});
//

// home gallery
	$(document).ready(function($) {
		// We only want these styles applied when javascript is enabled
//		$('div.navigation').css({'width' : '390px', 'float' : 'right'});
		$('div.content').css('display', 'block');

		// Initially set opacity on thumbs and add
		// additional styling for hover effect on thumbs
		var onMouseOutOpacity = 0.67;
		$('#thumbs ul.thumbs li').opacityrollover({
			mouseOutOpacity:   onMouseOutOpacity,
			mouseOverOpacity:  1.0,
			fadeSpeed:         'fast',
			exemptionSelector: '.selected'
		});
		onMouseOutOpacity = 1;
		$('#gallery-identity-thumbs ul.thumbs li').opacityrollover({
			mouseOutOpacity:   onMouseOutOpacity,
			mouseOverOpacity:  1.0,
			fadeSpeed:         'fast',
			exemptionSelector: '.selected'
		});
		onMouseOutOpacity = 1;
		$('#graphic1-thumbs ul.thumbs li').opacityrollover({
			mouseOutOpacity:   onMouseOutOpacity,
			mouseOverOpacity:  1.0,
			fadeSpeed:         'fast',
			exemptionSelector: '.selected'
		});
		onMouseOutOpacity = 1;
		$('#graphic2-thumbs ul.thumbs li').opacityrollover({
			mouseOutOpacity:   onMouseOutOpacity,
			mouseOverOpacity:  1.0,
			fadeSpeed:         'fast',
			exemptionSelector: '.selected'
		});
		// Initialize Advanced Galleriffic Gallery
        if ($('#thumbs, #graphic1-thumbs, #graphic2-thumbs, #gallery-identity-thumbs').length > 0) {
            var gallery = $('#thumbs, #graphic1-thumbs, #graphic2-thumbs, #gallery-identity-thumbs').galleriffic({
				delay:                     2500,
				numThumbs:                 30,
				preloadAhead:              10,
				enableTopPager:            true,
				enableBottomPager:         true,
				maxPagesToShow:            7,
				imageContainerSel:         '#slideshow',
				controlsContainerSel:      '#controls',
				captionContainerSel:       '#caption',
				loadingContainerSel:       '#loading',
				renderSSControls:          true,
				renderNavControls:         true,
				playLinkText:              'Play Slideshow',
				pauseLinkText:             'Pause Slideshow',
				prevLinkText:              '&lsaquo; Previous Photo',
				nextLinkText:              'Next Photo &rsaquo;',
				nextPageLinkText:          'Next &rsaquo;',
				prevPageLinkText:          '&lsaquo; Prev',
				enableHistory:             false,
				enableKeyboardNavigation:  false,
				autoStart:                 false,
				syncTransitions:           true,
				defaultTransitionDuration: 900,
				onSlideChange:             function(prevIndex, nextIndex) {
					// 'this' refers to the gallery, which is an extension of $('#thumbs')
					this.find('ul.thumbs').children()
						.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
						.eq(nextIndex).fadeTo('fast', 1.0);
				},
				onPageTransitionOut:       function(callback) {
					this.fadeTo('fast', 0.0, callback);
				},
				onPageTransitionIn:        function() {
					this.fadeTo('fast', 1.0);
				}
			});
		}
	});
// end home gallery


})(jQuery);

document.write('<' + 'style type="text/css">.noscript { display: none; }<' + '/style>');

$(function() {
 
  var url = location.pathname;
 
  if(url.indexOf('index') > -1) {
    $("body").attr("class","#index");
  }
 
  if(url.indexOf('our-portfolio') > -1) {
    $("body").attr("class","#portfolio_websites");
  }
 
  if(url.indexOf('website-development') > -1) {
    $("body").attr("class","#website-development");
  }
	
  if(url.indexOf('ecommerce') > -1) {
    $("body").attr("class","#website-development");
  }
});
