function addMega(){$(this).addClass("hovering");}
function removeMega(){$(this).removeClass("hovering");}
var megaConfig = { interval: 100, sensitivity: 4, over: addMega, timeout: 100, out: removeMega };

/* onLoad code STARTS */
$(document).ready(function(){
	
	/* Homepage */
	$("#home .accordion").accordion({fillSpace: true});
	$("#reviews .review_main").hide(); // hide all
	$("#reviews .review_main:first").show(); // show first one only
	$("#review_categories a:first").addClass("active");
	$("#review_categories a").click(function() {
		$("#review_categories a").removeClass("active");
		$(this).addClass("active");
		$("#review_categories a").css("border-right-width", "1px");
		$(this).css("border-right-width", "0");
		$("#reviews .review_main").hide(); // hide all
		$("#reviews " + this.hash).show();
		return false;
	});
	// extra review hide/show
	$("#reviews .review_extra").each(function(){
		$(this).children("ul").children("li:first").children("div").show();
		$(this).children("ul").children("li:first").children("span").css('background-position', '-10px 50%');
	});
	$("#reviews .review_extra ul li > a").click(function(){
		// if div is opened, follow link
		if( $(this).parent().children("div").css('display') == "block" )
		{
			// follow link
		}
		// else, default behaviour: hide/show
		else
		{
			$(this).parent().parent().parent().children("ul").children("li").children("div").hide();
			$(this).parent().parent().parent().children("ul").children("li").children("span").css('background-position', '0 50%');
			$(this).siblings("div").toggle();
			$(this).parent().children('span').css('background-position', '-10px 50%');
			return false;
		}
	});
	
	bestcat_scroller("#bestsellers", "#bestsellers_content", ".categorylisting");
	function bestcat_scroller (_ps,content_conveyor,e) {
		//vars
		var conveyor = $(content_conveyor, $(_ps));
		var item = $(e, $(_ps));
		var firstVisibleItem = $(e).filter(':visible:eq(0)');
		if(firstVisibleItem.length == 0) return;
		var itemWidth = parseInt(firstVisibleItem.outerWidth(true));
		//set length of conveyor
		conveyor.css("width", item.length * itemWidth);
		//config
		var sliderOpts = {
			max: (item.length * itemWidth) - parseInt($(_ps).css("width")),
			change: function(e, ui) {
				conveyor.animate({ left : "-" + ui.value + "px" }, 500);
			},
			step: itemWidth,
			animate: true
		};
		$(_ps).find(".slider").slider(sliderOpts);
		$(_ps).find(".btn-next").bind('click', function(){
			var curr_value = $(_ps).find(".slider").slider("value");
			$(_ps).find(".slider").slider("value", curr_value + itemWidth);
			return false;
		});
		$(_ps).find(".btn-prev").bind('click', function(){
			var curr_value = $(_ps).find(".slider").slider("value");
			$(_ps).find(".slider").slider("value", curr_value - itemWidth);
			return false;
		});
	};
	
	$('#featured_products, #best_discounts, #highest_ratings').click(function(){ show_recommendations(this); });	
	function show_recommendations(thisObject){		
		$('li[class*="selected_"]').each(function(){
			$(this).removeClass('selected_left selected_middle selected_right');
		});

		$('#featured_list, #discounts_list, #ratings_list').hide();

		if ($(thisObject).attr('id')=='featured_products'){
			selectedClass = 'selected_left';
			$('#featured_list').show();
		}
		else if ($(thisObject).attr('id')=='best_discounts'){
			selectedClass = 'selected_middle';
			$('#discounts_list').show();
		}
		else if ($(thisObject).attr('id')=='highest_ratings'){
			selectedClass = 'selected_right';
			$('#ratings_list').show();
		}

		$(thisObject).parent().parent().addClass(selectedClass);

		return false;
	}

	$('#recommendations_radio li input').click(function(){ change_recommendations(this); });
	function change_recommendations(thisObject){
		$('#recommendations_radio li input').prop('checked', false);
		$(thisObject).prop('checked', true);
		var type = $(thisObject).val();
		var category_name = $(thisObject).attr('alt');

		$('#top-discounts .box-inner h3').html('<span>Top Discounts In</span> ' + category_name);
		$('#popular-softwares .box-inner h3').html('<span>Popular In</span> ' + category_name);
		$('#top-fb-likes .box-inner .h3title').html('<span>Top Likes In</span> ' + category_name);

		$('#recommendations_tags li[class*="rtags_"]').hide();
		$('#recommendations_tags .rtags_'+type).show();

		$('#featured_list, #discounts_list, #ratings_list').mask("Loading...");

		$.ajax({
			type: 'POST',
			url: '/new_ajax/populate_featured_products/'+type,
			dataType: 'json',
			success: function (response){
				$('#featured_list').html(response['featured_list']);
				$('#discounts_list').html(response['discounts_list']);
				$('#ratings_list').html(response['ratings_list']);

				$('#top-discounts .box-inner .viewer .content-conveyor').html(response['top_discounts']);
				$('#popular-softwares .box-inner .viewer .content-conveyor').html(response['popular_softwares']);
				
				$('#top-fb-likes .box-inner .viewer').html(response['top_likes']);

				$('#featured_list, #discounts_list, #ratings_list').unmask("Loading...");

				$("#top-discounts .viewer, #popular-softwares .viewer").each(function() {
					$(this).find(".slider").slider({disabled:true});
					$(this).find(".btn-next").unbind();
					$(this).find(".btn-prev").unbind();

					product_scroller.init(this,".content-conveyor","ul.sidebar");
				});
				
				FB.XFBML.parse();
			}
		});
		
		return false;
	}

	/* search page */
	var cache = {};
	$("#search_simple, #contribute_search").autocomplete({
		minLength: 3,
		source: function(request, response) {
			if ( request.term in cache ) {
				response( cache[ request.term ] );
				return;
			}
			$.ajax({
				url: "/s/autocomplete/"+request.term,
				dataType: "json",
				success: function( data ) {
					cache[ request.term ] = data;
					response( data );
				}
			});
		},
		focus: function(event, ui) {
			$(this).val(ui.item.label);
			return false;
		},
		select: function(event, ui) {
			$(this).val(ui.item.label);
			window.location = ui.item.value;
			return false;
		}
	});

	/* Software Updater Scan Results Page */
	/* $('input.scanRating').rating({
		required: true,
		focus: function(value, link){
			// var tip = $(this).parent().children('.rating_tip');
			// tip[0].data = tip[0].data || tip.html();
			// tip.html(link.title || 'value: '+value);
		},
		blur: function(value, link){
			// var tip = $(this).parent().children('.rating_tip');
			// tip.html(tip[0].data || '');
		},
		callback: function(value, link){			
			
			// var tip = $(this).parent().children('.rating_tip');
			// tip[0].data = tip[0].data || tip.html();
			// tip.html('Rating submitted');

			var unique_product_id = $(this).parent().children('input[name="unique_product_id"]').val();
			var scan_item_id = $(this).parent().children('input[name="ItemId"]').val();
			
			$('#scan_item_'+scan_item_id+' .info_container .review .item_rating').val(value);

			$.ajax({
				type: 'POST',
				url: '/updater/rate',
				dataType: 'json',
				data: {unique_product_id: unique_product_id, rating: value}
			});

			// $(this).parent().html('<div style="line-height:1.5em;"><span class="rating-large2"><span class="stars2" style="width: '+(value*20)+'%;">'+value+'.00 stars</span></span> Thanks!</div>');
			$(this).parent().html('<div style="line-height:1.5em;"><span class="rating-large2"><span class="stars2" style="width: '+(value*20)+'%;">'+value+'.00 stars</span></span></div>');
		}
	}); */	

	/* Product page */
	$('#coupons .moreCommentsLink').live('click', function(){
		$(this).parent().siblings('.moreCommentsBox').slideToggle(); return false;
	});
	$('#coupons .collapseCRB').live('click', function(){
		$(this).parent().siblings('.coupon_add').fadeOut(); $(this).parent('.telltheworld').fadeOut(); return false;
	});
	$('#coupons .comment').live('keyup', function() {
		var label = $(this).siblings('.comment_strlen'),limit = 250,input = $(this).val(),input_length = input.length;
		if( input_length > limit) { $(label).html("(You cannot write more than "+limit+" characters!)"); $(this).val(input.substr(0,limit)); return false; }
		else { $(label).html("(You have "+(limit-input_length)+" characters left)"); return true; }
	});
	
	/* Product page 'GoTo' functions (open correct tab and scroll to content) */
	$('.gotoReview').click(function(){
		$("a[href='#user']").click(); // simulate tab click
		window.location.href = '#user';
		return false;
	});
	$('.gotoWriteReview').click(function(){
		$("a[href='#user']").click(); // simulate tab click
		window.location.href = '#writeReview';
		return false;
	});
	
	/* direct rating */
	$('.directRating').rating({
		required: true,
		focus: function(value, link){
			var tip = $('#directRatingTip');
			if(tip[0])
			{
				tip[0].data = tip[0].data || tip.html();
				tip.html(link.title || 'value: '+value);
			}
		},
		blur: function(value, link){
			var tip = $('#directRatingTip');
			if(tip[0])
			{
				$('#directRatingTip').html(tip[0].data || '');
			}
		},
		callback: function(value, link){
			$(this.form).ajaxSubmit({
				target: '#directRatingTip'
			});
			//$('.directRating').rating('disable');
			//$('#directRatingTip').html('Thanks!');
			$('#directRatingForm').html('<div style="line-height:1.5em;"><span class="rating-large"><span class="stars" style="width: '+(value*20)+'%;">'+value+'.00 stars</span></span> Thanks!</div>');
			var offset = $("#reviewForm").offset();
			$("html, body").delay(750).animate({scrollTop: offset.top}, 1500);
		}
	});
	
	/* Product page user review form handling */
	$('#review_advantages').keyup(function(){ limitChars('review_advantages', 1000, 'review_advantages_strlen') });
	$('#review_disavantages').keyup(function(){ limitChars('review_disavantages', 1000, 'review_disavantages_strlen') });
	$('#review_overall').keyup(function(){ limitChars('review_overall', 80, 'review_overall_strlen') });
	
	/* review rating */
	$('input.starRating').rating({
		required: true,
		focus: function(value, link){
			var tip = $('#ratingTip');
			tip[0].data = tip[0].data || tip.html();
			tip.html(link.title || 'value: '+value);
		},
		blur: function(value, link){
			var tip = $('#ratingTip');
			$('#ratingTip').html(tip[0].data || '');
		},
		callback: function(value, link){
			$('input.starRating[name=rating]').val(value);
		}
	});
	$('#reviewForm').ajaxForm({
		beforeSubmit: 	validateReview,
		success: 	ugcNotification
	});
	/* shorten review strings */
	$('#user_reviews .comment p').truncate({max_length: 500});
	$('#editorReview .comment').truncate({max_length: 1000});
	
	/* embed youtube video */
	$('#popupEmbedForm').submit(function(){
		$('#review_embed').val($('#popupEmbed').val());
		$("#youtube-embed").dialog("close");
		return false;
	});
	
	/* paginated user reviews */
	/*$('#user_reviews_container .pagination a').live("click", function(){
		var resourceLink = $(this).attr("href");
		$.ajax({
			type: "GET",url: resourceLink,dataType: "html",
			beforeSend: function(){$('#user_reviews_container').fadeOut('fast').html('<img src="/img/frontend/ajax-loader.gif" alt="...please wait..." class="ajaxLoader" />').fadeIn('slow');},
			success: function(response){$('#user_reviews_container').hide().html(response).fadeIn('slow');}
		});return false;
	});*/
	$('#user_reviews_container .pagination a').live("click", function(){
		var resourceLink = $(this).attr("href");
		$.ajax({
			type: "GET",
			url: resourceLink,
			dataType: "html",
			success: function(response){
				$('#user_reviews_container .pagination').remove();
				$('#user_reviews_container').append(response).fadeIn('slow');
			}
		});
		return false;
	});
	
	/* Product page QnA user question form handling */
	$('#questionForm').ajaxForm({
		beforeSubmit:	validateQuestion,
		success:	ugcNotification
	});
	$('#qna_question').keyup(function(){ limitChars('qna_question', 250, 'qna_q_strlen') });
	/* hide extra QnA answers (x > 2) */
	$('#qna .wrapper').each(function(j){
		$(this).children('.item').each(function(i){
			if(i > 1) $(this).hide();
		});
	});
	// Show extra answers
	$("#qna .answers a").live("click", function(){
		$(this).parent().parent().siblings('.item').show();
		return false;
	});
	/* shorten QnA answer strings */
	$('#qna .wrapper .item span').truncate({max_length: 500});
	
	/* paginated QnAs */
	/*$('#qnas_container .pagination a').live("click", function(){var resourceLink = $(this).attr("href");
		$.ajax({
			type: "GET",url: resourceLink,dataType: "html",
			beforeSend: function(){$('#qnas_container').hide().html('<img src="/img/frontend/ajax-loader.gif" alt="...please wait..." class="ajaxLoader" />').fadeIn('slow');},
			success: function(response){$('#qnas_container').hide().html(response).fadeIn('slow');$('#qna .wrapper').each(function(j){$(this).children('dl').children('dd.item').each(function(i){if(i > 1) $(this).hide();});});}
		});return false;
	});*/
	$('#qnas_container .pagination a').live("click", function(){
		var resourceLink = $(this).attr("href");
		$.ajax({
			type: "GET",
			url: resourceLink,
			dataType: "html",
			success: function(response){
				$('#qnas_container .pagination').remove();
				$('#qnas_container').append(response).fadeIn('slow');
				
				// hide extra QnA answers (x > 2)
				$('#qna .wrapper').each(function(j){
					$(this).children('.item').each(function(i){
						if(i > 1) $(this).hide();
					});
				});
			}
		});
		return false;
	});

	var slept = false;
	/* post download screen */
	$(".downloadProduct").click(function(e) {
		
		var url = $('.downloadProduct').attr('href');
		
		// Not Babylon or irfanview?
		if( url.indexOf('8307') == '-1' && url.indexOf('9337') == '-1' && url.indexOf('9374') == '-1' )
		{
			// show popup
			$("#downloadPopup").dialog( {width:617, dialogClass:'popup-downloadPopup', resizable: false, closeText: 'close', modal: true });
		}
		
		// irfanview products
		if( url.indexOf('9337') != '-1' || url.indexOf('9374') != '-1' )
		{
			// show popup
			$("#stubPopup").dialog( {width:804, dialogClass:'popup-stubPopup', resizable: false, closeText: 'close', modal: true });
			return false;
		}
		
		$("#productDetailcontainer").hide(); // hide product details
		$("#postDownload").fadeIn(); // show post download screen
		
		// MSIE bug fix: throw in marker as referer is not carried over via js
		if ( $.browser.msie ) { url = url+'/ie'; }
		// Chrome & MSIE bug fix: wait 1sec before going to link
		setTimeout("redirect('" + url + "')", 1000);
		return false;
	});
	
	/* -discount & -coupon pages: reveal/hide more discount */
	$('.toggleLimit').click(function() {
		$(this).parent().prev('.children').toggleClass('limit');
		return false;
	});
	
	
	
	/* publisher listing */
	$("#publisherIndexA").show();
	$("#publisherJumpTo a").click(function(){
		$("div.publisherGroup").hide(); // hide all
		$(this.hash).show();
		return false;
	});
	
	/* category pages */
	$(".product-table tr:nth-child(even)").css("background-color", "#f6f6f6");
	
	$("#awards .embed_btn").click(function(){
		var code = $(this).parent().siblings('textarea.embed_code').html();
		$('#embed_code').html(code);
		$('#embed_code').toggle();
		return false;
	});
	$(".alisting .embed_btn").click(function(){
		$(this).parent().siblings('textarea.embed_code').toggle();
		return false;
	});
	
	/* edit account */
	$('#bio').keyup(function(){ limitChars('bio', 1000, 'bio_strlen') });
	$("#dob").datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true, yearRange: '-100:-16', minDate: '-100y', maxDate: '-16y'});
	
	/* FB logout */
	$('#logout').click(function(){
		FB.logout(function(response){});
		setTimeout("redirect('/auth/logout')", 1500);
		return false;
	});
	
	/* Sign in */
	$("#signInLocal").click(function() {
		$('#signInForm').toggle('slow');
	});
	
	/* Black Friday */
	$('.showitall').click(function(){
		$('#bf_like').hide();
		$('#bf_mask').hide();
	});
	
	$(".tabs").tabs(); // initialise tabs
	
	site_content.init('#site-map','ol a.remove');
	
	$("#other-softwares .viewer, #other-editions .viewer, #related-software .viewer, #top-discounts .viewer, #popular-softwares .viewer").each(function() {	
		product_scroller.init(this,".content-conveyor","ul.sidebar");
	});

	// Top Nav Dropdown
	$("li.mega > a").click(function(){ return false; });
	$("li.mega").hoverIntent(megaConfig);

	// Sign in Dropdown
	$("#sign-in > a").click(function(){
		$(this).parent().toggleClass("open");
		if ($(this).parent().hasClass("open")){ $(this).parent().children("div").show(); }
		else { $(this).parent().children("div").hide(); }
		return false;
	});
	// New Customers Dropdown
	$("#new-customers a").click(function(){
		$(this).parent().toggleClass("open");
		if ($(this).parent().hasClass("open")){ $(this).parent().children("div").show(); }
		else { $(this).parent().children("div").hide(); }
		return false;
	});
	
	// Initialise Popups
	$("a.sign-in").click(function(){ $("#popup-sign-in").dialog( {width:617, dialogClass:'popup-sign-in', resizable: false, closeText: 'close', modal: true }); return false; });
	$("a.youtube").click(function(){ $("#youtube-embed").dialog( {width:447, dialogClass:'popup-youtube', resizable: false, closeText: 'close', modal: true }); return false; });
	$("a.submitted").click(function(){ $("#submitted").dialog( {width:447, dialogClass:'popup-submitted', resizable: false, closeText: 'close', modal: true }); return false; });
	$("a.variation").click(function(){ $("#variation").dialog( {width:617, dialogClass:'popup-sign-in', resizable: false, closeText: 'close', modal: true }); return false; });
	$("a.checker").click(function(){ $("#popup-software-checker .popup").dialog( {width:530, dialogClass:'popup-software-checker', resizable: false, closeText: 'close', modal: true }); return false; });
});
/* onLoad code ENDS */

