var dayName   = new Array("Sun.","Mon.","Tues.","Wed.","Thur.","Fri.","Sat.");
var monName   = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec");
var blank     = /^( *[\n\r]+ *)+$/;
var nothing   = /^$/;
var textInput = /^(text|textarea|password)$/i;

function showTime()
{
	var now=new Date();
	var weekDay=getWeekDay(now.getDay());
	var month=getThisMonth(now.getMonth());
	var hour=getThisHour(now.getHours());
	var minute=getThisMinute(now.getMinutes());
	var second=getThisSeconds(now.getSeconds());
	var value=weekDay+" "+month+" "+now.getDate()+", "+now.getFullYear()+" "+hour+":"+minute+":"+second;
	return value;
}
function getWeekDay(value)
{
	return dayName[value];
}
function getThisMonth(value)
{
	return monName[value];
}
function getThisHour(value)
{
	if(value<10)
	{
		value="0"+value;
	}
	return value;
}
function getThisMinute(value)
{
	if(value<10)
	{
		value="0"+value;
	}
	return value;
}
function getThisSeconds(value)
{
	if(value<10)
	{
		value="0"+value;
	}
	return value;
}
function displayTime(elem)
{
  	findDOM(elem).innerHTML=showTime();
  	setTimeout("displayTime('" + elem + "')",1000);
}
function findDOM(objectID) {
	var isDHTML = 0;
	var isLayers = 0;
	var isAll = 0;
	var isID = 0;
	if(document.getElementById) {
		isID = 1;
		isDHTML = 1;
	}else {
		if(document.all) {
			isAll = 1;
			isDHTML = 1;
		}else {
			browseVersion = parseInt(navigator.appVersion);
			if((navigator.appName.indexOf("Netscape") != -1) && (browseVersion == 4)) {
				isLayers = 1;
				isDHTML = 1;
			}
		}
	}
	
	if(isID) {
		return document.getElementById(objectID);
	}else {
		if(isAll) {
			return document.all[objectID];
		}else {
			if(isLayers) {
				return document.layers[objectID];
			}
		}
	}
}

function screenWidth() {
        var width;
        if( typeof( window.innerWidth ) == 'number' ) {
                //Non-IE
                width = parseInt(window.innerWidth);
        }else if( document.documentElement &&
                ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
                //IE 6+ in 'standards compliant mode'
                width = parseInt(document.documentElement.clientWidth);
        }else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                //IE 4 compatible
                width = parseInt(document.body.clientWidth);
        }
        return width;
}

function screenHeight() {
        var height;
        if( typeof( window.innerWidth ) == 'number' ) {
                //Non-IE
                height = parseInt(window.innerHeight);
        }else if( document.documentElement &&
                ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
                //IE 6+ in 'standards compliant mode'
                height = parseInt(document.documentElement.clientHeight);
        }else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                //IE 4 compatible
                height = parseInt(document.body.clientHeight);
        }
        return height;
}

