/*@cc_on _d=document;eval('var document=_d');@*/

var URLROOT = 'http://' + location.hostname + '/';

function dw(obj){
	alert(var_dump(obj));
}
function var_dump(obj) {
	if(typeof(obj) == "object") {
		return "Type: "+ typeof(obj) + ((obj.constructor) ? "\nConstructor: "+ obj.constructor : "") + "\nValue: " + obj;
	}else{
		return "Type: " + typeof(obj) + "\nValue: " + obj;
	}
}
function MyRand(max){
	var ret = max * Math.random();
	if(ret == 0.0){
		ret = 1;
	}else{
		ret = Math.ceil(ret)
	}
	return ret;
}

//Validation
var validators = new Array();
function isValid(messageNode){
	if(messageNode == undefined){
		messageNode = '#msg';
	}
	var msg = '';
	var msgs = '';
	var valid = true;
	if($(messageNode).length > 0){
		$(messageNode).contents().remove();
	}
	for(validator in validators){
 		if(typeof validators[validator] == "string"){
 			if((msg = eval(validators[validator])) != null){
				$(validator).addClass('warn');
				msgs += '<span>' + msg + '</span><br />';
				valid = false;
			}else{
				$(validator).removeClass('warn');
			}
		}
	}
	if($(messageNode).length > 0 && msgs != ''){
				$(messageNode).append(msgs);
	}
	return valid;
};

String.prototype.nl2br = function(){
	return this.replace(/\r?\n/g, '<br />');
}

function is_email(val){
	return val.match(/^[_a-z0-9-]+([\._a-z0-9-\+]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i);
}

function is_telno(val){
	return val.match(/^[0-9]+[0-9\-]*[0-9]+$/i);
}

function changeView(editable){
	$('.view').each(function (){
		this.style.display = (editable ? 'none' : '');
	});
	$('.edit').each(function(){
		this.style.display = (editable ? '' : 'none');
	});
}

function innerScroll(selecter){
	$('html,body').animate(
		{scrollTop: $(selecter).offset().top}
		, {easing: "easeOutExpo"}
	); 
}

jQuery(document).ready(function($){
	if($('no_wall').length == 0){
		
		if($.cookie('wall') == null || (MyRand(5) > 4)){
			$.cookie('wall', 'style/img/back/' + MyRand(6) + '.jpg', { expires: 1 });
		}
		
		$('html').css({'background-image':'url("' + $.cookie('wall') + '")'});
		}
		
		/*@cc_on
		if($.browser.msie && $.browser.version < 7){
			$('a#head_aboutus').hover(function(){
				$('a#head_aboutus > img').css('background-position', 'center -20px');
				return false;
			}, function(){
				$('a#head_aboutus > img').css('background-position', 'center 0px');
				return false;
			});
			$('a#head_contact').hover(function(){
				$('a#head_contact > img').css('background-position', 'center -20px');
				return false;
			}, function(){
				$('a#head_contact > img').css('background-position', 'center 0px');
				return false;
			});
			$('div#newsbox > h2').css('overflow-y', 'hidden');
			$('div#newsbox > h2').css('height', '38px');
		}
		
		@*/
});