/* url redirection */
function redirect(url) { location.href = url; }

function replyQuestion(id)
{
	var e = $('#qna_answer'+id).parent().parent();
	
	if ( $(e+':hidden').length > 0 )
	{
		$(e).show();
		$('#qna_answer'+id).focus();
	}
	else
	{
		$(e).hide();
	}
	return false;
}

/* validation functions */
function validateCouponComment(formData, jqForm, options) {
	var comment = $(jqForm[0]).children('.comment').val();
	if ( !comment ) {
		alert('Please write a comment'); return false;
	}
	// all good, disable submit button to avoid double-posting
	$(jqForm[0]).children('.btn-submit').fadeOut('fast');
	$(jqForm[0]).append('<p style="float:right;">please wait&hellip; <img src="/img/frontend/ajax-loader-small.gif" alt="" style="vertical-align:middle;" /></p>').fadeIn('slow');
}
function validateReview(formData, jqForm, options) {
	var advantages = $('#review_advantages').val();
	var disavantages = $('#review_disavantages').val();
	var overall = $('#review_overall').val();
	var rating = $('.starRating[name=rating]:checked').val();
	
	if ( $('#review_username').length > 0 ) { var username = $('#review_username').val(); }
	else { var username = true; }
	
	if ( !advantages || !disavantages || !overall || !rating || !username ) {
		alert('Please fill in all fields'); return false;
	}
	// all good, disable submit button to avoid double-posting
	$("#reviewForm .btn-submit").fadeOut('fast');
	$("#reviewForm").append('<p style="float:right;margin-top: 15px;">please wait&hellip; <img src="/img/frontend/ajax-loader-small.gif" alt="" style="vertical-align:middle;" /></p>').fadeIn('slow');
}
function validateQuestion(formData, jqForm, options) {
	var content = $(jqForm[0]).children('textarea').val();
	if (!content) {
		alert('Please enter your question'); return false;
	}
	// all good, disable submit button to avoid double-posting
	$("#questionForm .btn-submit").fadeOut('fast');
	$("#questionForm").append('<img src="/img/frontend/ajax-loader-small.gif" alt="please wait" />').fadeIn('slow');
}
function validateAnswer(formData, jqForm, options) {
	var content = $(jqForm[0]).children('textarea').val();
	if (!content) {
		alert('Please enter your answer'); return false;
	}
	// all good, disable submit button to avoid double-posting
	$(jqForm[0]).children(".btn-submit").fadeOut('fast');
	$(jqForm[0]).children('textarea').after('<img src="/img/frontend/ajax-loader-small.gif" alt="please wait" />').fadeIn('slow');
}
function validateComment(formData, jqForm, options) {
        var content = $(jqForm[0]).children('textarea').val();
        if (!content) {
                alert('Please enter your comment'); return false;
        }
        // all good, disable submit button to avoid double-posting
        $("#commentForm .btn-submit").fadeOut('fast');
        $("#commentForm").append('<img src="/img/frontend/ajax-loader-small.gif" alt="please wait" />').fadeIn('slow');
}
function validateCommentReply(formData, jqForm, options) {
	var content = $(jqForm[0]).children('textarea').val();
	if (!content) {
		alert('Please enter your comment'); return false;
	}
	// all good, disable submit button to avoid double-posting
	$(jqForm[0]).children(".btn-submit").fadeOut('fast');
	$(jqForm[0]).children('textarea').after('<img src="/img/frontend/ajax-loader-small.gif" alt="please wait" />').fadeIn('slow');
}

