//サーバ用
var root = "http://www.petseek.jp/";

//ローカル
if (location.host=='pet.localhost') {
	root = "http://pet.localhost/";
}

root = '/';

// alert(location.host);

imageDir = root + "img/";
uploadDir = imageDir + "uploads/";
iconDir = imageDir + "icon/";
loading_img = imageDir + "loading.gif";
loading_info = '<img src="' + loading_img + '" />通信中。。。';

loading_img_circle = imageDir + "loading_circle.gif";
loading_info_circle = '<img src="' + loading_img_circle + '" style="margin:auto;" />';

try{
	$(document).ready(firstFunction);
}catch(e){}

function firstFunction(){

	// input type=textとテキストエリアのバックグラウンド
	$('input.basicText, input[type=password], textarea').focus(
			function(){
				$(this).css("background-color", "#eeeeee");
			}
		);
	$('input.basicText, input[type=password], textarea').blur(
			function(){
				$(this).css("background-color", "#ffffff");
			}
		);
	// テキストフィールドデフォルト
	$("input.basicText, textarea, input-table input[type=text]").fieldtag({ markedClass: "defaultText"});

	$('.alphaOver').hover(
		function(){ $(this).fadeTo(200, 0.6); },
		function(){ $(this).fadeTo(200, 1.0); }
	);

}

/**
 * 薄い文字クリア
 * @return
 */
function clearFirstTag(){
	$("input.basicText, textarea, input-table input[type=text]").each(function(){
		try{
			this.clear();
		}catch(e){

		}
	});
}


function changeKeywordCategory(obj, index){
	jQuery('.mainSerchUl li a').removeClass('selected');
	jQuery(obj).addClass('selected');
	// obj.className = 'selected';

	jQuery(obj).blur();
	jQuery('#serch_category_id').val(index);
	if(jQuery('#serch_keyword').val() != ""){
		goSerch();
	}
}

function goSerch(){
	var category_id = jQuery('#serch_category_id').val();
	var keyword = jQuery('#serch_keyword').val();
	var type="shop";
	// alert(category_id);
	if(category_id == 0){ type="site"; }
	if(category_id == -1){
		type="serchAll";
		var target = root + "others/serchAll/" + keyword;
	}else{
		var target = root + type + "/serch/" + category_id + "/" + keyword;
	}
	location.href=target;
}

/**
 * テキストフィールドデフォルト
 */
/*
jQuery Fieldtag Plugin
    * Version 1.1
    * 2009-05-07 10:10:35
    * URL: http://ajaxcssblog.com/jquery/fieldtag-watermark-inputfields/
    * Description: jQuery Plugin to dynamically tag an inputfield, with a class and/or text
    * Author: Matthias Jäggli
    * Copyright: Copyright (c) 2009 Matthias Jäggli under dual MIT/GPL license.
*/

(function($){$.fn.fieldtag=function(options){var opt=$.extend({markedClass:"tagged",standardText:false},options);$(this).focus(function(){if(!this.changed){this.clear();}}).blur(function(){if(!this.changed){this.addTag();}}).keyup(function(){this.changed=($(this).val()?true:false);}).each(function(){this.title=$(this).attr("title");if($(this).val()==$(this).attr("title")){this.changed=false;}
this.clear=function(){if(!this.changed){$(this).val("").removeClass(opt.markedClass);}}
this.addTag=function(){$(this).val(opt.standardText===false?this.title:opt.standardText).addClass(opt.markedClass);}
if(this.form){this.form.tagFieldsToClear=this.form.tagFieldsToClear||[];this.form.tagFieldsToClear.push(this);if(this.form.tagFieldsAreCleared){return true;}
this.form.tagFieldsAreCleared=true;$(this.form).submit(function(){$(this.tagFieldsToClear).each(function(){this.clear();});});}}).keyup().blur();return $(this);}})(jQuery);


