/*hoverIntent*/(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
/*navigator*/(function(d){function o(g,a){var b=d(a);return b.length<2?b:g.parent().find(a)}function m(g,a){var b=this,q=g.add(b),j=g.children(),k=0,n=a.vertical;f||(f=b);if(j.length>1)j=d(a.items,g);d.extend(b,{getConf:function(){return a},getIndex:function(){return k},getSize:function(){return b.getItems().size()},getNaviButtons:function(){return p.add(h)},getRoot:function(){return g},getItemWrap:function(){return j},getItems:function(){return j.children(a.item).not("."+a.clonedClass)},move:function(c,e){return b.seekTo(k+ c,e)},next:function(c){return b.move(1,c)},prev:function(c){return b.move(-1,c)},begin:function(c){return b.seekTo(0,c)},end:function(c){return b.seekTo(b.getSize()-1,c)},focus:function(){return f=b},addItem:function(c){c=d(c);if(a.circular){j.children("."+a.clonedClass+":last").before(c);j.children("."+a.clonedClass+":first").replaceWith(c.clone().addClass(a.clonedClass))}else j.append(c);q.trigger("onAddItem",[c]);return b},seekTo:function(c,e,l){c.jquery||(c*=1);if(a.circular&&c===0&&k==-1&&e!== 0)return b;if(!a.circular&&c<0||c>b.getSize()||c<-1)return b;var r=c;if(c.jquery)c=b.getItems().index(c);else r=b.getItems().eq(c);var u=d.Event("onBeforeSeek");if(!l){q.trigger(u,[c,e]);if(u.isDefaultPrevented()||!r.length)return b}r=n?{top:-r.position().top}:{left:-r.position().left};k=c;f=b;if(e===undefined)e=a.speed;j.animate(r,e,a.easing,l||function(){q.trigger("onSeek",[c])});return b}});d.each(["onBeforeSeek","onSeek","onAddItem"],function(c,e){d.isFunction(a[e])&&d(b).bind(e,a[e]);b[e]=function(l){l&& d(b).bind(e,l);return b}});if(a.circular){var t=b.getItems().slice(-1).clone().prependTo(j),s=b.getItems().eq(1).clone().appendTo(j);t.add(s).addClass(a.clonedClass);b.onBeforeSeek(function(c,e,l){if(!c.isDefaultPrevented())if(e==-1){b.seekTo(t,l,function(){b.end(0)});return c.preventDefault()}else e==b.getSize()&&b.seekTo(s,l,function(){b.begin(0)})});b.seekTo(0,0,function(){})}var p=o(g,a.prev).click(function(){b.prev()}),h=o(g,a.next).click(function(){b.next()});if(!a.circular&&b.getSize()>1){b.onBeforeSeek(function(c, e){setTimeout(function(){if(!c.isDefaultPrevented()){p.toggleClass(a.disabledClass,e<=0);h.toggleClass(a.disabledClass,e>=b.getSize()-1)}},1)});a.initialIndex||p.addClass(a.disabledClass)}a.mousewheel&&d.fn.mousewheel&&g.mousewheel(function(c,e){if(a.mousewheel){b.move(e<0?1:-1,a.wheelSpeed||50);return false}});if(a.touch){var i={};parseInt(j[0]).ontouchstart=function(c){c=c.touches[0];i.x=c.clientX;i.y=c.clientY};parseInt(j[0]).ontouchmove=function(c){if(c.touches.length==1&&!j.is(":animated")){var e= c.touches[0],l=i.x-e.clientX;e=i.y-e.clientY;b[n&&e>0||!n&&l>0?"next":"prev"]();c.preventDefault()}}}a.keyboard&&d(document).bind("keydown.scrollable",function(c){if(!(!a.keyboard||c.altKey||c.ctrlKey||d(c.target).is(":input")))if(!(a.keyboard!="static"&&f!=b)){var e=c.keyCode;if(n&&(e==38||e==40)){b.move(e==38?-1:1);return c.preventDefault()}if(!n&&(e==37||e==39)){b.move(e==37?-1:1);return c.preventDefault()}}});a.initialIndex&&b.seekTo(a.initialIndex,0,function(){})}d.tools=d.tools||{version:"1.2.5"}; d.tools.scrollable={conf:{activeClass:"active",circular:false,clonedClass:"cloned",disabledClass:"disabled",easing:"swing",initialIndex:0,item:null,items:".items",keyboard:true,mousewheel:false,next:".next",prev:".prev",speed:400,vertical:false,touch:true,wheelSpeed:0}};var f;d.fn.scrollable=function(g){var a=this.data("scrollable");if(a)return a;g=d.extend({},d.tools.scrollable.conf,g);this.each(function(){a=new m(d(this),g);d(this).data("scrollable",a)});return g.api?a:this}})(jQuery); (function(d){var o=d.tools.scrollable;o.autoscroll={conf:{autoplay:true,interval:3E3,autopause:true}};d.fn.autoscroll=function(m){if(typeof m=="number")m={interval:m};var f=d.extend({},o.autoscroll.conf,m),g;this.each(function(){var a=d(this).data("scrollable");if(a)g=a;var b;a.play=function(){b||(b=setInterval(function(){a.next()},f.interval))};a.pause=function(){b=clearInterval(b)};a.stop=function(){a.pause()};f.autopause&&a.getRoot().add(a.getNaviButtons()).hover(a.pause,a.play);f.autoplay&&a.play()}); return f.api?g:this}})(jQuery); (function(d){function o(f,g){var a=d(g);return a.length<2?a:f.parent().find(g)}var m=d.tools.scrollable;m.navigator={conf:{navi:".navi",naviItem:null,activeClass:"active",indexed:false,idPrefix:null,history:false}};d.fn.navigator=function(f){if(typeof f=="string")f={navi:f};f=d.extend({},m.navigator.conf,f);var g;this.each(function(){function a(h,i,c){k.seekTo(i);if(p){if(location.hash)location.hash=h.attr("href").replace("#","")}else return c.preventDefault()}function b(){return n.find(f.naviItem||"> *")} function q(h){var i=d("<"+(f.naviItem||"a")+"/>").click(function(c){a(d(this),h,c)}).attr("href","#"+h);h===0&&i.addClass(s);f.indexed&&i.text(h+1);f.idPrefix&&i.attr("id",f.idPrefix+h);return i.appendTo(n)}function j(h,i){h=b().eq(i.replace("#",""));h.length||(h=b().filter("[href="+i+"]"));h.click()}var k=d(this).data("scrollable"),n=f.navi.jquery?f.navi:o(k.getRoot(),f.navi),t=k.getNaviButtons(),s=f.activeClass,p=f.history&&d.fn.history;if(k)g=k;k.getNaviButtons=function(){return t.add(n)};b().length? b().each(function(h){d(this).click(function(i){a(d(this),h,i)})}):d.each(k.getItems(),function(h){q(h)});k.onBeforeSeek(function(h,i){setTimeout(function(){if(!h.isDefaultPrevented()){var c=b().eq(i);!h.isDefaultPrevented()&&c.length&&b().removeClass(s).eq(i).addClass(s)}},1)});k.onAddItem(function(h,i){i=q(k.getItems().index(i));p&&i.history(j)});p&&b().history(j)});return f.api?g:this}})(jQuery);

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
/* custom */


WebFontConfig = {
	google: { families: [ 'Old+Standard+TT:latin' ] }
};

(function() {
	var wf = document.createElement('script');
	wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
	wf.type = 'text/javascript';
	wf.async = 'true';
	var s = document.getElementsByTagName('script')[0];
	s.parentNode.insertBefore(wf, s);
})();

function loginFocus(oFld, sTxt) {
	var val = oFld.value, sId = "#" + oFld.id, text = sTxt;
	if (val.toLowerCase()==text.toLowerCase()) {
		$(sId).val('');
		$(sId).removeClass("greyText");
	}
}

function loginBlur(oFld, sTxt) {
	var val = oFld.value, sId = "#" + oFld.id, text = sTxt;
	if (val=="") oFld.value = text;
	if (oFld.value.toLowerCase()==text.toLowerCase()) {
		$(sId).addClass("greyText");
	}
}

function expandClick(txt) {
	var id = document.getElementById(txt);
	if (id) {
		if (id.style.display=="")
			id.style.display = "none";
		else {
			id.style.display = "";
		}
	}
}
function invalidCaptcha() {
	document.getElementById("feedbackerr").style.display = "";
	document.getElementById("systheform").style.display = "";
	sysReloadCa();
}

function sysReloadCa() {
	document.getElementById('syscaimg').src='/caimage.asp?' + Date();
}

function ChkallTlds(allt) {
	var row, i, aRows = document.getElementsByTagName("input"), allt = document.getElementById("allTlds");
	for (i=0;i<aRows.length;i++) {
		row = aRows[i].id;
		if (row.substr(0,4)=="chk."){
			if (allt.checked)
				aRows[i].checked=true;
			else
				aRows[i].checked=false;
		}
	}
	return true;
}

function changeLogin(sId) {
	var frm = "#" + sId + "form";
	$(".login-box").find("a").removeClass("selected");
	$(".login-box").find("form").hide(0);
	$("#"+sId).addClass("selected");
	$(frm).show(0);
	
}
function checkDefaultValue(sId,sValue){
	if(sId.value==sValue){
		sId.value=""
	} else if(sId.value=="") {
		sId.value=sValue
	}
}

$(document).ready(function() {
	var formErrors, captchaError;
	
	function emailValid(value) {
		return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);
	}
	function switchSlide(sSource){
		$('#main-video param[name=flashvars]').attr('value',sSource);
	}
	
	$("#menu-main").removeClass("non-js");
	
	var menuConfig = {    
		over: function(){$(this).addClass("current").find(".sub").slideDown("normal")},
		timeout: 0,
		out: function(){$(this).removeClass("current").find(".sub").slideUp("fast")},
		interval: 25,
		sensitivity: 1
	};
	$("#menu-main li").hoverIntent(menuConfig);

	var dropBoxConfig = {    
		over: function(){$(this).stop().addClass("dropped").animate({ top: 0 }, 'normal')},
		timeout: 0,
		out: function(){$(".point .arrow").stop().animate({ top: -161 }, 'normal').removeClass("dropped")},
		interval: 0,
		sensitivity: 1
	};
	$(".arrow").hoverIntent(dropBoxConfig);
	
	$("#contact-us").submit(function(event){
		lFormErrors = false, lCaptchaError = false;
		
		$("#error-log span").hide().html("");
		
		$(".req-field").each(function() {
			if ($(this).val()=="") {
				$(this).addClass("req-missing");
				lFormErrors = true;
			} else {
				$(this).removeClass("req-missing")
			}
		});
		
		if ($(".req-email").val()=="" || !emailValid($(".req-email").val())) {
			$(".req-email").addClass("req-missing");
			lFormErrors = true;
		} else {
			$(".req-email").removeClass("req-missing")
		}
		
		if ($("#recaptcha_response_field").val()=="") {
			$("#recaptcha_response_field").addClass("req-missing");
			lCaptchaError=true;
		} else {
			$("#recaptcha_response_field").removeClass("req-missing");
		}
		if (lFormErrors || lCaptchaError) {
			$("#error-log span").fadeIn("slow").append("Whoops, it seems like you missed a few required fields.");
			return false;
		} else {
			return true;	
		}
	});

	$(".req-field").blur(function() {
		if($(this).val()!="") {$(this).removeClass("req-missing")}
	})
	
	$(".presentation-video").click(function(event){
		event.preventDefault()
		$("#video-frame").attr("src","/includes/getSilverlight.asp?f="+ $(this).attr("id"))
	})
});