function ugcNotification(responseText, statusText, xhr, $form) {
	// replace form
	$($form).html('<p>' + responseText + '</p>');
	// popup notification
	$("#submitted .popup").html('<p>' + responseText + '</p>');
	$("#submitted").dialog( {width:447, dialogClass:'popup-submitted', resizable: false, closeText: 'close', modal: true });
}


/* product variations */
function select_variation(product_id) {
	/* 0=>name, 1=>locale, 2=>buy_url, 3=>coupon_text, 4=>licence, 5=>product_version, 6=>version_type, 7=>parent_id, 8=>coupon_id */
	$("#product_main_name").text(variationData[product_id][0]);
	$("#product_main_download a.buy").attr('href', variationData[product_id][2]);
	$("#product_spec #license").text(variationData[product_id][4]);
	$("#product_spec #edition").text( variationData[product_id][1].charAt(0).toUpperCase() + variationData[product_id][1].slice(1) ); // ucfirst
	$("#product_spec #version_type").text(variationData[product_id][6]);
	
	$("#coupons").empty();
	var url = "/product/coupon/" + variationData[product_id][7] + "/" + product_id + "/" + variationData[product_id][8];
	$.get(url, function(data){
		if ( data ) {
			$("#jumpToCoupon").text('See coupons');
			$("#coupons").html(data);
			$(".couponRatingForm").ajaxForm({ success: couponRatingNotification });
			$(".couponCommentForm").ajaxForm({ beforeSubmit: validateCouponComment, success: couponCommentNotification });
		}
		else {
			$("#jumpToCoupon").text('');
			$("#coupons").html('');
		}
	});
	
	$("#variation").dialog("close");
	return false;
}

