/* common js functions */

/**
 * opens a new window and loads the specified url
 * @return reference to the new window
*/
function openInNew(strUrl, strTitle, intWidth, intHeight, blnFocus) {
    if (intWidth==null) {intWidth="300";}
    if (intHeight==null) {intHeight="200";}

	//center the window
    var intLeft = (screen.availWidth-intWidth)/2;
    var intTop = (screen.availHeight-intHeight)/2;

	//replace all spaces
	strTitle=strTitle.replace(" ","_");

    var newWin=window.open(strUrl,strTitle,"width="+intWidth+",height="+intHeight+",left="+intLeft+",top="+intTop+",dependent=yes,scrollbars=yes,resizable=yes,directories=no,location=no,menubar=no,titlebar=no,toolbar=no,status=no");
    if (newWin) {
	    if (blnFocus!=false) {  //not the same as (!blnFocus) - handles null better
	        newWin.focus();
	    } 
    } else {
    	alert("This action opens a new window. Please add www.kitchentuneup.com to your list of sites allowed to open popups.");
    }
    return newWin;
}

/**
 * submits a form to a new window
 * @return reference to the new window
*/
function submitToNew(frm, intWidth, intHeight, blnFocus) {
	var newWin=openInNew("about:blank",intWidth,intHeight,blnFocus);
	frm.target=newWin.name;
	frm.submit();
}


