jQuery(document).ready(function(){
	if(jQuery(".AutoBlurText").length > 0) {
		inputText(".AutoBlurText");	
	}
	initSlide();
	var isOpen = false;
	if(jQuery(".LoginLink").length > 0) {
		jQuery(".LoginLink").bind("click", function(e){
			if(!isOpen) {											   
				jQuery(this).closest(".SubBlock01Inner").find(".Hidden").removeClass("Hidden");
				jQuery(this).addClass("Open");
				isOpen = true;
			}
			else {
				jQuery(this).closest(".SubBlock01Inner").find(".FormStyle").addClass("Hidden");
				isOpen = false;
				jQuery(this).removeClass("Open");
			}
			e.stopPropagation();
		})
		jQuery(".LoginLink").parent().bind("click", function(e){
			jQuery(".SubBlock01Inner .FormStyle").removeClass("Hidden");											
			e.stopPropagation();
			isOpen = true;
			jQuery(this).find(".LoginLink").addClass("Open");
		})
		jQuery(document).bind("click", function(){
			jQuery(".SubBlock01Inner .FormStyle").addClass("Hidden");
			isOpen = false;
			jQuery(".LoginLink").removeClass("Open");
		})
	}
	
	if(jQuery('#rest').length > 0) {
		jQuery('#rest').selectBox();
	}
		
	jQuery('.Region').each(function(){
		jQuery(this).tooltip();
	});
	
	//password replace
	jQuery('.password-fake-field').each(function () {
		var input = jQuery(this);
		var pass = input.next().hide();

		input.bind('focus', function () {
			input.hide();
			pass.show().focus();
		});
		pass.bind('blur', function () {
			if ( pass.val() == '' ) {
				input.show();
				pass.hide();
			}
		});
	});
})
function inputText(cssSel,NewInputClass){

	jQuery(cssSel).each(function(){
		var tagName = this.tagName.toLowerCase();
		var tempString = "";
		if(tagName=="textarea")
			tempString = this.title;
		else if(tagName=="input")
			tempString = this.alt;

		if(tempString!="")
		{
			jQuery(this).bind("blur",function(){
				if(jQuery(this).val()=="")
				{
					jQuery(this).val(tempString);
					jQuery(this).addClass(NewInputClass);
				}
			}).bind("focus",function(){
				if(jQuery(this).val()==tempString)
				{
					jQuery(this).val("");
					jQuery(this).removeClass(NewInputClass);
				}
			});
		}
	});
}
function initSlide(){
	if(jQuery(".SlideObj").length> 0){
		if(jQuery(".SlideObj .StopSlide").length > 1){
			var bannerSlider = new $slidesPresentation( jQuery(".SlideObj"), {
				control: jQuery(".SlidePaging"),
				play_backward: false, //default is false : play forward
				delay: 7 //in second(s)
			});
			jQuery(".StopSlide").each(function() {
				var thisItem = jQuery(this);
				/*var target = "#control_" + thisItem.parent().attr("id");
				jQuery(target).find("li").bind("mouseover", function () {
					bannerSlider.clearTimer();
				});*/
				thisItem.bind("mouseover", function (evt) {
					bannerSlider.clearTimer();
				});
				thisItem.bind("mouseout", function (evt) {
					bannerSlider.autoPlay();
				});
			});
		}
	}	
	function play(flag){
		alert(flag);	
	}
}

