function checkLoginRemember(){
	var check = getCookie("JetSetMafia_Login_Remember");
	if ((check==null) || (check==0)){
		return false;
	}else{
		return true;
	}
}

function Delete_Login_Remember(){
	delCookie("JetSetMafia_Login_Remember"); 
	delCookie("JetSetMafia_Login_Username"); 
	delCookie("JetSetMafia_Login_Password"); 

}

function getCookie(NameOfCookie) 
{ 
        if(document.cookie.length > 0){ 
                begin = document.cookie.indexOf(NameOfCookie+"="); 
                if(begin != -1){ 
                        begin += NameOfCookie.length+1; 
                        end = document.cookie.indexOf(";", begin); 
                        if (end == -1) end = document.cookie.length; 
                        return unescape(document.cookie.substring(begin, end)); 
                } 
        } 
        return null; 
}

function setCookie(NameOfCookie, value, expiredays){
        var ExpireDate = new Date(); 
        var NumOfMonth = 6;
        ExpireDate.setMonth(ExpireDate.getMonth() + NumOfMonth);

        document.cookie = NameOfCookie + "=" + escape(value) + 
                ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
} 


function delCookie(NameOfCookie) 
{ 
	if(getCookie(NameOfCookie)){ 
		document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; 
	} 
} 

var timesCalled = 0; 
function RedirectAfter(sPage, nSeconds) 
{ 
        timesCalled++; 
        var fActionName; 
        if(arguments[2]){ 
                fActionName = arguments[3]; 
                var fActionNameString = fActionName.toString(); 
                var firstBraketPos = fActionNameString.indexOf("{"); 
                var fActionNameFunctionName = fActionNameString.substring(fActionNameString.indexOf(" "), fActionNameString.indexOf("(")); 
                if(timesCalled==1){ 
                        // modify the function argument[3] 
                        fActionNameBody = fActionNameString.substring(firstBraketPos+1, fActionNameString.length-1) + "\n\tRedirectAfter('" + sPage + "', " + nSeconds + ", " + arguments[2] + ", " + fActionNameFunctionName + ");"; 
                        eval("\t" + fActionNameFunctionName + "_Timer = new Function('', fActionNameBody);"); 
                } 
                if(timesCalled == Math.ceil(nSeconds/parseInt(arguments[2]))){ 
                        document.location = sPage; 
                } 
                fActionName = fActionNameFunctionName + "_Timer()"; 
                nSeconds = parseInt(arguments[2]); 
        }else{ 
                fActionName = new Function("", "document.location = '" + sPage + "';"); 
        } 
        var timerID = setTimeout(fActionName, 1000*nSeconds); 
}


function Logout_Confirmation()
{
	check = checkLoginRemember()
	if (check == true)
	{
		if (window.confirm("Would you like us to remember your password?"))
		{
			window.location = "logoff.asp" ;
		}else{
			delCookie("JetSetMafia_Login_Remember");
			delCookie("JetSetMafia_Login_Username"); 
			delCookie("JetSetMafia_Login_Password"); 				
		}	
	}
		document.location = "index.asp";
}

function handler(e){
	var key = (navigator.appName == "Netscape") ? e.which : e.keyCode;
	if (key == 110)
		return false;
	if (key == 8 || key == 13 || key == 46 || (key > 47 && key < 58) || (key > 95 && key < 106))
			return true; 
	else
		return false;
}

function IsValidEmail_contactUs(NForm){
	if (NForm.FromName.value == ""){
		alert ("Enter your Name");
		return false; 
	}else{
	        var str = NForm.FromEmail.value;
	        var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; 
	        var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
	        if (!reg1.test(str) && reg2.test(str)) {
	                return true;
	        }else{
	                alert ("Enter A valid Email");
	                return false; 
	        }
	}
}

function ShowEmailForm(howform){
	if (rightpagetable.style.display =='') {
			rightpagetable.style.display = 'none';
		}else{
			rightpagetable.style.display = '';
	}
}

function addBookmark(title,url){
	if (window.sidebar){
			window.sidebar.addPanel(title, url,"");
		}else if( document.all){
			window.external.AddFavorite( url, title);
		}else if( window.opera && window.print ){
	return true;
	}
}

function loggin(){
	alert("You have to be a registered user to get on the guest list. Please register and login and try again.")
}