/* quick find box */
function quickfind() {
	var array = $('#input_category').val().split('|');
	if ($('#input_mac:checked').length > 0) // mac
		var url = array[1];
	else // windows
		var url = array[0];
	window.location = url;
}

var remove_element = { init: function(e, p) {
	$(e).bind('click', function(){
		if((p) == "tr") { $(this).parents(p).css('display','none'); }
		else { $(this).parents(p).slideUp('slow'); }
		return false;
	});
}};

var product_scroller = {
	init: function(_ps,content_conveyor,e) {
		
		//vars
		var conveyor = $(content_conveyor, $(_ps));
		var item = $(e, $(_ps));
		var firstVisibleItem = $(e).filter(':visible:eq(0)');
		if(firstVisibleItem.length == 0) return;
		var itemWidth = parseInt(firstVisibleItem.outerWidth(true));
		
		//set length of conveyor
		conveyor.css("width", item.length * itemWidth);
		
		//config
		var sliderOpts = {
		  	max: (item.length * itemWidth) - parseInt($(_ps).css("width")),
			change: function(e, ui) {
				conveyor.animate({ left : "-" + ui.value + "px" }, 1000);
			},
			step: itemWidth,
			animate: true
		};
		
		$(_ps).find(".slider").slider(sliderOpts);	
		$(_ps).find(".btn-next").bind('click', function(){
			var curr_value = $(_ps).find(".slider").slider("value");
			$(_ps).find(".slider").slider("value", curr_value + itemWidth);
			return false;
		});
		$(_ps).find(".btn-prev").bind('click', function(){
			var curr_value = $(_ps).find(".slider").slider("value"); 						  
			$(_ps).find(".slider").slider("value", curr_value - itemWidth);
			return false;
		});
	}
};

var price_watcher = {
	init: function(_pw,_remove) {
		$(_pw +' '+_remove).bind('click', function(){
			var pwlink = $(this); price_watcher.remove(_pw,pwlink); return false;
		});
		$(_pw +' a.toggle').bind('click', function(){
			var pwtoggle = $(this); price_watcher.toggle(pwtoggle); return false;
		});
	},
	toggle: function(pwtoggle) {
		$(pwtoggle).next().slideToggle('slow').parent().parent().toggleClass('close');
		if((pwtoggle).parent().parent().hasClass('close')){
			$(pwtoggle).html('+');
		}else{
			$(pwtoggle).html('&ndash;');
		}
	},	
	remove: function(_pw,pwlink) {
		$(pwlink).parent().slideUp('slow');
		var child_count = $(pwlink).parent().parent().children("li:visible").size()-2;
		var status_update = $(pwlink).parent().parent().parent().parent()
			status_update.find('.status').html('You have ('+child_count+') items in your price watcher')
			status_update.find('h3').html('Price watcher ('+child_count+' items)');
		return false;
	}	
};

