$(document).ready(function() {

	/* Cufon.replace('h3', {hover: true});	 */


	/* login labels */

	$("#login input").ezpz_hint();

		
	/* Client Login */
	
	$("#login_btn a").click(function () { 
		jQuery.easing.def = "easeInOutCubic";
		$("#login").fadeIn(400);
		$("#login_btn a").hide();
  	});

	$("#cancel a").click(function () { 
		jQuery.easing.def = "easeInOutCubic";
		$("#login").fadeOut(400);
		$("#login_btn a").fadeIn(400);
  	});
		

	/* Small Screen Fix */

	navposition = function() {
		if( $(window).height() < 600 || $(window).width() < 900 ) {
			$("#sidebar").css("position", "absolute");
		} else {
			if( $.browser.msie ) {
				// IF IE
				if( $.browser.version.substr(0,1) == "6") {
					// IF IE 6
					$("#sidebar").css("position", "absolute"); }
				else {
					// IF OTHER THAN IE 6
					$("#sidebar").css("position", "fixed");
				}
			} else {
				// IF NOT IE
				$("#sidebar").css("position", "fixed");
			}
		}				
	}
				
	$(window).resize( function() {
		navposition();
	});

	navposition();


	/* Contact Form */
	
	var options = { target:'#alert' };
	$('#contact_form').ajaxForm(options);	
	
	$.fn.clearForm = function() {
	  return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form')
		  return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea')
		  this.value = '';
		else if (type == 'checkbox' || type == 'radio')
		  this.checked = false;
		else if (tag == 'select')
		  this.selectedIndex = -1;
	  });
	};

	
	/* FancyBox */
	
	$("a.fancybox").fancybox();
	
/*
	$("a.fancybox").fancybox({
		'zoomSpeedIn':500,
		'zoomSpeedOut':500,
		'overlayShow':true,
	  	easingIn:'easeInOutCirc', 
		easingOut:'easeInOutCirc', 
		easingChange:'easeInOutCirc',
		hideOnContentClick:true,
		zoomOpacity:true,
		imageScale:true
	});
*/

	$("a#fancybox_penta").fancybox({
		hideOnContentClick:false,
		'frameWidth': 480, 
        'frameHeight': 380
	});
	
	$("a#fancybox_connected").fancybox({
		hideOnContentClick:false,
		'frameWidth': 725, 
        'frameHeight': 325
	});
	
	$("a#fancybox_mobile").fancybox({
		hideOnContentClick:false,
		'frameWidth': 807, 
        'frameHeight': 350
	});

	$("a#fancybox_spectroniq").fancybox({
		hideOnContentClick:false,
		'frameWidth': 526, 
        'frameHeight': 208
	});
	

	
	/* Page Scroll */
	
	function filterPath(string) {
	return string
		.replace(/^\//,'')
		.replace(/(index|default).[a-zA-Z]{3,4}$/,'')
		.replace(/\/$/,'');
	}
	
	var locationPath = filterPath(location.pathname);
	$('a[href*=#nav]').each(function() {
		var thisPath = filterPath(this.pathname) || locationPath;
		if (  locationPath == thisPath
		&& (location.hostname == this.hostname || !this.hostname)
		&& this.hash.replace(/#/,'') ) {
			var $target = $(this.hash), target = this.hash;
			if (target) {
				var targetOffset = $target.offset().top;
				$(this).click(function(event) {
					event.preventDefault();
					$('html, body').animate({scrollTop: targetOffset}, 600, 'easeInOutCubic', function() {
						location.hash = target;
					});
				});
			}
		}
	});
});