function toggleSummary() {
	$(".previousYear").toggle();
	if ($("#summaryHeader").html() == "(more)")
		$("#summaryHeader").html("(less)");
	else
		$("#summaryHeader").html("(more)");
}	

function checkAction(frm) {
	if (confirm("Save your action to the database?")) 
		$("#" + frm).submit();
	else
		$("#" + frm).each (function() {this.reset();});
}

function submitForm(frm) {
	$("#" + frm).submit();	
}

function showMoreOptions() {
	$(".queryOptions").toggle();
	if ($("#moreOptions").html()=="hide options")
		$("#moreOptions").html("more options");
	else
		$("#moreOptions").html("hide options");
}

function DateAdd(objDate, strInterval, intIncrement) {
	if(typeof(objDate) == "string")
	{
		objDate = new Date(objDate);

		if (isNaN(objDate))
		{
			throw("DateAdd: Date is not a valid date");
		}
	}
	else if(typeof(objDate) != "object" || objDate.constructor.toString().indexOf("Date()") == -1)
	{
		throw("DateAdd: First parameter must be a date object");
	}

	if(
	strInterval != "M"
	&& strInterval != "D"
	&& strInterval != "Y"
	&& strInterval != "h"
	&& strInterval != "m"
	&& strInterval != "uM"
	&& strInterval != "uD"
	&& strInterval != "uY"
	&& strInterval != "uh"
	&& strInterval != "um"
	&& strInterval != "us"
	)
	{
		throw("DateAdd: Second parameter must be M, D, Y, h, m, uM, uD, uY, uh, um or us");
	}

	if(typeof(intIncrement) != "number")
	{
		throw("DateAdd: Third parameter must be a number");
	}

	switch(strInterval)
	{
		case "M":
		objDate.setMonth(parseInt(objDate.getMonth()) + parseInt(intIncrement));
		break;

		case "D":
		objDate.setDate(parseInt(objDate.getDate()) + parseInt(intIncrement));
		break;

		case "Y":
		objDate.setYear(parseInt(objDate.getYear()) + parseInt(intIncrement));
		break;

		case "h":
		objDate.setHours(parseInt(objDate.getHours()) + parseInt(intIncrement));
		break;

		case "m":
		objDate.setMinutes(parseInt(objDate.getMinutes()) + parseInt(intIncrement));
		break;

		case "s":
		objDate.setSeconds(parseInt(objDate.getSeconds()) + parseInt(intIncrement));
		break;

		case "uM":
		objDate.setUTCMonth(parseInt(objDate.getUTCMonth()) + parseInt(intIncrement));
		break;

		case "uD":
		objDate.setUTCDate(parseInt(objDate.getUTCDate()) + parseInt(intIncrement));
		break;

		case "uY":
		objDate.setUTCFullYear(parseInt(objDate.getUTCFullYear()) + parseInt(intIncrement));
		break;

		case "uh":
		objDate.setUTCHours(parseInt(objDate.getUTCHours()) + parseInt(intIncrement));
		break;

		case "um":
		objDate.setUTCMinutes(parseInt(objDate.getUTCMinutes()) + parseInt(intIncrement));
		break;

		case "us":
		objDate.setUTCSeconds(parseInt(objDate.getUTCSeconds()) + parseInt(intIncrement));
		break;
	}
	return objDate;
}