var site_content = {
	init: function(_pw,_remove) {
		$(_pw +' a.toggle').bind('click', function(){
			var pwtoggle = $(this); site_content.toggle(pwtoggle); return false;
		});
	},
	toggle: function(pwtoggle) {
		if( $('.site-map-inner').is(':visible') ) {
			$('.site-map-inner').hide(); $(pwtoggle).html('+'); return false;
		}else{
			$('.site-map-inner').slideDown('slow'); $(pwtoggle).html('-'); return false;
		};
	}
};

// HTML Truncator for jQuery
// by Henrik Nyh <http://henrik.nyh.se> 2008-02-28.
// Free to modify and redistribute with credit.
(function(d){function g(b,c){b=d(b);var a=b.clone().empty(),e;b.contents().each(function(){var f=c-a.text().length;if(f!=0)(e=this.nodeType==3?h(this,f):g(this,f))&&a.append(e)});return a}function h(b,c){var a=i(b.data);if(j)a=a.replace(/^ /,"");j=!!a.match(/ $/);a=a.slice(0,c);return a=d("<div/>").text(a).html()}function i(b){return b.replace(/\s+/g," ")}function k(b){var c=d(b),a=c.children(":last");if(!a)return b;b=a.css("display");if(!b||b=="inline")return c;return k(a)}function l(b){var c=d(b).children(":last");
if(c&&c.is("p"))return c;return b}var j=true;d.fn.truncate=function(b){var c=d.extend({},d.fn.truncate.defaults,b);d(this).each(function(){if(!(d.trim(i(d(this).text())).length<=c.max_length)){var a=this.nodeType==3?h(this,c.max_length-c.more.length-3):g(this,c.max_length-c.more.length-3),e=d(this).hide();a.insertAfter(e);k(a).append(' <a href="#show more content">'+c.more+"</a>");l(e).append(' <a href="#show less content">'+c.less+"</a>");a.find("a:last").click(function(){a.hide();e.show();return false});
e.find("a:last").click(function(){a.show();e.hide();return false})}})};d.fn.truncate.defaults={max_length:100,more:"&hellip;more",less:"less"}})(jQuery);

// Chararcter limiter
function limitChars(b,a,c){var d=$("#"+b).val(),e=d.length;if(e>a){$("#"+c).html("(You cannot write more than "+a+" characters!)");$("#"+b).val(d.substr(0,a));return false}else{$("#"+c).html("(You have "+(a-e)+" characters left)");return true}};

// jQuery Star Rating Plugin v3.13 - Dual MIT & GPL licenses
// Home : http://www.fyneworks.com/jquery/star-rating/
window.jQuery&&function(a){if(a.browser.msie)try{document.execCommand("BackgroundImageCache",false,true)}catch(m){}a.fn.rating=function(c){if(this.length==0)return this;if(typeof arguments[0]=="string"){if(this.length>1){var d=arguments;return this.each(function(){a.fn.rating.apply(a(this),d)})}a.fn.rating[arguments[0]].apply(this,a.makeArray(arguments).slice(1)||[]);return this}c=a.extend({},a.fn.rating.options,c||{});a.fn.rating.calls++;this.not(".star-rating-applied").addClass("star-rating-applied").each(function(){var b,
e=a(this),k=(this.name||"unnamed-rating").replace(/\[|\]/g,"_").replace(/^\_+|\_+$/g,""),j=a(this.form||document.body),h=j.data("rating");if(!h||h.call!=a.fn.rating.calls)h={count:0,call:a.fn.rating.calls};var g=h[k];if(g)b=g.data("rating");if(g&&b)b.count++;else{b=a.extend({},c||{},(a.metadata?e.metadata():a.meta?e.data():null)||{},{count:0,stars:[],inputs:[]});b.serial=h.count++;g=a('<span class="star-rating-control"/>');e.before(g);g.addClass("rating-to-be-drawn");if(e.attr("disabled"))b.readOnly=
true;g.append(b.cancel=a('<div class="rating-cancel"><a title="'+b.cancel+'">'+b.cancelValue+"</a></div>").mouseover(function(){a(this).rating("drain");a(this).addClass("star-rating-hover")}).mouseout(function(){a(this).rating("draw");a(this).removeClass("star-rating-hover")}).click(function(){a(this).rating("select")}).data("rating",b))}var f=a('<div class="star-rating rater-'+b.serial+'"><a title="'+(this.title||this.value)+'">'+this.value+"</a></div>");g.append(f);this.id&&f.attr("id",this.id);
this.className&&f.addClass(this.className);if(b.half)b.split=2;if(typeof b.split=="number"&&b.split>0){var i=(a.fn.width?f.width():0)||b.starWidth,l=b.count%b.split;i=Math.floor(i/b.split);f.width(i).find("a").css({"margin-left":"-"+l*i+"px"})}b.readOnly?f.addClass("star-rating-readonly"):f.addClass("star-rating-live").mouseover(function(){a(this).rating("fill");a(this).rating("focus")}).mouseout(function(){a(this).rating("draw");a(this).rating("blur")}).click(function(){a(this).rating("select")});
if(this.checked)b.current=f;e.hide();e.change(function(){a(this).rating("select")});f.data("rating.input",e.data("rating.star",f));b.stars[b.stars.length]=f[0];b.inputs[b.inputs.length]=e[0];b.rater=h[k]=g;b.context=j;e.data("rating",b);g.data("rating",b);f.data("rating",b);j.data("rating",h)});a(".rating-to-be-drawn").rating("draw").removeClass("rating-to-be-drawn");return this};a.extend(a.fn.rating,{calls:0,focus:function(){var c=this.data("rating");if(!c)return this;if(!c.focus)return this;var d=
a(this).data("rating.input")||a(this.tagName=="INPUT"?this:null);c.focus&&c.focus.apply(d[0],[d.val(),a("a",d.data("rating.star"))[0]])},blur:function(){var c=this.data("rating");if(!c)return this;if(!c.blur)return this;var d=a(this).data("rating.input")||a(this.tagName=="INPUT"?this:null);c.blur&&c.blur.apply(d[0],[d.val(),a("a",d.data("rating.star"))[0]])},fill:function(){var c=this.data("rating");if(!c)return this;if(!c.readOnly){this.rating("drain");this.prevAll().andSelf().filter(".rater-"+c.serial).addClass("star-rating-hover")}},
drain:function(){var c=this.data("rating");if(!c)return this;c.readOnly||c.rater.children().filter(".rater-"+c.serial).removeClass("star-rating-on").removeClass("star-rating-hover")},draw:function(){var c=this.data("rating");if(!c)return this;this.rating("drain");if(c.current){c.current.data("rating.input").attr("checked","checked");c.current.prevAll().andSelf().filter(".rater-"+c.serial).addClass("star-rating-on")}else a(c.inputs).removeAttr("checked");c.cancel[c.readOnly||c.required?"hide":"show"]();
this.siblings()[c.readOnly?"addClass":"removeClass"]("star-rating-readonly")},select:function(c,d){var b=this.data("rating");if(!b)return this;if(!b.readOnly){b.current=null;if(typeof c!="undefined"){if(typeof c=="number")return a(b.stars[c]).rating("select",undefined,d);typeof c=="string"&&a.each(b.stars,function(){a(this).data("rating.input").val()==c&&a(this).rating("select",undefined,d)})}else b.current=this[0].tagName=="INPUT"?this.data("rating.star"):this.is(".rater-"+b.serial)?this:null;this.data("rating",
b);this.rating("draw");var e=a(b.current?b.current.data("rating.input"):null);if((d||d==undefined)&&b.callback)b.callback.apply(e[0],[e.val(),a("a",b.current)[0]])}},readOnly:function(c,d){var b=this.data("rating");if(!b)return this;b.readOnly=c||c==undefined?true:false;d?a(b.inputs).attr("disabled","disabled"):a(b.inputs).removeAttr("disabled");this.data("rating",b);this.rating("draw")},disable:function(){this.rating("readOnly",true,true)},enable:function(){this.rating("readOnly",false,false)}});
a.fn.rating.options={cancel:"Cancel Rating",cancelValue:"",split:0,starWidth:19};a(function(){a("input[type=radio].star").rating()})}(jQuery);

