
function openForm(url, name)
{
	return openPop(url, 'form', 'width=1040,height=800,menubar=no,toolbar=no,scrollbars=1,resizable=1,status=1');
}
function openHelp(url)
{
	return openPop(url, 'help', 'width=800,height=460,menubar=no,toolbar=no,scrollbars=1,resizable=1,status=1');
}
function openAnother(url)
{
	return openPop(url, '_blank', '');
}
function openPop(url, winName, winStyle)
{
	var newWin = null;
	try{
		newWin = window.open(url, winName, winStyle);
		if (newWin != 'undefined') {
			newWin.focus();
		}
	} catch (e) {
		alert(e);
	}
	return newWin;	
}

function attachOpenHelp(selector)
{
	$(selector).click(function () {
		openHelp($(this).attr('href'));
		return false;
	});
}

function attachTextboxWatermark(selector)
{
    swapValues=[];
    swapColors=[];
    $(selector).each(
        function(i){
            swapValues[i]=$(this).val();
            swapColors[i]=$(this).css("color");
            $(this).focus(function()
                {
                    if($(this).val()==swapValues[i])
                    {
                        $(this).val("");
                        $(this).css("color", "#000000");
                    }
                }
            ).blur(function()
                {
                    if($.trim($(this).val())=="")
                        {
                            $(this).val(swapValues[i]);
                            $(this).css("color", swapColors[i]);
                        }
                 }
            );
        }
    );
}
/*
 * 入力例に一致する文字が初期値として与えられている場合は　attachTextboxWatermark をする
 * 入力例に一致しない文字が初期値として与えられている場合は attachTextboxWatermark をしない
 * @param  object selector
 * @param  string  keyword
 */
function attachTextboxWatermarkWithKeyword(selector, keyword)
{
    if ( $(selector).val() == keyword ){
        attachTextboxWatermark(selector);
    } else {
        $(selector).css('color', "#000000")
    }
}