function sWinopen(wUrl,wName,wWidth,wHeight,wScroll) {
	var wArg = "";
	wArg = wArg + "menubar=no";
	wArg = wArg + ",location=no";
	wArg = wArg + ",toolbar=no";
	wArg = wArg + ",resizable=yes";
	wArg = wArg + ",status=no";
	if (wScroll != "") {
		wArg = wArg + ",scrollbars=" + wScroll;
	 } else {
		wArg = wArg + ",scrollbars=no";
	}
	if (wHeight != "") {
		wArg = wArg + ",height=" + wHeight;
	}
	if (wWidth != "") {
		wArg = wArg + ",width=" + wWidth;
	}
	var wTop = 0;
	if (wHeight != "") {
		wTop = Number(window.screen.availHeight - wHeight)/2;
	}
	wArg = wArg + ",top=" + wTop;
	var wLeft = 0;
	if (wWidth != "") {
		wLeft = Number(window.screen.availWidth - wWidth)/2;
	}
	wArg = wArg + ",left=" + wLeft;
    wWin = window.open(wUrl, wName, wArg);
    wWin.focus();
}
function sWinopen2(wUrl) {
	var IE = navigator.appName.indexOf('Microsoft',0) != -1;
	var NN = navigator.appName.indexOf('Netscape',0) != -1;
	var scWidth = screen.availWidth;
	var scHeight = screen.availHeight;
	var setw = 'toolbar=no,location=no,directories=no,status=no,menubar=no,personalbar=no,scrollbars=yes,resizable=yes,top=0,left=0,';
	if(IE) {
		setw = setw + 'width=' + (scWidth-12) + ',height=' + (scHeight-31);
	}
	else if(NN){
		setw = setw + 'outerwidth=' + scWidth + ',outerheight=' + scHeight;
	}
	else {
		setw = setw + 'width=' + scWidth + ',height=' + scHeight;
	}

	max_window = window.open(wUrl,'win1',setw);
	max_window.focus();
}
function sWinopenVisitors() {
	var scWidth = 800;
	var scHeight = screen.availHeight;
	var setw = 'toolbar=no,location=no,directories=no,status=no,menubar=no,personalbar=no,scrollbars=yes,resizable=yes,top=0,left=0,';
	setw = setw + 'width=' + scWidth + ',height=' + scHeight;
	v_window = window.open('http://lifephotojournal.com/visitors/','winvisitors',setw);
	v_window.focus();
}

function OpenPreview (f) {
    window.open('blank.html', 'comments', 'left=150,top=100,width=640,height=480,scrollbars=yes,resizable=yes,status=yes');
	f.target = "comments";
	f.submit();
}

function sDisplay(id) {
    var disp = document.getElementById(id).style.display;
    if (disp == "none") {
        document.getElementById(id).style.display= "block";
		if (id != "post") {
			location.hash = id;
		} else {
			sSetFormValue();
		}
    } else {
        document.getElementById(id).style.display= "none";
    }
}


function sChange_jp_en(id1,id2) {
    var disp = document.getElementById(id1).style.display;
    if (disp == "none") {
        document.getElementById(id1).style.display= "block";
        document.getElementById(id2).style.display= "none";
    } else {
        document.getElementById(id1).style.display= "none";
        document.getElementById(id2).style.display= "block";
    }
}


var HOST = 'lifephotojournal.com';
function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") + (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}
function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}
function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}
function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    now = now.toGMTString();
    setCookie('mtcmtauth', f.author.value, now, '/', '', '');
    setCookie('mtcmtmail', f.email.value, now, '/', '', '');
    setCookie('mtcmthome', f.url.value, now, '/', '', '');
}
function forgetMe (f) {
    deleteCookie('mtcmtmail', '/', '');
    deleteCookie('mtcmthome', '/', '');
    deleteCookie('mtcmtauth', '/', '');
    f.email.value = '';
    f.author.value = '';
    f.url.value = '';
}
function sSetFormValue () {
    document.comments_form.author.value = getCookie("mtcmtauth");
    document.comments_form.url.value = getCookie("mtcmthome");
    document.comments_form.email.value = getCookie("mtcmtmail");
	if (getCookie("mtcmtauth") || getCookie("mtcmthome")) {
    	document.comments_form.bakecookie[0].checked = true;
	} else {
    	document.comments_form.bakecookie[1].checked = true;
	}
}

function rememberMe2 (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    now = now.toGMTString();
    setCookie('mtentauth', f.title.value, now, '/', '', '');
    setCookie('mtentmail', f.text.value, now, '/', '', '');
    setCookie('mtenthome', f.text_more.value, now, '/', '', '');
}
function forgetMe2 (f) {
    deleteCookie('mtentmail', '/', '');
    deleteCookie('mtenthome', '/', '');
    deleteCookie('mtentauth', '/', '');
    f.title.value = '';
    f.text.value = '';
    f.text_more.value = '';
}
function sSetFormValue2 () {
    document.comments_form.title.value = getCookie("mtentauth");
    document.comments_form.text.value = getCookie("mtentmail");
    document.comments_form.text_more.value = getCookie("mtenthome");
	if (getCookie("mtentauth") || getCookie("mtenthome")) {
    	document.entry_form.bakecookie[0].checked = true;
	} else {
    	document.entry_form.bakecookie[1].checked = true;
	}
	document.entry_form.title.focus();

}

function keystrokes(form) {
    form.userkeystrokes.value = 1;
}

function sSelectChange(theField) {
	var winTarget = "_self";
	open(theField[theField.selectedIndex].value, winTarget);
}