/**
* hoverIntent r5 // 2007.03.27
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(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);

/**
 * jQuery Form Plugin
 * version: 2.43 (12-MAR-2010)
 * @requires jQuery v1.3.2 or later
 * Dual licensed under the MIT and GPL licenses
 */
(function(b){function o(){if(b.fn.ajaxSubmit.debug){var a="[jquery.form] "+Array.prototype.join.call(arguments,"");if(window.console&&window.console.log)window.console.log(a);else window.opera&&window.opera.postError&&window.opera.postError(a)}}b.fn.ajaxSubmit=function(a){function e(){function s(){var q=h.attr("target"),n=h.attr("action");k.setAttribute("target",z);k.getAttribute("method")!="POST"&&k.setAttribute("method","POST");k.getAttribute("action")!=g.url&&k.setAttribute("action",g.url);g.skipEncodingOverride||
h.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"});g.timeout&&setTimeout(function(){C=true;t()},g.timeout);var m=[];try{if(g.extraData)for(var v in g.extraData)m.push(b('<input type="hidden" name="'+v+'" value="'+g.extraData[v]+'" />').appendTo(k)[0]);u.appendTo("body");u.data("form-plugin-onload",t);k.submit()}finally{k.setAttribute("action",n);q?k.setAttribute("target",q):h.removeAttr("target");b(m).remove()}}function t(){if(!D){var q=true;try{if(C)throw"timeout";var n,m;m=w.contentWindow?
w.contentWindow.document:w.contentDocument?w.contentDocument:w.document;var v=g.dataType=="xml"||m.XMLDocument||b.isXMLDoc(m);o("isXml="+v);if(!v&&(m.body==null||m.body.innerHTML=="")){if(--G){o("requeing onLoad callback, DOM not available");setTimeout(t,250);return}o("Could not access iframe DOM after 100 tries.");return}o("response detected");D=true;j.responseText=m.body?m.body.innerHTML:null;j.responseXML=m.XMLDocument?m.XMLDocument:m;j.getResponseHeader=function(H){return{"content-type":g.dataType}[H]};
if(g.dataType=="json"||g.dataType=="script"){var E=m.getElementsByTagName("textarea")[0];if(E)j.responseText=E.value;else{var F=m.getElementsByTagName("pre")[0];if(F)j.responseText=F.innerHTML}}else if(g.dataType=="xml"&&!j.responseXML&&j.responseText!=null)j.responseXML=A(j.responseText);n=b.httpData(j,g.dataType)}catch(B){o("error caught:",B);q=false;j.error=B;b.handleError(g,j,"error",B)}if(q){g.success(n,"success");x&&b.event.trigger("ajaxSuccess",[j,g])}x&&b.event.trigger("ajaxComplete",[j,g]);
x&&!--b.active&&b.event.trigger("ajaxStop");if(g.complete)g.complete(j,q?"success":"error");setTimeout(function(){u.removeData("form-plugin-onload");u.remove();j.responseXML=null},100)}}function A(q,n){if(window.ActiveXObject){n=new ActiveXObject("Microsoft.XMLDOM");n.async="false";n.loadXML(q)}else n=(new DOMParser).parseFromString(q,"text/xml");return n&&n.documentElement&&n.documentElement.tagName!="parsererror"?n:null}var k=h[0];if(b(":input[name=submit]",k).length)alert('Error: Form elements must not be named "submit".');
else{var g=b.extend({},b.ajaxSettings,a),r=b.extend(true,{},b.extend(true,{},b.ajaxSettings),g),z="jqFormIO"+(new Date).getTime(),u=b('<iframe id="'+z+'" name="'+z+'" src="'+g.iframeSrc+'" onload="(jQuery(this).data(\'form-plugin-onload\'))()" />'),w=u[0];u.css({position:"absolute",top:"-1000px",left:"-1000px"});var j={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=
1;u.attr("src",g.iframeSrc)}},x=g.global;x&&!b.active++&&b.event.trigger("ajaxStart");x&&b.event.trigger("ajaxSend",[j,g]);if(r.beforeSend&&r.beforeSend(j,r)===false)r.global&&b.active--;else if(!j.aborted){var D=false,C=0;if(r=k.clk){var y=r.name;if(y&&!r.disabled){g.extraData=g.extraData||{};g.extraData[y]=r.value;if(r.type=="image"){g.extraData[y+".x"]=k.clk_x;g.extraData[y+".y"]=k.clk_y}}}g.forceSync?s():setTimeout(s,10);var G=100}}}if(!this.length){o("ajaxSubmit: skipping submit process - no element selected");
return this}if(typeof a=="function")a={success:a};var c=b.trim(this.attr("action"));if(c)c=(c.match(/^([^#]+)/)||[])[1];c=c||window.location.href||"";a=b.extend({url:c,type:this.attr("method")||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},a||{});c={};this.trigger("form-pre-serialize",[this,a,c]);if(c.veto){o("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(a.beforeSerialize&&a.beforeSerialize(this,a)===false){o("ajaxSubmit: submit aborted via beforeSerialize callback");
return this}var f=this.formToArray(a.semantic);if(a.data){a.extraData=a.data;for(var d in a.data)if(a.data[d]instanceof Array)for(var l in a.data[d])f.push({name:d,value:a.data[d][l]});else f.push({name:d,value:a.data[d]})}if(a.beforeSubmit&&a.beforeSubmit(f,this,a)===false){o("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[f,this,a,c]);if(c.veto){o("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}d=b.param(f);if(a.type.toUpperCase()==
"GET"){a.url+=(a.url.indexOf("?")>=0?"&":"?")+d;a.data=null}else a.data=d;var h=this,i=[];a.resetForm&&i.push(function(){h.resetForm()});a.clearForm&&i.push(function(){h.clearForm()});if(!a.dataType&&a.target){var p=a.success||function(){};i.push(function(s){var t=a.replaceTarget?"replaceWith":"html";b(a.target)[t](s).each(p,arguments)})}else a.success&&i.push(a.success);a.success=function(s,t,A){for(var k=0,g=i.length;k<g;k++)i[k].apply(a,[s,t,A||h,h])};d=b("input:file",this).fieldValue();l=false;
for(c=0;c<d.length;c++)if(d[c])l=true;if(d.length&&a.iframe!==false||a.iframe||l||0)a.closeKeepAlive?b.get(a.closeKeepAlive,e):e();else b.ajax(a);this.trigger("form-submit-notify",[this,a]);return this};b.fn.ajaxForm=function(a){return this.ajaxFormUnbind().bind("submit.form-plugin",function(e){e.preventDefault();b(this).ajaxSubmit(a)}).bind("click.form-plugin",function(e){var c=e.target,f=b(c);if(!f.is(":submit,input:image")){c=f.closest(":submit");if(c.length==0)return;c=c[0]}var d=this;d.clk=c;
if(c.type=="image")if(e.offsetX!=undefined){d.clk_x=e.offsetX;d.clk_y=e.offsetY}else if(typeof b.fn.offset=="function"){f=f.offset();d.clk_x=e.pageX-f.left;d.clk_y=e.pageY-f.top}else{d.clk_x=e.pageX-c.offsetLeft;d.clk_y=e.pageY-c.offsetTop}setTimeout(function(){d.clk=d.clk_x=d.clk_y=null},100)})};b.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};b.fn.formToArray=function(a){var e=[];if(this.length==0)return e;var c=this[0],f=a?c.getElementsByTagName("*"):c.elements;
if(!f)return e;for(var d=0,l=f.length;d<l;d++){var h=f[d],i=h.name;if(i)if(a&&c.clk&&h.type=="image"){if(!h.disabled&&c.clk==h){e.push({name:i,value:b(h).val()});e.push({name:i+".x",value:c.clk_x},{name:i+".y",value:c.clk_y})}}else if((h=b.fieldValue(h,true))&&h.constructor==Array)for(var p=0,s=h.length;p<s;p++)e.push({name:i,value:h[p]});else h!==null&&typeof h!="undefined"&&e.push({name:i,value:h})}if(!a&&c.clk){a=b(c.clk);f=a[0];if((i=f.name)&&!f.disabled&&f.type=="image"){e.push({name:i,value:a.val()});
e.push({name:i+".x",value:c.clk_x},{name:i+".y",value:c.clk_y})}}return e};b.fn.formSerialize=function(a){return b.param(this.formToArray(a))};b.fn.fieldSerialize=function(a){var e=[];this.each(function(){var c=this.name;if(c){var f=b.fieldValue(this,a);if(f&&f.constructor==Array)for(var d=0,l=f.length;d<l;d++)e.push({name:c,value:f[d]});else f!==null&&typeof f!="undefined"&&e.push({name:this.name,value:f})}});return b.param(e)};b.fn.fieldValue=function(a){for(var e=[],c=0,f=this.length;c<f;c++){var d=
b.fieldValue(this[c],a);d===null||typeof d=="undefined"||d.constructor==Array&&!d.length||(d.constructor==Array?b.merge(e,d):e.push(d))}return e};b.fieldValue=function(a,e){var c=a.name,f=a.type,d=a.tagName.toLowerCase();if(typeof e=="undefined")e=true;if(e&&(!c||a.disabled||f=="reset"||f=="button"||(f=="checkbox"||f=="radio")&&!a.checked||(f=="submit"||f=="image")&&a.form&&a.form.clk!=a||d=="select"&&a.selectedIndex==-1))return null;if(d=="select"){var l=a.selectedIndex;if(l<0)return null;c=[];d=
a.options;var h=(f=f=="select-one")?l+1:d.length;for(l=f?l:0;l<h;l++){var i=d[l];if(i.selected){var p=i.value;p||(p=i.attributes&&i.attributes.value&&!i.attributes.value.specified?i.text:i.value);if(f)return p;c.push(p)}}return c}return a.value};b.fn.clearForm=function(){return this.each(function(){b("input,select,textarea",this).clearFields()})};b.fn.clearFields=b.fn.clearInputs=function(){return this.each(function(){var a=this.type,e=this.tagName.toLowerCase();if(a=="text"||a=="password"||e=="textarea")this.value=
"";else if(a=="checkbox"||a=="radio")this.checked=false;else if(e=="select")this.selectedIndex=-1})};b.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||typeof this.reset=="object"&&!this.reset.nodeType)this.reset()})};b.fn.enable=function(a){if(a==undefined)a=true;return this.each(function(){this.disabled=!a})};b.fn.selected=function(a){if(a==undefined)a=true;return this.each(function(){var e=this.type;if(e=="checkbox"||e=="radio")this.checked=a;else if(this.tagName.toLowerCase()==
"option"){e=b(this).parent("select");a&&e[0]&&e[0].type=="select-one"&&e.find("option").selected(false);this.selected=a}})}})(jQuery);

