// JavaScript Document

/* ===============================================
  Roll over
=============================================== */
	function initRollOverImages(){
		var image_cache = new Object();
		$("img.rover,input.rover").each(function(i){
			var imgsrc = this.src;
			var dot = this.src.lastIndexOf('.');
			var imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
			image_cache[this.src] = new Image();
			image_cache[this.src].src = imgsrc_ro;
			$(this).hover(function(){
				this.src = imgsrc_ro;
			},function(){
				this.src = imgsrc;
			});
		});
	}

/* ===============================================
  Menu active
=============================================== */
	function Menu_active(id){
		if(id != ''){
			var target_img = "img#"+id;
			$(target_img).each(function(i){
				dot = this.src.lastIndexOf('.');
				var imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
				this.src = imgsrc_ro;

				$(this).hover(function(){
					this.src = imgsrc_ro;
				},function(){
					this.src = imgsrc_ro;
				});
			});
		}
	}

/* ===============================================
  Menu active (text)
=============================================== */
	function localMenu_active(id){
		if(id != ''){
			var target_img = "li#"+id;
			$(target_img).each(function(i){
				$(this).addClass("on");
			});
			var target_img = "dd#"+id;
			$(target_img).each(function(i){
				$(this).addClass("on");
			});
		}
	}
	
/* ===============================================
  Focus to input,textarea
=============================================== */
	function InputFocus(){
		$('input[type=text],input[type=password]').addClass('input-usually');
		$('.input-usually').focus(function(){
			$(this).addClass('input-focus');
		});
		$('.input-usually').blur(function(){
			if($(this).find('.input-focus')){
				$(this).removeClass('input-focus');
			}
		});
	}


/* ===============================================
  Drop down menu
=============================================== */

$(document).ready(function(){
		$('li.headlink').hover(
			function() { $('ul', this).css('display', 'block'); },
			function() { $('ul', this).css('display', 'none'); });
	});


/* ===============================================
  Run Functions
=============================================== */
$(document).ready(function(){
	//Mouse Over
	initRollOverImages();
	//input focus
	InputFocus();
});
