$(document).ready(function () {
	$.externallinks();
	//******************** Toggle sidebar snippets *******************/
	var titleCss = "rhsTitle";
	var titleOpenCss = 'on';
	var contentCss = "rhsContent";
	$('div.' + titleCss).click(function () {
		if ($(this).hasClass(titleOpenCss)) {
			$(this).removeClass(titleOpenCss);
			$(this).next('div.' + contentCss).hide();
		}
		else {
			$(this).next('div.' + contentCss).slideDown(100);
			$(this).addClass(titleOpenCss);
		}
	});
	// **************** form validation ************************/
	$("#contactusForm").validate({
		rules: {
			name: "required",
			phone: "required",
			email: {
				required: true,
				email: true
			},
			subject: "required",
			comment: "required"
		},
		messages: {
			name: "Please enter your name",
			phone: "Please enter your contact number",
			subject: "This field is required",
			comment: "Please type something to submit",
			email: "Please enter a valid email address"
		}
	});

	/******************* top navigation menu *******************/
	$('#topNavi ul li a').addClass("topNavColorJs");
	$('#topNavi ul li a.on').removeClass("topNavColorJs");
	$('#topNavi ul li a.navijs').hover(
        function () {
        	$('#topNavi ul li a').addClass("topNavColorJs");
        	$('#topNavi ul li a.on').removeClass("topNavColorJs");
        	$('.topSubNavi:visible').hide();
        	$('div[title="' + $(this).attr('id') + '"]').show();
        	$(this).removeClass("topNavColorJs");

        },
        function () {
        }
    );
	$('#topNavi ul li a.first').hover(
        function () {
        	$('#topNavi ul li a').addClass("topNavColorJs");
        	$('#topNavi ul li a.on').removeClass("topNavColorJs");
        	$(this).removeClass("topNavColorJs");
        	$('.topSubNavi:visible').hide();
        	$('div.current').show();
        },
        function () {
        }
    );
	/****************** Switch style **************************/
	$('.styleswitch').click(function () {
		switchStylestyle(this.getAttribute("rel"));
		return false;
	});
	var c = readCookie('style');
	if (c) switchStylestyle(c);
	/***************** Scroll text/images ***********************/
	jQuery("#scrolltext div.hide").removeClass("hide");
	jQuery('#scrolltext').cycle({ fx: 'scrollUp', delay: -2000, timeout: 5000 });
	jQuery('#scrolltext').hover(function () { jQuery(this).cycle('pause'); }, function () { jQuery(this).cycle('resume'); });
	jQuery("#mainBarnerScroll div.hide").removeClass("hide");
	jQuery('#mainBarnerScroll').cycle({ fx: 'fade', speed: 3000 });
	jQuery('#mainBarnerScroll').hover(function () { jQuery(this).cycle('pause'); }, function () { jQuery(this).cycle('resume'); });
	jQuery('#scorllRssClips').serialScroll({
		items: 'li',
		prev: '.rssClip a#arrowpre',
		next: '.rssClip a#arrownext',
		axis: 'x',
		offset: 0, //when scrolling to photo, stop 230 before reaching it (from the left)
		start: 0, //as we are centering it, start at the 2nd
		duration: 680,
		force: true,
		stop: true,
		lock: false,
		cycle: true, //don't pull back once you reach the end
		//easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: false //click on the images to scroll to them
	});
});

$.externallinks = function () {
	$('a[href^="http://"]').attr({
		target: "_blank",
		title: function (arr) {
			if ($(this).attr("title") != null && $(this).attr("title").length > 0) {
				$(this).attr("title", $(this).attr("title") + " (opens in a new window)");
			}
			else {
				$(this).attr("title", "opens in a new window");
			}
		}
	});
}