function MM_findObj(n, d){
	var p,i,x;  if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length){
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) 
		x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
		x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById)
		x=d.getElementById(n);
	return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr;
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
  	x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
   		if ((x=MM_findObj(a[i]))!=null){
   			document.MM_sr[j++]=x;
   			if(!x.oSrc)
   				x.oSrc=x.src;
   			x.src=a[i+2];
   		}
}

function UnregisteredUser(){
	alert('You have to be a registered user to view the full size picture. Please register and login and try again.')
}

function confirm_deleteAlbum(eventID,eventDate){
	if (window.confirm("Are you sure you want to delete this Album ?")){
		window.location = "viewEvents.asp"
	}
}

function showPromotion(optionSelected){
	if(optionSelected == "Birthday Party")
		BPromotion.style.display = "";
	else
		BPromotion.style.display = "none";
}

function checkFixedLists(Form){
	return true;
	//if (Form.FixedMailingList[0].checked == false && Form.FixedMailingList[1].checked == false){
	//	alert("You have to select either Special Events or Weekly Events")
	//	return false;
	//}
}

function right(e){
	if (navigator.appName == 'Netscape' && 	(e.which == 3 || e.which == 2))
		return false;
	else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)){
		alert("Right Click and View Source have been disabled on this page");
		return false;
	}
	return true;
}

function rightCALL(){
	document.onmousedown=right;
	document.onmouseup=right;
	if (document.layers) window.captureEvents(Event.MOUSEDOWN);
	if (document.layers) window.captureEvents(Event.MOUSEUP);
	window.onmousedown=right;
	window.onmouseup=right;
}

function changeIt(){
	uplaodNumber.style.display = "none"
	theLink.style.display = "none"
	var theTable = "";
	theTable += "<table width='100%' class='text'>"
	var k=1;
	for (var i=1 ; i<=uplaodNumber.value ; ){
		theTable += "<tr>"
		for (var j=0 ; j<2 ; j++){
			if (i <= uplaodNumber.value)
				theTable += "<td>"+(k)+"-</td><td width='48%'><input type='file' name='mytext"+i+"' class='fields'></td>"
			i++;
			k++;
		}
	theTable += "</tr>"
	}
	theTable += "</table>"
	my_div.innerHTML = theTable;
}

function popupform(myform, windowname){
	if (! window.focus)return true;
	window.open('', windowname, 'height=500,width=500,scrollbars=yes');
	myform.target=windowname;
	return true;
}
function popupformreminder(myform, windowname){
	if (! window.focus)return true;
	window.open('', windowname, 'height=100,width=300,scrollbars=yes,top=350,left=350');
	myform.target=windowname;
	return true;
}
function IsValidEmail(NForm){ 
        NForm.newEmail.focus();
        var str = NForm.newEmail.value; 
        var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid 
        var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid 
        if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid 
                return true; 
        }else{ 
                alert("Enter a valid Email");
                return false; 
        } 
}

function Validate_ChangeEmailForm(NForm){
	if(NForm.t_username.value.length == 0){
		alert("You must enter a User Name");
		return false;
	}else{
		if(NForm.t_NewPassword.value.length == 0){
			alert("You must enter a Password");
			return false;
		}
	}
}

function Validate_FillUsername(NForm){
        NForm.username.focus();
        var str = NForm.username.value; 
        
        if(NForm.username.value.length == 0){
        	alert("You must enter an E-mail address");
		return false;
	}

        var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid 
        var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid 
        if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid 
                return true; 
        }else{ 
                alert("Enter a valid Email");
                return false; 
        } 
}

function validate_BirthdayEmailForm(NForm){
	NForm.nameFrom.focus();
	if(NForm.nameFrom.value.length == 0){
		alert("You must enter a Name From");
		return false;
	}

	NForm.emailFrom.focus();
	if(NForm.emailFrom.value.length == 0){
		alert("You must enter an Email From");
		return false;
	}

	NForm.emailSubject.focus();
	if(NForm.emailSubject.value.length == 0){
		alert("You must enter an Email Subject");
		return false;
	}

	NForm.emailBody.focus();
	if(NForm.emailBody.value.length == 0){
		alert("You must enter a Body Email");
		return false;
	}
}