function parent_screenWidth() {
	var width;
	if( typeof( parent.window.innerWidth ) == 'number' ) {
		//Non-IE
		width = parseInt(parent.window.innerWidth);
		//screenheight = parseInt(window.innerHeight);
	}else if( parent.document.documentElement &&
		( parent.document.documentElement.clientWidth || parent.document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		width = parseInt(parent.document.documentElement.clientWidth);
		//screenheight = parseInt(document.documentElement.clientHeight);
	}else if( parent.document.body && ( parent.document.body.clientWidth || parent.document.body.clientHeight ) ) {
		//IE 4 compatible
		width = parseInt(parent.document.body.clientWidth);
		//screenheight = parseInt(document.body.clientHeight);
	}  
	return width;
}

function parent_screenHeight() {
        var height;
        if( typeof( parent.window.innerWidth ) == 'number' ) {
                //Non-IE
                height = parseInt(parent.window.innerHeight);
        }else if( parent.document.documentElement &&
                ( parent.document.documentElement.clientWidth || parent.document.documentElement.clientHeight ) ) {
                //IE 6+ in 'standards compliant mode'
                height = parseInt(parent.document.documentElement.clientHeight);
        }else if( document.body && ( parent.document.body.clientWidth || parent.document.body.clientHeight ) ) {
                //IE 4 compatible
                height = parseInt(parent.document.body.clientHeight);
        }
        return height;
}

function loadingAds() {
	var add_area = findDOM('leaderBoard_box');
	add_area.style.display = "inline";
	add_area.style.width   = "728px";
	add_area.style.height  = "90px";
	add_area.src           = "/cgi-bin/leader_board.mcml";
	setTimeout("loadingAds()",30000);
}

function popBox(e, obj, w, h, file) {
	var popUpBox = findDOM(obj);
	if(popUpBox.style.display == "inline") { return; }
	var x                  = findXCoordinate(e) + 10;
	var y                  = findYCoordinate(e) - 5;
	popUpBox.style.display = "inline";
	popUpBox.style.left    = x + "px";
	popUpBox.style.top     = y + "px";
	popUpBox.style.width   = w + "px";
	popUpBox.style.height  = h + "px";
	popUpBox.src           = file;
}

function fillParentField(field, thisValue) {
	parent.document.all[field].value = thisValue;
}

function popTip(containerID, width, src, h) {
	if(findDOM(containerID + "_span")) { return; }
	var height = h ? h : 20;
	var span = document.createElement("span");
	span.setAttribute("id", containerID + "_span");
	span.setAttribute("name", containerID + "_span");
	span.innerHTML = "<img src=\"/images/gui/tip_icon.gif\" border=\"0\" />" +
			 "<iFrame id=\"tip_box\" name=\"tip_box\" style=\"width:" + width + "px;height:" + height +"px;position:absolute;z-index:1100;" +
			 "display:inline;padding:0px;border-width:1px;border-color:#666666;border-style:solid;\" frameborder=\"0\" " +
			 "marginwidth=\"0\" marginheight=\"0\" scrolling=\"auto\" noresize=\"noresize\" src=\"" + src + "\"></iFrame>";
	var container = findDOM(containerID);
	container.appendChild(span);
}

function removeTip(containerID,p) {
	var container = p ? parent.findDOM(containerID) : findDOM(containerID);
	var span      = p ? parent.findDOM(containerID + "_span") : findDOM(containerID + "_span");
	if(span) {
		hideObject(span);
		container.removeChild(span);
	}
}

function moveMsgBox(e, obj, w, h) {
	var popUpBox        = findDOM(obj);
	var x               = findXCoordinate(e) + 10;
	var y               = findYCoordinate(e) - 5;
	popUpBox.style.left = x + "px";
	popUpBox.style.top  = y + "px";
}

function clearPopBox(obj) {
        var popUpBox           = findDOM(obj);
        popUpBox.style.display = "none";
        popUpBox.src           = "";
}

function popBox_(e, obj, w, h, file) {
        var popUpBox           = findDOM(obj);
        var x                  = findXCoordinate(e);
        var y                  = findYCoordinate(e);
	var screen_width       = screenWidth();
	var screen_height      = screenHeight();
	var box_width          = parseInt(w);
	var box_height         = parseInt(h);
	if(box_width > screen_width - 20) {box_width = screen_width - 20;}
	var obj_x              = ((x + 10 + box_width) > screen_width) ? (x - box_width - 10) : (x + 10);
	if(obj_x < 0) {obj_x = 0;}
	if(box_height > screen_height - 20) {box_height = screen_height - 20;}
	var obj_y              = ((y + 10 + box_height) > screen_height) ? (y - box_height -10) : (y + 10);
	if(obj_y < 0) {obj_y = 0;}
 
        popUpBox.style.display = "inline";
        popUpBox.style.left    = obj_x + "px";
        popUpBox.style.top     = obj_y + "px";
        popUpBox.style.width   = box_width + "px";
        popUpBox.style.height  = box_height + "px";
        popUpBox.src           = file;
}

function moveMsgBox_(e, obj, w, h) {
        var popUpBox        = findDOM(obj);
        var x               = findXCoordinate(e);
        var y               = findYCoordinate(e);
	var screen_width    = screenWidth();
        var screen_height   = screenHeight();
	var box_width       = parseInt(w);
        var box_height      = parseInt(h);
	var obj_x           = ((x + 10 + box_width) > screen_width) ? (x - box_width - 10) : (x + 10);
        if(obj_x < 0) {obj_x = 0;}
        var obj_y            = ((y + 10 + box_height) > screen_height) ? (y - box_height -10) : (y + 10);
        if(obj_y < 0) {obj_y = 0;}

        popUpBox.style.left = obj_x + "px";
        popUpBox.style.top  = obj_y + "px";
}

// hide an element
function hide(elementID) {
	var element = findDOM(elementID);
	if(element) {
		hideObject(element);
	}
}
// hide an object
function hideObject(obj) {
	if(obj.innerHTML) {
		obj.innerHTML = "";
	}
	obj.style.display = "none";
}
// find the Y coordinate of a moving mouse

function parent_show(elem, html) {
        var obj = parent.findDOM(elem);
	if(!obj) { return; }
        obj.style.display = "inline";
        if(html) {
                obj.innerHTML = unescape(html);
        }
}

function parent_hide(elem) {
	var obj = parent.findDOM(elem);
	if(obj) {
		hideObject(obj);
	}
}

function opener_show(elem, html) {
        var obj = opener.findDOM(elem);
        obj.style.display = "inline";
        if(html) {
                obj.innerHTML = unescape(html);
        }
}

function show(elem, html) {
	var obj = findDOM(elem);
	obj.style.display = "inline";
	if(html) {
		obj.innerHTML = unescape(html);
	}
}

function findYCoordinate(e) {
	if(e.y) {
		return parseInt(e.y) + parseInt(document.body.scrollTop);
	}
	if(e.pageY) {
		return parseInt(e.pageY);
	}
}

// find the X coordinate of a moving mouse
function findXCoordinate(e) {
	if(e.x) {
		return parseInt(e.x) + parseInt(document.body.scrollLeft);
	}
	if(e.pageX) {
		return parseInt(e.pageX);
	}
}

function saveToCookbook(rcid,action,width,height) {
	popup('/cgi-bin/save_to_cookbook.mcml?rcid='+rcid+'&action='+action,width,height);
}

function emailRecipe(rcid,width,height) {
	popup('/cgi-bin/email_recipe.mcml?rcid='+rcid,width,height);	
}

function popup(url,width,height,scroll) {
	var leftPos   = 0;
        var topPos    = 0;
	var scrollBar = scroll ? "yes" : "no";
	var winName   = 'pop_me';
	if(screen) {
		leftPos = (screen.width - parseInt(width)) / 2;
		topPos  = (screen.height - parseInt(height)) / 2;
	}
	window.open(url,winName,'status=no,toolbar=no,location=no,scrollbars='+scrollBar+',width='+width+',height='+height+',left='+leftPos+',top='+topPos);
}

function deleteRecipe(thisForm, cookbookid, recipe, category) {
	if(confirm("Recipe \"" + unescape(recipe) + "\"\nwill be deleted from your \"" + unescape(category) + "\" category\nDo you want to continue?")) {
		thisForm.cookbookid.value = cookbookid;
		thisForm.action.value = 'delete';
		thisForm.submit();
	}
	return;
}

// further modification will use this function to replace deleteRecipe, deleteCategory, etc.
function deleteItem(frame,url,type,name,source) {
	var message = type + " \"" + unescape(name) + "\"\nwill be deleted from your \"" + unescape(source) + "\"\nDo you want to continue?"; 
	if(confirm(message)) {
		 findDOM(frame).src = url;
	}
	return;
}

function editCategory(catid,action) {
        var leftPos = 0;
        var topPos  = 0;
        var winName = 'save_'+catid;
        if(screen)
        {
                leftPos=(screen.width-400)/2;
                topPos=(screen.height-220)/2;
        }
        window.open('/cgi-bin/add_user_category.mcml?categoryid='+catid+'&action='+action,winName,'status=no,toolbar=no,location=no,scrollbars=no,width=400,height=220,left='+leftPos+',top='+topPos);
}

function deleteCategory(thisForm, categoryid, category) {
      if(confirm("Category \"" + unescape(category) + "\" and all the recipes it stores\nwill be deleted from your cookbook.\nDo you want to continue?")) {
                thisForm.categoryid.value = categoryid;
                thisForm.action.value = 'delete';
                thisForm.submit();
      }
      return;
}

// advanced validation done on the server
// this submits an iframe hidden form
function submitHForm(action, delimiter, hScript, hForm, formFields) {
        var myScript = frames[hScript];
        var myForm   = myScript.document.forms[hForm];
        var myFields;
	if(formFields.indexOf(delimiter) < 0) {
		myFields = new Array(formFields);
	}else {
		myFields = formFields.split(delimiter);
	}
        for(var i = 0; i < myFields.length; i++) {
                var value = trimString(document.all[myFields[i]].value);
                myScript.document.all[myFields[i]].value = value;
        }
	myScript.document.all['action'].value = action;
        myForm.submit();
        return true;
}

function page(url) {
	top.location.href = mediaClayUrl(url);
}

function mediaClayUrl(url) {
	if(url.substring(0,1) != "/") { url = "/" + url; }
	return url;
}

function goToRegister() {
	parent.document.location='/Register';	
}

function forgetLoginData() {
	parent.document.location='/Forget_Login_data';
}

function jumpToPage(url) {
	document.location=url;
}

function htdig(thisForm, element, object) {
	var form_element = document.all[element];
	var input   = trimString(form_element.value);
	form_element.value = input;
	if (input == "") {
		show(object);
 		return false;
	}
	return true;
}

function trimString(string) {
	string = string.replace(/^ +/,'');
	string = string.replace(/ +$/,'');
	return string;
}

function selectPage(thisForm, action, start) {
	document.all['action'].value = action;
	document.all['start'].value = start;
	document.all[thisForm].submit();
}

function submitForm(thisForm, action) {
	thisForm.form_action.value = action;
	thisForm.submit();
}

function searchRecipes(thisForm) {
	eraseCookie("rcsclause");
	thisForm.action.value = "search_recipe";
	thisForm.submit();
}

function searchUsers(thisForm) {
        eraseCookie("ursclause");
        thisForm.action.value = "search_user";
        thisForm.submit();
}

function spawnChild(thisForm, selectedMenu) {
        var menu = document.all[selectedMenu];
        var component = selectedMenu.split("_");
        var spawner_parent = component[2];
        var spawner_collection = thisForm.spawner_collection.value;
        var spawner = menu.value;
        spawner_collection = spawner_collection.replace(/ /g, '');
	if(spawner_collection == "") {
		spawner_collection = spawner_parent + ":" + spawner;
	}else {
		var reg_spawner_parent = new RegExp(spawner_parent);
		if(spawner_collection.match(reg_spawner_parent)) {
			var collections = spawner_collection.split(",");
			for(var i=0; i < collections.length; i++) {
				if(collections[i].match(reg_spawner_parent)) {
					collections[i] = spawner_parent + ":" + spawner;
					break;
				}
			}
			spawner_collection = collections.join(",");
		}else {
			spawner_collection += "," + spawner_parent + ":" + spawner;
		}
	}
	thisForm.spawner_action.value = "spawn_child";
        thisForm.spawner_collection.value = spawner_collection;
        thisForm.submit();
}

function addRecipe(thisForm) {
	thisForm.action.value = "add_recipe";
	thisForm.submit();
}

function addRecipe_spawnChild(thisForm, selectedMenu, type) {
	var menu = document.all[selectedMenu];
	thisForm.spawner_action.value = "spawn_child";
	if(type == "f") {
		thisForm.level2_spawner.value = menu.value;
		thisForm.spawner_type.value = "f";
	}
	if(type == "ct") {
		thisForm.spawner.value = menu.value;
		thisForm.spawner_type.value = "ct";
	}
	thisForm.action.value = "";
	thisForm.submit();
}

function eraseCookie(cookieID) {
	//pass in parameter: cookie ID
	expireCookie(getCookie(cookieID));
}

function expireCookie(cookie) {
	// pass in parameter: cookie string, ex myid=123456
	var expireDate = new Date;
	expireDate.setDate(expireDate.getDate()-1);
	var arr = cookie.split("=");
	document.cookie = arr[0] + "=;expires=" + expireDate.toGMTString() + ";path=/";
}

function getCookie(cookieID) {
	// pass in parameter: cookie id, ex abcd in abcd=123456, return cookie string
	var cookie = document.cookie;
	var cookies = cookie.split(";");
	var re = new RegExp(cookieID + "=");
	for(var i=0; i<cookies.length; i++) {
		var curValue = trimString(cookies[i]);
		if(curValue.match(re)) {
			return curValue;
		}
	}
	return "";
}

function autoSize() {
	self.resizeTo(650,(parseInt(getContentHeight()) + 80));
}

function addUpButton(upButton, p) {
	if(p) { //invoke from child frame
		if(parseInt(parent_getContentHeight()) > parseInt(parent_screenHeight())) {	
			parent_show(upButton, "<a href='#'><img border='0' src='/images/up.gif' alt='top'/></a>");		
		}
	}else {
		if(parseInt(getContentHeight()) > parseInt(screenHeight())) {
			show(upButton, "<a href='#'><img border='0' src='/images/up.gif' alt='top'/></a>");
		}
	}
}

function setFrameHeight(frame,width) {
	var myFrame = parent.findDOM(frame);
	//if(myFrame) { myFrame.style.height = (10 + getContentHeight()) + "px" };
	if(myFrame) { 
		myFrame.style.height = getContentHeight() + "px"; 
		if(width) { myFrame.style.width = width + "px"; }
	};
	// let parent add up button
	addUpButton('upbutton', 'parent');
}



function getContentHeight() {
	var contentHeight;
	if (typeof document.height != "undefined") {
		contentHeight = document.height;
	}
	else if (document.compatMode && document.compatMode != "BackCompat") {
		contentHeight = document.documentElement.scrollHeight;
	}
	else if (document.body && typeof document.body.scrollHeight != "undefined") {
		contentHeight = document.body.scrollHeight;
	}
	return contentHeight;
}

function parent_getContentHeight() {
        var contentHeight;
        if (typeof parent.document.height != "undefined") {
                contentHeight = parent.document.height;
        }
        else if (parent.document.compatMode && parent.document.compatMode != "BackCompat") {
                contentHeight = parent.document.documentElement.scrollHeight;
        }
        else if (parent.document.body && typeof parent.document.body.scrollHeight != "undefined") {
                contentHeight = parent.document.body.scrollHeight;
        }
        return contentHeight;
}

function pageHeight() {
	alert("Screen height: " + screenHeight() + "\nPage content height: " + getContentHeight());
}

function blankEntry(string) {
	return (blank.test(string) || nothing.test(string)) ? true : false;
}

function popNewWindow(w, h, url) {
        var winName = 'new_w';
        //window.open(mediaClayUrl(url),winName,'status=no,toolbar=no,location=no,scrollbars=yes,width='+w+',left=0,top=0');
        window.open(mediaClayUrl(url),winName,'status=no,toolbar=no,location=no,scrollbars=yes,width='+w+',height='+h+',left=0,top=0');
}

function logout() {
	if(confirm("are you sure you want to sign out?")) {
		findDOM('function').src = '/cgi-bin/logout.mcml';
	}
	return;
}

function clearFormFields(delimiter, formFields) {
        var myFields;
        if(formFields.indexOf(delimiter) < 0) {
                myFields = new Array(formFields);
        }else {
                myFields = formFields.split(delimiter);
        }	
        for(var i = 0; i < myFields.length; i++) {
                document.all[myFields[i]].value = "";
	}	
}
 
function createXMLHttpObj() {
	var xmlhttp;
	try {
		xmlhttp = new ActiveXObject( "Msxml2.XMLHTTP" );
	}catch(e) {
		try {
			xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
		}catch(e1) {
			xmlhttp = false;
		}
	}
	if(!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function checkUserSessionTimeout() {
/*        var time = new Date();
        var s = time.getMilliseconds();
        var xmlhttp = createXMLHttpObj();
        var url = "/cgi-bin/dhtml/check_user_session_timeout.mcml?s=" + s;
        xmlhttp.open( "GET", url, false );
        xmlhttp.send(null);
        var sessionStatus = xmlhttp.responseText;
        if(sessionStatus == "ok") {
                setTimeout("checkUserSessionTimeout()",15000);
        }else {
                eraseCookie("sessionid");
               	document.location="/timeout";
        }
*/
}

function checkOnlineUsers() {
/*	var checker = findDOM("online_user_checker");
	checker.src = "/cgi-bin/dhtml/check_onlineusers.mcml";	
        setTimeout("checkOnlineUsers()",15000);
*/
}

function updateUserSession() {
/*        var time = new Date();
        var s = time.getMilliseconds();
	var xmlhttp = createXMLHttpObj();
        var url = "/cgi-bin/dhtml/update_user_session.mcml?s=" + s;
        xmlhttp.open( "GET", url, false );
        xmlhttp.send(null);
        var status = xmlhttp.responseText;
*/
}

function focusCursor(thisForm) {
	var myForm = document.forms[thisForm];
	if(!myForm) { return; }
	for(var i = 0; i < myForm.length; i++) {
		var element = myForm.elements[i];
		var type = element.type;
		var value = element.value;
		if(value == "" && textInput.test(type)) {
			if(!element.disabled) {
				element.focus();
			}
			break;
		}
	}
}

function checkFileUploader(cookieName, containerID, fileFieldID, syblingID, words) {
	if(!getCookie(cookieName)) { return; }
	enableFileUploader(cookieName, containerID, fileFieldID, syblingID, words);
}

function enableFileUploader(cookieName, containerID, fileFieldID, syblingID, words) {
	if(findDOM(fileFieldID)) { return; }
	var container = findDOM(containerID);
	var syblingContainer = findDOM(syblingID);
	var fileField = document.createElement("input");
	fileField.setAttribute("id", fileFieldID);
	fileField.setAttribute("name", fileFieldID);
	fileField.setAttribute("type", "file");
	var anchor = document.createElement("a");
	anchor.setAttribute("id", fileFieldID + "_cancel");
	anchor.setAttribute("href", "javaScript:disableFileUploader('" + cookieName + "','" + containerID + "','" + fileFieldID + "','" + syblingID + "')");
	var span   = document.createElement("span");
	span.setAttribute("id", syblingID + "_span");
	var text   = document.createTextNode(words);
	var remove = document.createTextNode(" [Remove]");
	span.appendChild(text);
	syblingContainer.appendChild(span);
	anchor.appendChild(remove);
	container.appendChild(fileField);
	container.appendChild(anchor);
	if(!getCookie(cookieName)) { document.cookie = cookieName + "=1;path=/"; }
	return;
}

function disableFileUploader(cookieName, containerID, fileFieldID, syblingID) {
	var fileField = findDOM(fileFieldID);
	if(fileField) { 
		var container = findDOM(containerID);
		var anchor    = findDOM(fileFieldID + "_cancel");
		var syblingContainer = findDOM(syblingID);
		var span = findDOM(syblingID + "_span");
		hideObject(fileField);
		hideObject(anchor);
		hideObject(span);
        	container.removeChild(fileField);
		container.removeChild(anchor);
		syblingContainer.removeChild(span);
		document.all["file_path"].value = "";
		if(getCookie(cookieName)) { eraseCookie(cookieName); }
	}
	return;
}

// for saveing recipe to the network
function checkRecipeEntries() {
	return false;
}

function moveCookbookRecipes(frame,menu,chkbox) {
	var move_menu = document.all[menu];
	var ct_id = move_menu.value;
	if(ct_id == 0) { return; }
	var ckbk_ids = new Array();
	var ckbk_checkbox = document.all[chkbox];
	for(var i = 1; i < ckbk_checkbox.length; i++) {
		if(ckbk_checkbox[i].checked) { ckbk_ids.push(ckbk_checkbox[i].value); }
	}
	if(ckbk_ids.length < 1) { 
		alert("At least one recipe must be selected");
		move_menu.selectedIndex = 0;
		return;
	}
	findDOM(frame).src = "/cgi-bin/move_cookbook_recipes.mcml?ct_id=" + ct_id + "&ckbk_ids=" + ckbk_ids.join(",");
}

function deleteCookbookRecipes(frame,ct_name,chkbox) {
	var ckbk_ids = new Array();
	var ckbk_checkbox = document.all[chkbox];
        for(var i = 1; i < ckbk_checkbox.length; i++) {
                if(ckbk_checkbox[i].checked) { ckbk_ids.push(ckbk_checkbox[i].value); }
        }
        if(ckbk_ids.length < 1) {
                alert("At least one recipe must be selected");
        }else if(confirm("delete the selected recipe" + (ckbk_ids.length == 1 ? "" : "s") + " from your \"" + ct_name + "\" category?")) {
		findDOM(frame).src = "/cgi-bin/delete_cookbook_recipes.mcml?ckbk_ids=" + ckbk_ids.join(",");
	}
	return;
}

function quitePerform(frame,src) {
	findDOM(frame).src = src;
}

function checkAll(chkbox) {
	var checkbox = document.all[chkbox];
	var numberOfCheckBoxes = checkbox.length;
	if(checkbox[0].checked == true) {
		for(var i=1; i<numberOfCheckBoxes; i++) {
			checkbox[i].checked = true;
		}
	}else {
		for(var i=1; i<numberOfCheckBoxes; i++) {
			checkbox[i].checked = false;
		}
	}
}

function browserOK() {
	if (navigator.appName.indexOf("Netscape") != -1) {
		alert('To perform this function, you must use Internet Explorer');
		return false;
	}
	return true;
}

function bookmark(title, url) {
	if(document.all) {
		window.external.AddFavorite(url, title);
	}else if(window.sidebar) {
		window.sidebar.addPanel(title, url, "");
	}
}













