
var sgSliver = new Object();

sgSliver.PublicController = function() {
	this.documentReady();
}

sgSliver.PublicController.prototype = {
	documentReady : function(){
		$(document).ready(function(){
			sgSliver.controller.dropDownMenu('div#globalNav ul li');
			sgSliver.controller.rollOver('div.shortCutNav01 a img');
			$('div.doctorList a, div.floorMap a').lightBox();
			//blank();
		});
	},
	dropDownMenu : function(target){
		$(target).hover(function(){
				$(this).find('a:first').addClass("on");
				$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(25);
			},function(){
				$(this).find('a:first').removeClass("on");
				$(this).find('ul:first').css({visibility: "hidden"});
			});
	},
	rollOver : function(target){
		var  postfix = '_o';
		$(target).not('[src*="'+ postfix +'."]').each(function() {
			var img = $(this);
			var src = img.attr('src');
			var src_on = src.substr(0, src.lastIndexOf('.')) + postfix + src.substring(src.lastIndexOf('.'));
			$('<img>').attr('src', src_on);
			img.hover(function() {
				img.attr('src', src_on);
			},function() {
				img.attr('src', src);
			});
		});			
	}
}

function addstring() {
	document.forms[0].q.value = 'site:sg-silver.or.jp' + document.forms[0].q.value;
	return true;
}


function blank(){
	var as = document.getElementsByTagName('a');
	for(var i=0; i<as.length; i++){
		var data = as[i].className;
		var ptnm = new  RegExp('target','i')
		if(data.match(ptnm)){
			as[i].setAttribute('target','_blank');
		};
	};
}

function addstring(){
	document.forms[0].q.value = 'site:http://sg-silver.or.jp/ ' + document.forms[0].q.value;
	return true;
}

function openWin(){
		/*
			 1. url      2. window name    3. width     4. height    5. resizable
			 6. toolbar  7. scrollbars     8. location  9. menubar  10. status
		*/
		var args = arguments,
		win_set = 'width=' + ((args[2])? args[2] : screen.width-30) 
			+ ',height=' + ((args[3])? args[3] : screen.height-30) 
			+ ',resizable=' + ((args[4])? 1 : 0) 
			+ ',toolbar=' + ((args[5])? 1 : 0) 
			+ ',scrollbars=' + ((args[6])? 1 : 0) 
			+ ',location=' + ((args[7])? 1 : 0) 
			+ ',menubar=' + ((args[8])? 1 : 0) 
			+ ',status=' + ((args[9])? 1 : 0);
		swin = window.open(args[0],args[1],win_set);
		swin.focus();
}

sgSliver.controller = new sgSliver.PublicController();
