﻿

function _goto(id) {	
	window.location.href = "/members/index.aspx?puid=" + id;
}
function _popup(url) {	
	myWin = window.open(url, 'blank', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=690,height=780');
}
function _popOpenerLink(url) {	
	myWin = window.open("/members/index.aspx?print=true&puid="+url, 'blank', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=690,height=780');
}
function _gotoprint(id) {
	myWin = window.open("/members/index.aspx?print=true&puid=" + id, 'myWin', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=690,height=750');
}
function _gotoprint(id, qs) {
	myWin = window.open("/members/index.aspx?print=true&puid=" + id + '&' + qs, 'myWin', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=690,height=750');
}
function _gotoprintpop(id) {
	myWin = window.open("/members/index.aspx?print=true&puid=" + id, 'myWin', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=690,height=750');
}
function _gotourlpop(url) {
	myWin = window.open(url, 'myWin', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=690,height=750');
}
function _sendtofriendpop(puid) {	
	myWin = window.open("/mail/sendmail.aspx?puid=" + puid, 'myWin', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=690,height=715');
}
function _sendtofriendurlpop(url) {	
	myWin = window.open("/mail/sendmail.aspx?" + url, 'myWin', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=690,height=715');
}
// Food Log Print Function 
function _gotoprintfoodlog(id, qs)
{
	myWin = window.open("/members/index.aspx?print=true&puid=" + id + '&' + qs, 'myWin', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=650,height=750');
}

function addEvent(elm, evType, fn, useCapture) {
	if(elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	} else {
		elm['on' + evType] = fn;
	}
}


// removes square border that IE adds to checkboxes and radiobuttons
function removeCheckBoxBorders() {
	var el = document.getElementsByTagName("input");
	for (i=0;i<el.length;i++) {
		var type = el[i].getAttribute("type");
		if((type=="checkbox")||(type=="radio")) {
			el[i].style.border = "none";
		}
	}
}
addEvent(window, 'load', removeCheckBoxBorders, false);

//returns an element based on name used for .net controls
function FindElement(e) {
	var elm = null;
	for (i = 0; i < document.forms[0].elements.length; i++) {
		if (document.forms[0].elements[i].name.indexOf(e) != -1) {
			elm = document.forms[0].elements[i];
			break;
		}
	}
	return elm;
}

//heart rate calc
function RequiredValidator(controlId) {
    if( FindElement(controlId).value == "") {
        alert('Please enter your age.');
        return false;
    }
}

//zebra tables
function zebra (table) {
	var current = "oddRow";
	var trs = table.getElementsByTagName("tr");
	for (var i = 0; i < trs.length; i++) {
		trs[i].className += " " + current;
		current = current == "evenRow" ? "oddRow" : "evenRow";
	}
}
function stripes () {
	var tables = document.getElementsByTagName("table");
	for (var i = 0; i < tables.length; i++) {
		if (tables[i].className.match(/zebra/)) {
			zebra(tables[i]);
		}
	}
}

//Blogs
function ConfirmCancel() {
	if (confirm("All changes will be lost. Are You sure you want to continue?")) {
		window.location='/members/bridalbootcamp/index.aspx';
	}
}
function ConfirmDelete() {
	 return confirm("Are you sure you want to delete this item?");
}


//ARTICLE PRINT
function printit() {  
	if (window.print) {
		window.print() ;  
	} else {
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0  HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);
	}
}

//Search Site or Recipes based on rblType
function DoSearch(txtsearch) {
	//go through rbltype radio button list and set searchtype = checked value
	//for( i = 0; i < rbltype.length; i++ ) {
	//	if( rbltype[i].checked == true )
	//		searchtype = rbltype[i].value;
	//}
	if(document.getElementById("recipes").checked) {
		searchtype = "recipes";
	} else {	
		searchtype = "site";
	}
	//depending on searchtype set url
	if (searchtype == "recipes") {
		window.location.href = "/members/foodandrecipes/recipes/search.aspx?Search=" + txtsearch;
	} else {
		window.location.href = "/members/search.aspx?q=" + txtsearch;
	}
	//redirect to right search page
	url = "";
	txtsearch = "";
}
function DoSearchHitEnter(event, txtsearch) {
	if (document.all) {
		if(event.keyCode==13) {
			event.returnValue=false;
			event.cancel = true;
			DoSearch(txtsearch);
		}
	}
	else if (document.getElementById) {
  		if (event.which == 13) {
  			event.returnValue=false;
   			event.cancel = true;
   			DoSearch(txtsearch);
		}
	}
	else if(document.layers) {
		if(event.which == 13) {
			event.returnValue=false;
			event.cancel = true;
			DoSearch(txtsearch);
		}
	}			
}
function submitenter(event,val) {
	if (document.all) {
		if(event.keyCode==13) {
			event.returnValue=false;
			event.cancel = true;
			if(val==1)
				goNutritionSearch();
			else
				goRecipeSearch();
		}
	}
}

function DoSearchRecipes(txtsearch, cbfavorite, cbquick) {
	var url = "/members/tools/recipes/search.aspx?Search=";
	url += txtsearch.value;
	if(cbfavorite.checked == true)
		url += "&showfavoritesonly=true";
	if(cbquick.checked == true)
		url += "&showvaluedatas=quick";
	//redirect to right search page
	document.location.href = url;
}

function submitenter(event,val) {
	if (document.all) {
		if(event.keyCode==13) {
			event.returnValue=false;
			event.cancel = true;
			if(val==1)
				goNutritionSearch();
			else
				goRecipeSearch();
		}
	}
}
function goNutritionSearch() {
	encodedString = escape(document.getElementById("txtNutritionSearch").value);
	location.href= "/members/Foodandrecipes/nutrition/search.aspx?s=" + encodedString;
	return false;
}
function goRecipeSearch() {
	location.href= "/members/foodandrecipes/recipes/search.aspx?search=" + document.getElementById("txtRecipeSearch").value;
}

//MY PROGRESS SLIDER
var toggleSection = function(obj) {
	theState = $(obj+"Div").className;
	theHeight = document.all ? $(obj+"Div").offsetHeight : $(obj+"Div").clientHeight;
	if (theState == "expanded") {
		sectionT = new Tween($(obj+"WrapperDiv").style,'height',Tween.strongEaseOut,theHeight,0,.5,'px');
		$(obj+"Div").className = "";
		if ($(obj+"Text")) {$(obj+"Text").innerHTML = 
		    "<img src=\"/images/myprogress/myprogress-open.gif\"width=\"10\" height=\"10\" alt=\"\" border=\"0\" align=\"absmiddle\" hspace=\"4\">";
		}
	} else {
		sectionT = new Tween($(obj+"WrapperDiv").style,'height',Tween.strongEaseOut,1,theHeight,.5,'px');
		$(obj+"Div").className = "expanded";
		if ($(obj+"Text")) {$(obj+"Text").innerHTML = 
		    "<img src=\"/images/myprogress/myprogress-close.gif\"width=\"10\" height=\"10\" alt=\"\" border=\"0\" align=\"absmiddle\" hspace=\"4\">";
		
		}
	}
	sectionT.start();
}