
function newsletter_signup(){
	if(v_subscribe.exec()){
	  $("#loading_subscribe").show();
		var filtervars = {
			do_what:'subscribe',        
			email: $("#email").val()
		 };
		$.ajax({
			type: "POST",
			url: "_ajax_files/subscribe_ajax.php",
			data: filtervars,
			dataType: "html",
			success: function(html){
				alert(html);
				$("#email").val('Enter email address');
				$("#loading_subscribe").hide();
			}
		});
		
		return false;	
	}else{
		return false;
	}
}

// Numeric only control handler
jQuery.fn.ForceNumericOnly =
function()
{
    return this.each(function()
    {
        $(this).keydown(function(e)
        {
            var key = e.charCode || e.keyCode || 0;
            // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
			//190 = dot
            return (
                key == 8 || 
                key == 9 ||
                key == 46 ||
				key == 190 ||
                (key >= 37 && key <= 40) ||
                (key >= 48 && key <= 57) ||
                (key >= 96 && key <= 105));
        })
    })
};

$(document).ready( function(){
		
	var this_hostname = window.location.href;
	var where_is_host=this_hostname.indexOf('www.leesrv.com');
	
	if( where_is_host < 0 )
	{
		alert("Invalid license key, please contact RVSS Support team.");
	}

	$('.tooltips').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		showBody: " - ",
		fade: 150,
		left: -300
	});	   
		   
	/*$(".tablink, .mytabs").mouseover( function() {
		 $(".tablink").removeClass('active'); //remove active class from all the tabs link if it is there, it won't do anything
		 $("#"+$(this).attr("tab_id")).addClass('active');
		 $(".mytabs").hide();
		 $("#tab_"+$(this).attr("tab_id")).show();
	});
	
	$(".tablink, .mytabs").mouseout( function() {
		 $(".tablink").removeClass('active'); //remove active class from all the tabs link if it is there, it won't do anything
		 $(".mytabs").hide();
	});*/
	
	$(".tablink, .mytabs").click( function() {
		 $(".tablink").removeClass('active'); //remove active class from all the tabs link if it is there, it won't do anything
		 $("#"+$(this).attr("tab_id")).addClass('active');
		 $(".mytabs").hide();
		 $("#tab_"+$(this).attr("tab_id")).show();
	});
	
	/*$(".mytabs").mouseover( function() {
		 $(".tablink").removeClass('active'); //remove active class from all the tabs link if it is there, it won't do anything
		 $("#"+$(this).attr("tab_id")).addClass('active');
		 $(".mytabs").hide();
		 $("#tab_"+$(this).attr("tab_id")).show();
	});
	$(".tablink, .mytabs").mouseout( function() {
		 $(".tablink").removeClass('active'); //remove active class from all the tabs link if it is there, it won't do anything
		 $(".mytabs").hide();
	});*/

	if($("#display_header_background_image").val()!="" && $("#display_header_background_image").val()!="undefined" && $("#display_header_background_image").val()!=null)	
		$('#intro').css("background-image", "url("+$("#display_header_background_image").val()+")");  
		
	$(".makemeblank").focus( function(){
		if($(this).val()==$(this).attr("defaulttext")){
			$(this).val('');
		}
	 });	
	$(".makemeblank").blur( function(){
		if($(this).val()==""){
			$(this).val($(this).attr("defaulttext"));
		}
	});
	
	if($("#location_time").val()!="undefined" && $("#location_time").val()!=undefined){
		var d=new Date();	
		var hr=d.getHours();
		if(hr<10){ hr="0"+""+hr; }
		var mn=d.getMinutes();
		if(mn<10){ mn="0"+""+mn; }
		var curtim=hr+""+mn;
		var day=d.getDay();
		var dbtimes=$("#location_time").val();
		var time_slots=dbtimes.split("|");
		dbtimes=time_slots[0].split(":");
		var dbtimes1="";
		var timarr1="";
		var secondtiming=false;
		if(time_slots[1]!=""){
			secondtiming=true;
			dbtimes1=time_slots[1].split(":");
			timarr1=dbtimes1[day].split("-");
		}
		var timarr=dbtimes[day].split("-");
		var storeopen=false;
		if(timarr[0]=="" && timarr[1]==""){
			storeopen=false;	
		}else{
			if(curtim>timarr[0]){
				if(timarr[1]=="" || curtim<timarr[1]){
					storeopen=true;	
				}
			}else if(timarr[0]=="" && curtim<timarr[1]){
				storeopen=true;
			}else if(curtim>timarr[0] && curtim<timarr[1]){
				storeopen=true;	
			}
		}
		
		if(secondtiming==true && storeopen==false){
			if(curtim>timarr1[0]){
				if(timarr1[1]=="" || curtim<timarr1[1]){
					storeopen=true;	
				}
			}else if(timarr1[0]=="" && curtim<timarr1[1]){
				storeopen=true;
			}else if(curtim>timarr1[0] && curtim<timarr1[1]){
				storeopen=true;	
			}
		}
		if(storeopen==true){
			$("#div_store_open").removeClass('hide');
			$("#div_store_close").addClass('hide');
		}else{
			$("#div_store_open").addClass('hide');
			$("#div_store_close").removeClass('hide');
		}
		
		$("#show_store_hours").click(function(){
			$("#div_store_hrs_head").removeClass("hide");
		});
		$("#a_store_hrs_close").click(function(){
			$("#div_store_hrs_head").addClass("hide");
		});

	}
	
	$(".reset_captcha").click(
		function(){
			$("#"+$(this).attr("image_id")).attr("src","visual-captcha.php?w="+$(this).attr("image_width")+"&h="+$(this).attr("image_height")+"&r="+Math.random());
		}					  
	);
});

function init_thickbox(){
	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
	imgLoader = new Image();// preload image
	imgLoader.src = tb_pathToImage;
}

function clear_form_elements(ele) {
    $(ele).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
                $(this).val('');
                break;
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    });
}