/* Easy Slider 1.7 - jQuery plugin - by Alen Grakalic - Modified by ced
 * http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding
 */
(function(b){b.fn.easySlider=function(a){a=b.extend({prevId:"prevBtn",prevText:"Previous",nextId:"nextBtn",nextText:"Next",controlsShow:true,controlsBefore:"",controlsAfter:"",controlsFade:true,firstId:"firstBtn",firstText:"First",firstShow:false,lastId:"lastBtn",lastText:"Last",lastShow:false,vertical:false,speed:800,auto:false,pause:2E3,continuous:false,numeric:false,numericId:"controls",slidesName:["Antivirus","Design","Photo","Music Software","Mac Software","Video Editing","System Utilities",
"Security Suites"]},a);this.each(function(){function n(f){f=parseInt(f)+1;b("li","#"+a.numericId).removeClass("current");b("li#"+a.numericId+f).addClass("current")}function o(){if(c>h)c=0;if(c<0)c=h;a.vertical?b("ul",d).css("margin-left",c*k*-1):b("ul",d).css("margin-left",c*i*-1);l=true;a.numeric&&n(c)}function g(f,q){if(l){l=false;var j=c;switch(f){case "next":c=j>=h?a.continuous?c+1:h:c+1;break;case "prev":c=c<=0?a.continuous?c-1:0:c-1;break;case "first":c=0;break;case "last":c=h;break;default:c=
f}j=Math.abs(j-c);var r=j*a.speed;if(a.vertical){p=c*k*-1;b("ul",d).animate({marginTop:p},{queue:false,duration:r,complete:o})}else{p=c*i*-1;b("ul",d).animate({marginLeft:p},{queue:false,duration:r,complete:o})}if(!a.continuous&&a.controlsFade){if(c==h){b("a","#"+a.nextId).hide();b("a","#"+a.lastId).hide()}else{b("a","#"+a.nextId).show();b("a","#"+a.lastId).show()}if(c==0){b("a","#"+a.prevId).hide();b("a","#"+a.firstId).hide()}else{b("a","#"+a.prevId).show();b("a","#"+a.firstId).show()}}q&&clearTimeout(m);
if(a.auto&&f=="next"&&!q)m=setTimeout(function(){g("next",false)},j*a.speed+a.pause)}}var d=b(this),e=b("li",d).length,i=b("li",d).width(),k=b("li",d).height(),l=true;d.width(i);d.height(k);d.css("overflow","hidden");var h=e-1,c=0;b("ul",d).css("width",e*i);if(a.continuous){b("ul",d).prepend(b("ul li:last-child",d).clone().css("margin-left","-"+i+"px"));b("ul",d).append(b("ul li:nth-child(2)",d).clone());b("ul",d).css("width",(e+1)*i)}a.vertical||b("li",d).css("float","left");if(a.controlsShow){e=
a.controlsBefore;if(a.numeric)e+='<div id="slider_cat"><ol id="'+a.numericId+'"></ol></div>';if(a.firstShow)e+='<span id="'+a.firstId+'"><a href="javascript:void(0);">'+a.firstText+"</a></span>";e+=' <span id="'+a.prevId+'"><a href="javascript:void(0);">'+a.prevText+"</a></span>";e+=' <span id="'+a.nextId+'"><a href="javascript:void(0);">'+a.nextText+"</a></span>";if(a.lastShow)e+=' <span id="'+a.lastId+'"><a href="javascript:void(0);">'+a.lastText+"</a></span>";e+=a.controlsAfter;b(d).after(e)}if(a.numeric)for(e=
0;e<a.slidesName.length;e++)b(document.createElement("li")).attr("id",a.numericId+(e+1)).html("<a rel="+e+' href="javascript:void(0);">'+a.slidesName[e]+"</a>").appendTo(b("#"+a.numericId)).click(function(){g(parseInt(b("a",b(this)).attr("rel")),true);return false});b("a","#"+a.nextId).click(function(){g("next",true);return false});b("a","#"+a.prevId).click(function(){g("prev",true);return false});b("a","#"+a.firstId).click(function(){g("first",true);return false});b("a","."+a.lastId).click(function(){g("last",
true);return false});var m;if(a.auto)m=setTimeout(function(){g("next",false)},a.pause);a.numeric&&n(0);if(!a.continuous&&a.controlsFade){b("a","#"+a.prevId).hide();b("a","#"+a.firstId).hide()}})}})(jQuery);

