var timeout = 0;
$(document).ready(function(){
	$(".fader").fader();
	calendarOver();
	$.fn.iNav();
});
$.fn.iNav=function(){
	$("#nav li.dropdown").hover(function(){
		var i = $(this);
		timeout = setTimeout(function(){i.addClass("hov").children("ul").slideDown("fast")},350);
	},function(){
		clearTimeout(timeout);
		$(this).removeClass("hov").children("ul").slideUp("fast");
	});
}
function calendarEvent(){document.forms.LargeCalendar.submit();}
function calendarOver(){
	$(".active").hover(function(){
		var cell = $(this);
		timeout = setTimeout(function(){cell.addClass("hov").children(".detail").show("fast")},500);
	},function(){
		clearTimeout(timeout);
		$(this).removeClass("hov").children(".detail").hide("fast");
	});
}
//submenu's section
function subnav(el,sel){
	$("."+el).each(function(){
		if (($(this).length)&&($(this).children().children("."+sel).length)) {
			$(this).children(".selector").animate({"width":$(this).children().children("."+sel).width()+"px","left":$(this).children().children("."+sel).position().left+"px"},"slow");
		}
	});
}
function initSubpage(defaultValue){
	var anch = window.location.href;
	if (anch.indexOf('#') != -1) {
		anch = anch.substr((anch.indexOf('#')+1), (anch.length - anch.indexOf('#')));
		$("."+anch).addClass("subsel");
	} else {
		$("."+defaultValue).addClass("subsel");
	}
}
function initTabs(defaultValue){
	initSubpage(defaultValue);
	$(".subsel").show();
	subnav("tabs","subsel");
	$(".tabs a").click(function(){
		var id = $(this).attr("href");
		id = id.substr((id.indexOf('#')+1), (id.length - id.indexOf('#')));
		$(".tab").hide();
		$(".subsel").removeClass("subsel");
		$("."+id).addClass("subsel").show();
		subnav("tabs","subsel");
	});
}

function changeDisable(){
	 removeDis();
     if(document.GiftPackagesForm.get_radiogroup){
         var numradios = document.GiftPackagesForm.get_radiogroup.length;
             if(numradios > 0){
                 for(var i=0; i<numradios; i++){
                     if(document.GiftPackagesForm.get_radiogroup[i].checked){
                            var value = document.GiftPackagesForm.get_radiogroup[i].value;
                            if(value == 1){
                            	document.getElementById('pakages').style.display = "block";
                                document.getElementById('get_packages').disabled = false;
                                document.getElementById('custom_amount_sel').style.display = "none";
                                document.getElementById('custom_amount').style.display = "none";
                            }else{
                            	document.getElementById('custom_amount_sel').style.display = "block";
                                document.getElementById('custom_amount').style.display = "block";
                                document.getElementById('get_custom_amount').disabled = false;
                                document.getElementById('get_custom_amount_sel').disabled = false;
                                document.getElementById('pakages').style.display = "none";
                            }
                     }
                 }   
             }
     }                  
}
