﻿//
//
//
function dummy() { }
function no_progress_bar_dummy() { }

//
//
//
$(document).ready(function(){
	init_forms();
	$(".cornered").each(function(){ $(this).corner("10px"); });
//	init_lightbox();
//	init_carousel();
//	init_slider();
});

//
//
//
function init_lightbox () {
	if ( $('a[rel=lightbox]').attr('rel') == 'lightbox' ){
		$('a[rel=lightbox]').lightBox();
	}
}


//
//
//
function init_slider () {
	if ( $('#slider').attr('id') == 'slider' ) {
	$("#slider").easySlider({
		loop: true,                           // Looping
		orientation: 'fade',                  // Fading
		autoplayDuration: 5000,               // Autoplay with 1 second intervals
		autogeneratePagination: false,         // Automatically generate pagination links
		restartDuration: 5000,                // In case of user interaction, restart the autoplay after 2.5 seconds
		pauseable: true                       // Pause by hovering over the image!  Then restart after 2.5 seconds (see above)
	});
	}
}

//
//
//
function init_carousel () {
	if ( $('#cat_promo').attr('id') == 'cat_promo' ) {
		jQuery('#cat_promo').jcarousel({
			auto: 4,
			wrap: 'circular',
			initCallback: init_carousel_config
		});
	}
	if ( $('#cat_promo2').attr('id') == 'cat_promo2' ) {
		jQuery('#cat_promo2').jcarousel({
			auto: 4,
			wrap: 'circular',
			initCallback: init_carousel_config
		});
	}
}
function init_carousel_config ( carousel ) {
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });

	carousel.options.scroll = 1;

	$(".arrow").each(function(){
		$(this).mouseover( function() { 
			$(this).attr('src', $(this).attr('src').replace('.gif','_hover.gif') );
		});
		$(this).mouseout( function() { 
			$(this).attr('src', $(this).attr('src').replace('_hover.gif','.gif') );
		});
		$(this).mousedown( function() { 
			if( $(this).attr('src').indexOf('right') > 0) { 
				carousel.next();
			} else { 
				carousel.prev();
			}
		});
	});
}

//
//
//
function submit_form ( form_name ) {
	var is_correct = "1";
	$(".required,.required_").each(function (i) {
		if( $(this).attr("value") == "") {
			if( $(this).attr("className").indexOf("required_") == -1) { 
				$(this).attr("className", $(this).attr("className").replace("required", "required_") );
			}
			$(this).focus();
			is_correct = "0";
			return false;

		} else {
			if( $(this).attr("className").indexOf("required_") >= 0) { 
				$(this).attr("className", $(this).attr("className").replace("required_", "required") );
			}
		}
	});
	if( is_correct == "1" && $("#form_verify").val() == "0" ) {
		$("#form_verify").val("1");
		$("form#"+form_name+"").submit();
	}
}

//
//
//
function init_forms () {
	if( $("#form_verify").val() >= "0" ) {
		$("#form_verify").val("0");
		$("#current_action").val("0");
	} else {
		$("form:last").append("<input type=hidden id=form_verify name=form_verify value=0 />");
		$("form:last").append("<input type=hidden id=current_action name=current_action value=0 />");
	}
}

