/***********************************************
* Star of David Bikers Java Script Library
***********************************************/

function popitup(url) {
	newwindow=window.open(url,'name','height=540,width=640,resize=1');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popupnotice(url) {
	newwindow=window.open(url,'name','height=540,width=640,resize=1,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popuplarge(url) {
	params = 'height=' +screen.height;
	if (screen.width < 1065) {
		params += ', width=' +screen.width; }
	else {
		params += ', width=1065'; }
	params += ', scrollbars=yes,menubar=no,location=no, status=no, directories=no';
	newwindow=window.open(url,'name',params);
	if (window.focus) {newwindow.focus()}
	return false;
}

function showpics(pic,desc,url,img,vdesc) {
	if (pic != undefined) {
		var arrcnt = 0
		document.write("<table width=\"640\" border=2><td>")
		while (arrcnt < pic.length) {
			document.write("<a href=\"javascript: void(0)\" onclick=\"return popitup(\'picshow.htm?slides=" + pic + "\')\"><img alt=\"" + desc[arrcnt] + 			"\"src=\"http://www.starofdavidbikers.org/pics/Small/" + pic[arrcnt] + "\" width=\"120\" height=\"90\" class=\"style3\"></a> ")
			arrcnt++
		}
	}
	if (url != undefined && img != undefined) {
		parm = '<a href=\"' + url + '\" target="Pic"><img '
		if (vdesc != undefined) {
		parm += 'alt=\"' + vdesc + '\" '
		}
		parm += 'src=\"http://www.starofdavidbikers.org/pics/' + img + '\" width=\"120\" height=\"90\ border=\"1\" class=\"style3\"></A>'
		document.write(parm)
	}
	document.write("</td></table>")
	flagline()
}

function flagline() {
	document.write("<div align=\"center\">")
	var loop
	for (loop=1; loop <= 5; loop++) {
		document.write("<img src=\"http://www.starofdavidbikers.org/bikeline.jpg\" height=\"30\" class=\"style32\"> ") }
	document.write("<br>")
	document.write("</div>")
}

function showicon(page,urloc,loc) {
	document.write("<a href=\"")
	document.write(urloc)
	document.write("\"") 
	document.write(" onMouseover=\"")
	document.write(page)
	if (loc == "Down") { document.write("1") }
	document.write("pic.src=\'http://www.starofdavidbikers.org/ico/")
	document.write(page)
	document.write("_mo.jpg\'\"")
	document.write(" onMouseout=\"")
	document.write(page)
	if (loc == "Down") { document.write("1") }
	document.write("pic.src=\'http://www.starofdavidbikers.org/ico/")
	document.write(page)
	document.write(".jpg\'\">")
	document.write("<img src=\"http://www.starofdavidbikers.org/ico/")
	document.write(page)
	document.write(".jpg\" ")
	document.write("border=0 ")
	document.write("alt=\"")
	document.write(page)
	document.write("\" ")
	document.write("name=\"")
	document.write(page)
	if (loc == "Down") { document.write("1") }
	document.write("pic\">")
	document.write("</a>")
}

function navigate(curpage1,loc) {
	curpage = curpage1.toLowerCase()
	document.write("<table width=\"1024\">")
	document.write("<tr>")

	document.write("<td width=\"100\">")
	if (curpage == "home") {
		document.write("<img src=\"http://www.starofdavidbikers.org/ico/home_in.jpg\" border=0 alt=\"Home\">")
	}
	else {
		showicon("home","http://www.starofdavidbikers.org",loc)
	}
	document.write("</td>")

	document.write("<td width=\"100\">")
	if (curpage == "about") {
		document.write("<img src=\"http://www.starofdavidbikers.org/ico/about_in.jpg\" border=0 alt=\"About Us\">")
	}
	else {
		showicon("about","http://www.starofdavidbikers.org/aboutus.htm",loc)
	}
	document.write("</td>")

	document.write("<td width=\"100\">")
	if (curpage == "charter") {
		document.write("<img src=\"http://www.starofdavidbikers.org/ico/charter_in.jpg\" border=0 alt=\"Charter\">")
	}
	else {
		showicon("charter","http://www.starofdavidbikers.org/charter.htm",loc)
	}
	document.write("</td>")

	document.write("<td width=\"100\">")
	if (curpage == "board") {
		document.write("<img src=\"http://www.starofdavidbikers.org/ico/board_in.jpg\" border=0 alt=\"Board\">")
	}
	else {
		showicon("board","http://www.starofdavidbikers.org/board.htm",loc)
	}
	document.write("</td>")

	document.write("<td width=\"100\">")
	if (curpage == "gallery") {
		document.write("<img src=\"http://www.starofdavidbikers.org/ico/gallery_in.jpg\" border=0 alt=\"Gallery\">")
	}
	else {
		showicon("gallery","http://www.starofdavidbikers.org/gallery.htm",loc)
	}
	document.write("</td>")

	document.write("<td width=\"100\">")
	if (curpage == "calendar") {
		document.write("<img src=\"http://www.starofdavidbikers.org/ico/calendar_in.jpg\" border=0 alt=\"Calendar\">")
	}
	else {
		showicon("calendar","http://www.starofdavidbikers.org/calendar.htm",loc)
	}
	document.write("</td>")

	document.write("<td width=\"100\">")
	if (curpage == "membership") {
		document.write("<img src=\"http://www.starofdavidbikers.org/ico/membership_in.jpg\" border=0 alt=\"Membership\">")
	}
	else {
		showicon("membership","http://www.starofdavidbikers.org/membership.htm",loc)
	}
	document.write("</td>")

	document.write("<td width=\"100\">")
	if (curpage == "forum") {
		document.write("<img src=\"http://www.starofdavidbikers.org/ico/forum_in.jpg\" border=0 alt=\"Forum\">")
	}
	else {
		showicon("forum","http://www.starofdavidbikers.org/forum.htm",loc)
	}
	document.write("</td>")

	document.write("<td width=\"100\">")
	if (curpage == "merchandise") {
		document.write("<img src=\"http://www.starofdavidbikers.org/ico/merchandise_in.jpg\" border=0 alt=\"Merchandise\">")
	}
	else {
		showicon("merchandise","http://www.starofdavidbikers.org/merchandise.htm",loc)
	}
	document.write("</td>")

	document.write("<td width=\"100\">")
	if (curpage == "guestbook") {
		document.write("<img src=\"http://www.starofdavidbikers.org/ico/guestbook_in.jpg\" border=0 alt=\"Guest Book\">")
	}
	else {
		showicon("guestbook","http://www.theguestbook.com/read.php/617368",loc)
	}
	document.write("</td>")

	document.write("</tr>")
	document.write("</table>")
}

function previousSlide() {
   if(slideNum > 1) {
     slideNum--
   }
   document.mySlide.src=slide[slideNum-1]

   if (slideNum < numberofSlides) {
     document.navNext.src="http://www.starofdavidbikers.org/next.jpg"
     }
   else {
     document.navNext.src="http://www.starofdavidbikers.org/nav_blank.jpg"
     }

   if (slideNum > 1) {
     document.navPrev.src="http://www.starofdavidbikers.org/prev.jpg"
     }
   else {
     document.navPrev.src="http://www.starofdavidbikers.org/nav_blank.jpg"
     }
}

function nextSlide() {
   if (slideNum < numberofSlides) {
     slideNum++
   }
   document.mySlide.src=slide[slideNum-1]

   if (slideNum < numberofSlides) {
     document.navNext.src="http://www.starofdavidbikers.org/next.jpg"
     }
   else {
     document.navNext.src="http://www.starofdavidbikers.org/nav_blank.jpg"
     }

   if (slideNum > 1) {
     document.navPrev.src="http://www.starofdavidbikers.org/prev.jpg"
     }
   else {
     document.navPrev.src="http://www.starofdavidbikers.org/nav_blank.jpg"
     }
}

function displayJewishDate() {
	var now = new Date;
	var tday = now.getDate();
	var tmonth = now.getMonth() + 1;
	var tyear = now.getYear();
	if(tyear < 1900)
		// if date from Netscape, then add 1900
		tyear += 1900;
	var hebDate = civ2heb(tday, tmonth, tyear);
	var hmS = hebDate.substring(hebDate.indexOf(' ')+1, hebDate.length);
	var	hDay = eval(hebDate.substring(0, hebDate.indexOf(' ')));
	var hMonth = eval(hmS.substring(0, hmS.indexOf(' ')));
	var hYear = hmS.substring(hmS.indexOf(' ')+1, hmS.length);
	document.write('<strong>');
	document.write('&nbsp;&nbsp;&nbsp;&nbsp;' + hDay + ' ' + hebMonth[hMonth+1] + ' ' + hYear);
	document.write('</strong><br>');
	document.write('<div class=\"style22\">');

	// Then display the corresponding civil dates
	var day, month, year;
	var today = new Date;
	var yesterday = new Date(today.getTime() - 86400000);
	day   = yesterday.getDate();
	month = yesterday.getMonth() + 1;
	year  = yesterday.getYear();
	if(year < 1900)
		year += 1900; // if date from Netscape, then add 1900
	document.write('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + civMonth[month] + ' ' + day + ', ' + year + '&nbsp;(after dusk)<br>');
	day   = today.getDate();
	month = today.getMonth() + 1;
	year  = today.getYear();
	if(year < 1900)
		year += 1900; // if date from Netscape, then add 1900
	document.write('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + civMonth[month] + ' ' + day + ', ' + year);
}

<!-- Begin

// Cookie Functions  ////////////////////  (:)

// Set the cookie.
// SetCookie('your_cookie_name', 'your_cookie_value', exp);

// Get the cookie.
// var someVariable = GetCookie('your_cookie_name'); --!>

var expDays = 100;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}

function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}



function cookieForms() {  
	var mode = cookieForms.arguments[0];
	for(f=1; f<cookieForms.arguments.length; f++) {
		formName = cookieForms.arguments[f];
		if(mode == 'open') {	
			cookieValue = GetCookie('saved_'+formName);
			if(cookieValue != null) {
				var cookieArray = cookieValue.split('#cf#');
				if(cookieArray.length == document[formName].elements.length) {
					for(i=0; i<document[formName].elements.length; i++) {
						if(cookieArray[i].substring(0,6) == 'select') { document[formName].elements[i].options.selectedIndex = cookieArray[i].substring(7, cookieArray[i].length-1); }
						else if((cookieArray[i] == 'cbtrue') || (cookieArray[i] == 'rbtrue')) { document[formName].elements[i].checked = true; }
						else if((cookieArray[i] == 'cbfalse') || (cookieArray[i] == 'rbfalse')) { document[formName].elements[i].checked = false; }
						else { document[formName].elements[i].value = (cookieArray[i]) ? cookieArray[i] : ''; }
					}
				}
			}
		}

		if(mode == 'save') {	
			cookieValue = '';
			for(i=0; i<document[formName].elements.length; i++) {
				fieldType = document[formName].elements[i].type;
				if(fieldType == 'password') { passValue = ''; }
				else if(fieldType == 'checkbox') { passValue = 'cb'+document[formName].elements[i].checked; }
				else if(fieldType == 'radio') { passValue = 'rb'+document[formName].elements[i].checked; }
				else if(fieldType == 'select-one') { passValue = 'select'+document[formName].elements[i].options.selectedIndex; }
				else { passValue = document[formName].elements[i].value; }
				cookieValue = cookieValue + passValue + '#cf#';
			}
			cookieValue = cookieValue.substring(0, cookieValue.length-4); // Remove last delimiter
			SetCookie('saved_'+formName, cookieValue, exp);		
		}	
	}
}

function getNextValue()
{
 	pos = formData.search(frmBrk);
	var field = ""
	if (formData.substr(0,pos) != frmBrk) {
		field = formData.substr(0,pos);
	}
 	formData = (formData.substr(pos + (frmBrk.length)));
	field = field.replace(/%20/g," ")

	return field;
}

function formatPhone(ac,pr,sf)
{
	var phone = "";
	if ((ac != "") || (pr != "")) {
		if (ac != "") {
			phone = "(" + ac + ") "; 
		}
		phone = phone + pr + "-" + sf;
	}
	return phone;
}

function makebinary(variable)
{
	var retstr = "0";
	if (variable == "cbtrue") {
		retstr = "1";
	}
	return retstr;
}

function daysLeft(yr, mo, da) {
	var date1 = new Date(yr, mo, da);
	var today = new Date();
	days = date1.getTime() - today.getTime();
	days = days / 86400000;
	days = parseInt(days);
	return days;
}

function TodayString() {
	var now = new Date;
	var tday = now.getDate();
	var tmonth = now.getMonth() + 1;
	var tyear = now.getYear();
	while (tyear < 2000) {
		tyear = tyear + 100
	}
	var datestr = tyear + "-" + tmonth + "-" + tday;
	return datestr;
}
