// JavaScript Document

function getCSS(){
	var datetoday = new Date();
	var thehour = datetoday.getHours();
	var thesec = datetoday.getSeconds();
//	alert(thehour);
//	if ( ((thesec>=0)&&(thesec<10))||((thesec>=30)&&(thesec<40)) ){
//		var display = "common/daytime.css";
//	}
//	else if ( ((thesec>=10)&&(thesec<20))||((thesec>=40)&&(thesec<50)) ){
//		var display = "common/evening.css";
//	}
//	else{
//		var display = "common/night.css";
//	}
//	alert(display);
	if ( (thehour >= 5)&&(thehour < 11) ) {
		var display = "common/daytime.css";
	}
	else if ((thehour >= 11)&&(thehour < 17)) {
		var display = "common/evening.css";
	}
	else {
		var display = "common/night.css";
	}


	var css = '<link rel="stylesheet" type="text/css" href="' + display + '" id="jstyle" />';
//	alert("kou");
//	alert(css);
	document.write(css);
}
getCSS();

$(document).ready(function(){
	$('style').text($('textarea').val());
	$('textarea').keyup(function(){
		$('style').text($('textarea').val());
	});
});
$(function(){
    $("#popup_alert").click(function(){
        alert(  "popup"  );
        return false;
    });
});
//$.cookie('style', null);
//$(function() {$("#jstyle").attr( { href : $.cookie('style')});});

function jstyle(cssurl) {
//	alert($.cookie('style'));
//	$.cookie('style', null);
	$("#jstyle").attr( {href : cssurl});
	$.cookie('style', cssurl, { expires: 7, path: '/'});
//	alert('kou');
}

function RealTimer() {
	var date = new Date();
	var time = date.toLocaleString();
	var hour = date.getHours();
//	var min = date.getMinutes();
//	var sec = date.getSeconds();
//	if(hour < 10){ hour = "0" + hour; }
//	if(min < 10) { min = "0" + min; }
//	if(sec < 10) { sec = "0" + sec; }
//	if( ( ((sec+10) /10 ))%2 == 0 ){
//		if ( ((sec>=0)&&(sec<10))||((sec>=30)&&(sec<40)) ){
//
//	//		font('10px');
//			jstyle('common/css/indexstyle1.css');
//	//		var css = '<link rel="stylesheet" type="text/css" href="' + display + '" />';
//	//		document.write(css);
//	//		jstyle(css);
//	//		alert(css);
//		}
//		else if ( ((sec>=10)&&(sec<20))||((sec>=40)&&(sec<50)) ){
//			jstyle('common/css/indexstyle.css');
//	//			back();
//		}
//		else{
//
//	//		font('50px');
//			jstyle('common/css/indexstyle2.css');
//	//		jstyle(css);
//	//		alert(css);
//		}
//	}
	if ( (hour >= 5)&&(hour < 11) ) {
		jstyle('http://www.g-cafe.jp/common/daytime.css');
	}
	else if ((hour >= 11)&&(hour < 17)) {
		jstyle('http://www.g-cafe.jp/common/evening.css');
	}
	else {
		jstyle('http://www.g-cafe.jp/common/night.css');
	}



//	document.form1.text1.value = time;
	setTimeout("RealTimer()", 1000);
}
RealTimer();