/* jQuery Form Example Plugin 1.4.3 (c) Paul Mucur (http://mucur.name), BSD/GPL Licensed */
(function(a){a.fn.example=function(e,g){var d=a.isFunction(e),f=a.extend({},g,{example:e});return this.each(function(){var c=a(this),b=a.metadata?a.extend({},a.fn.example.defaults,c.metadata(),f):a.extend({},a.fn.example.defaults,f);if(!a.fn.example.boundClassNames[b.className]){a(window).unload(function(){a("."+b.className).val("")});a("form").submit(function(){a(this).find("."+b.className).val("")});a.fn.example.boundClassNames[b.className]=true}if(!c.attr("defaultValue")&&(d||c.val()==b.example))c.val("");
if(c.val()==""&&this!=document.activeElement){c.addClass(b.className);c.val(d?b.example.call(this):b.example)}c.focus(function(){if(a(this).is("."+b.className)){a(this).val("");a(this).removeClass(b.className)}});c.change(function(){a(this).is("."+b.className)&&a(this).removeClass(b.className)});c.blur(function(){if(a(this).val()==""){a(this).addClass(b.className);a(this).val(d?b.example.call(this):b.example)}})})};a.fn.example.defaults={className:"example"};a.fn.example.boundClassNames=[]})(jQuery);

/* (c) Sergiy Kovalchuk - https://code.google.com/p/jquery-loadmask/ - MIT/GPL Licensed */
(function(a){a.fn.mask=function(c,b){a(this).each(function(){if(b!==undefined&&b>0){var d=a(this);d.data("_mask_timeout",setTimeout(function(){a.maskElement(d,c)},b))}else{a.maskElement(a(this),c)}})};a.fn.unmask=function(){a(this).each(function(){a.unmaskElement(a(this))})};a.fn.isMasked=function(){return this.hasClass("masked")};a.maskElement=function(d,c){if(d.data("_mask_timeout")!==undefined){clearTimeout(d.data("_mask_timeout"));d.removeData("_mask_timeout")}if(d.isMasked()){a.unmaskElement(d)}if(d.css("position")=="static"){d.addClass("masked-relative")}d.addClass("masked");var e=a('<div class="loadmask"></div>');if(navigator.userAgent.toLowerCase().indexOf("msie")>-1){e.height(d.height()+parseInt(d.css("padding-top"))+parseInt(d.css("padding-bottom")));e.width(d.width()+parseInt(d.css("padding-left"))+parseInt(d.css("padding-right")))}if(navigator.userAgent.toLowerCase().indexOf("msie 6")>-1){d.find("select").addClass("masked-hidden")}d.append(e);if(c!==undefined){var b=a('<div class="loadmask-msg" style="display:none;"></div>');b.append("<div>"+c+"</div>");d.append(b);b.css("top",Math.round(d.height()/2-(b.height()-parseInt(b.css("padding-top"))-parseInt(b.css("padding-bottom")))/2)+"px");b.css("left",Math.round(d.width()/2-(b.width()-parseInt(b.css("padding-left"))-parseInt(b.css("padding-right")))/2)+"px");b.show()}};a.unmaskElement=function(b){if(b.data("_mask_timeout")!==undefined){clearTimeout(b.data("_mask_timeout"));b.removeData("_mask_timeout")}b.find(".loadmask-msg,.loadmask").remove();b.removeClass("masked");b.removeClass("masked-relative");b.find("select").removeClass("masked-hidden")}})(jQuery);
