	
	var content_body = ' ';
	
	function Response(transport) {
    $('searchbox').innerHTML = transport.responseText;
	}
	
	function eventAjax() {
	var search = document.getElementById('search2').value;
	//alert(base_url+'search/events');	
    var myAjax = new Ajax.Request(base_url+'search/events', 
                                   {method: 'post',parameters: {search:search},
                                   onComplete: Response});
									
	}
	function searchAjax() {
	var search = document.getElementById('search2').value;
	//alert(search);
		if(search != ''){
			var myAjax = new Ajax.Request(base_url+'search/search_trim', 
                                   {method: 'post',parameters: {search:search},
                                   onComplete: Response});
		}
		else {
			jQuery.post(base_url+'search/result',data,function(data) {
					jQuery('#searchbox').html(data);
					rebind2();
					}	);
		}
	}
	function allAjax() {
	var search = document.getElementById('search2').value;
	//alert(search);
		if(search != ''){
    var myAjax = new Ajax.Request(base_url+'search/trim_events', 
                                   {method: 'post',parameters: {search:search},
                                   onComplete: Response});
		}
		else {
			jQuery.post(base_url+'search/result',data,function(data) {
					jQuery('#searchbox').html(data);
					rebind2();
					}	);
		}
	}
	
	function albumResponse(transport) {
		$('albums').innerHTML = transport.responseText;
		document.getElementById('albums').style.display = 'block';
	}
	
	function bodyResponse(transport) {
		//alert(transport.responseText);
		if(content_body == ' ' ){
			content_body = $('content_body').innerHTML;
		}
		$('content_body').innerHTML = transport.responseText;
	}
	
	function view_profile(){
		if(content_body == ' ' ){
			content_body = $('content_body').innerHTML;
		}
		$('content_body').innerHTML = content_body;
	}
	
	function view_user_album(){
		var myAjax = new Ajax.Request(base_url+'user_uploads/', 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});
		
	}
	
	function search_view_photos(id){
		var myAjax = new Ajax.Request(base_url+'search/view_photos/'+id, 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});
		
	}
	
	function search_view_events(id){
		var myAjax = new Ajax.Request(base_url+'calendar/view_events/'+id, 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});
		
	}
	
	function sendPrivate(id) {
		if(content_body == ' ' ){
			content_body = $('content_body').innerHTML;
		}
		/*  var myAjax = new Ajax.Request(base_url+'message/sendPrivate/'+id, 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});  */
		$('content_body').innerHTML  = '<table width="100%" height="500" border="0" cellpadding="0" cellspacing="0"><tr><td><iframe src="'+base_url+'message/sendPrivate/'+id+'/frame" width="100%" height="500" frameborder="0"></iframe></td></tr></table>';
		
	}
	
	function ajxtest(form){
		var userfile = form.userfile.value;
		alert(userfile);
		var myAjax = new Ajax.Request(base_url+'user_uploads/add_image1', 
                                   {method: 'post',parameters: {userfile:userfile},
                                   onComplete: albumResponse});
	}
	
	
	function createAlbum() {
	//alert('createAlbum');
    /*  var myAjax = new Ajax.Request(base_url+'user_uploads/create_albums', 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: albumResponse});  */
		var frame = '<iframe src="'+base_url+'user_uploads/create_albums" width="100%" height="200" frameborder="0"></iframe>';
		$('albums').innerHTML = frame;
		document.getElementById('albums').style.display = 'block';
	}
	function createfbAlbum() {
		var frame = '<iframe src="'+base_url+'fbalbum" width="100%" height="200" frameborder="0"></iframe>';
		$('albums').innerHTML = frame;
		document.getElementById('albums').style.display = 'block';
	}
	function view_album(name){
		var myAjax = new Ajax.Request(base_url+'user_uploads/view', 
                                   {method: 'post',parameters: {name:name},
                                   onComplete: albumResponse});
								   
	}
	function my_events(){
		var myAjax = new Ajax.Request(base_url+'calendar/myevents', 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});
	}
	function create_event(){
		/*  var myAjax = new Ajax.Request(base_url+'calendar/create', 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});  */
		$('content_body').innerHTML  = '<table width="100%" height="742" border="0" cellpadding="0" cellspacing="0"><tr><td><iframe src="'+base_url+'calendar/create/ajax" width="100%" height="600" frameborder="0"></iframe></td></tr></table>';
		
	}
	function edit_event(id){
		/*  var myAjax = new Ajax.Request(base_url+'calendar/editevent/cid/'+id, 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});  */
		$('content_body').innerHTML =  '<table width="100%" height="742" border="0" cellpadding="0" cellspacing="0"><tr><td><iframe src="'+base_url+'calendar/editevent/cid/'+id+'/ajax" width="100%" height="600" frameborder="0"></iframe></td></tr></table>';
		
	}
	function accountsetting(){
		var myAjax = new Ajax.Request(base_url+'accountsetting/editaccount', 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});
	}
	function accountsetting_process(){
		var emailaddress = document.getElementById('emailaddress').value;
		var oldpassword = document.getElementById('oldpassword').value;
		var newpassword = document.getElementById('newpassword').value;
		var confirmpassword = document.getElementById('confirmpassword').value;
		var myAjax = new Ajax.Request(base_url+'accountsetting/editaccountprocess', 
                                   {method: 'post',parameters: {ajax:'true',emailaddress:emailaddress,oldpassword:oldpassword,newpassword:newpassword,confirmpassword:confirmpassword},
                                   onComplete: bodyResponse});
	}
	function inbox(){
		var myAjax = new Ajax.Request(base_url+'inbox', 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});
	}
	function inbox_body(id){
		var myAjax = new Ajax.Request(base_url+'inbox/body/'+id, 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});
	}
	function inbox_reply(id){
		var myAjax = new Ajax.Request(base_url+'inbox/reply/'+id, 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});
	}
	function outbox(){
		var myAjax = new Ajax.Request(base_url+'outbox', 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});
	}
	function outbox_body(id){
		var myAjax = new Ajax.Request(base_url+'outbox/body/'+id, 
                                   {method: 'post',parameters: {ajax:'true'},
                                   onComplete: bodyResponse});
	}
	function view_album2(name){
		var myAjax = new Ajax.Request(base_url+'user_uploads/view2', 
                                   {method: 'post',parameters: {name:name},
                                   onComplete: albumResponse});
	}
	function view_album3(name){
		var myAjax = new Ajax.Request(base_url+'user_uploads/view3/'+name, 
                                   {method: 'post',parameters: {name:name},
                                   onComplete: albumResponse});
	}
	function add_image(name){
		/*  var myAjax = new Ajax.Request(base_url+'user_uploads/add_image', 
                                   {method: 'post',parameters: {album_name:name},
                                   onComplete: albumResponse});  */
		var frame = '<iframe src="'+base_url+'user_uploads/add_image/'+name+'" width="100%" height="200" frameborder="0"></iframe>';
		$('albums').innerHTML = frame;
		document.getElementById('albums').style.display = 'block';
	}
	
	function admin_uploder(){
		var frame = '<table width="100%" height="742" border="0" cellpadding="0" cellspacing="0"><tr><td><iframe src="'+base_url+'uploader/" width="100%" height="900" frameborder="0"></iframe></td></tr></table>';
		$('content_body').innerHTML = frame;
	}
	
	function admin_eventlist(){
		var frame = '<table width="100%" height="742" border="0" cellpadding="0" cellspacing="0"><tr><td><iframe src="'+base_url+'calendar/eventlist/ajax" width="100%" height="900" frameborder="0"></iframe></td></tr></table>';
		$('content_body').innerHTML = frame;
	}
	
	function admin_ulist(){
		var frame = '<table width="100%" height="742" border="0" cellpadding="0" cellspacing="0"><tr><td><iframe src="'+base_url+'member/ulist" width="100%" height="1000" frameborder="0"></iframe></td></tr></table>';
		$('content_body').innerHTML = frame;
	}
	
	function edit_image(id,caption){
		var caption = prompt("Image Caption",caption);
		if (caption!=null && caption!="")
			{
				//alert(caption);
				new Ajax.Request(base_url+'user_uploads/edit_image/', 
                                   {method: 'post',parameters: {id:id,caption:caption},
                                   onComplete: albumResponse});
			}
		
		
	}
	
	function delete_image(id,name){
		var r=confirm("Delete Image?");
		if (r==true) {
			new Ajax.Request(base_url+'user_uploads/delete_image/', 
                                   {method: 'post',parameters: {id:id},
                                   onComplete: albumResponse});
			view_album(name);
		}
		
		
	}
	
	function delete_album(album_name){
		var r=confirm("Delete Album?");
		if (r==true) {
			new Ajax.Request(base_url+'user_uploads/delete_album/', 
                                   {method: 'post',parameters: {album_name:album_name},
                                   onComplete: albumResponse});
		}
		
		
	}
	
	function fb_member_login(fb_uid){
		var myAjax = new Ajax.Request(base_url+'login/fb_member_login', 
                                   {method: 'post',parameters: {fb_uid:fb_uid},
                                   onComplete: alert('log in')});
	}
	
	function cancel() {
		document.getElementById('albums').style.display = 'none';
		$('albums').innerHTML = ' ';
	}



//creates a prototype Ajax object, sends a request, and registers the callback function 'handleResponse'

function callAjax(state) {
	//alert(bodyparts);
    var myAjax = new Ajax.Request(base_url+'register/city', 
                                   {method: 'post',parameters: {state:state},
                                   onComplete: handleResponse});
}
function handleResponse(transport) {
	
    $('city').innerHTML = transport.responseText;
}




	function MM_preloadImages() { //v3.0
  	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

	function MM_findObj(n, d) { //v4.01
  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_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 autoswap() {
	var img = new Array(); img[0]="/images/p_flash1.jpg"; img[1]="/images/a_working.jpg"; img[2]="/images/b_working.jpg"; img[3]="/images/c_working.jpg";
	var i = 1;
	function semiauto(){
		document.images['img1'].src = img[i];
		i++;
		if (i>3){i=0;}
		setTimeout('semiauto()',5000);
	}
}

/*  function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};*/

/*  jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 3,
		animation: 'slow',
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
});  */  

$(function(){
		   $("#mail").validate({
					rules: {
						name: {
							required: true,
							minlength: 6
						},
						sender:{
							required: true,
							email: true
						},
						subject: {
							required: true,
							minlength: 3
						},
						message: {
							required: true,
							minlength: 1
						},
						privacy: {
							required: true,
							minlength: 2
						},
					},
					messages: {
						name: "Name cannot be blank or less than 6 characters.",
						sender: "Please enter a valid Email.",
						subject: "Enter a subject.",
						message: "Message cannot be blank.",
						privacy: "You must read and accept the privacy policy before continuing."
					}
							   });
		   });
		   
		   
		   
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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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_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 alertAndLogout(){
alert('You have been logged out due to inactivity.');
window.location = 'http://' + window.location.hostname + "/member/logout";
}  */
function validate_pword(conf) {
	var pass = document.getElementById('pword').value;
	var conf = document.getElementById('pword2').value;
	if( pass != conf ){
		document.getElementById('confirm').innerHTML = '<br/>The passwords you entered do not match.';
	}
	else {
		document.getElementById('confirm').innerHTML = '<br/>The passwords you entered match.';
	}
}
function validate_form ( )
{
    valid = true;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var alphaExp = /^[a-zA-Z\ ]+$/;
	var address = document.quickjoin.email.value;
	var firstname = document.quickjoin.firstname.value;
	var lastname = document.quickjoin.lastname.value;
	
	
	var pword = document.quickjoin.pword.value;
	var pword2 = document.quickjoin.pword2.value;
	
    if ( document.quickjoin.firstname.value == "" )	
	{
        alert ( "Please fill in the your First Name.");
		document.quickjoin.firstname.focus()
        valid = false;
    }
	else if(alphaExp.test(firstname) == false) 
	{
		alert('Letters Only Please on First Name');
		document.quickjoin.firstname.focus()
      	return false;

	}
	else if(document.quickjoin.lastname.value == "") 
	{
		alert("Please fill in your Last Name.");
		document.quickjoin.lastname.focus()
		valid = false;
	}
	else if(alphaExp.test(lastname) == false) 
	{
		alert('Letters Only Please on Last Name');
		document.quickjoin.lastname.focus()
      	return false;

	}
	else if(document.quickjoin.pword.value == "") 
	{
		alert("Please fill in your Password.");
		document.quickjoin.pword.focus()
		valid = false;
	}
	else if(reg.test(address) == false) 
	{
		alert('Invalid Email Address');
		document.quickjoin.email.focus()
      	return false;

	}
	else if(pword != pword2) 
	{
		alert('The passwords you entered do not match.');
		document.quickjoin.email.focus()
      	return false;

	}
    return valid;
	}
	
function showhide(thisform) {
	
	myOption = -1;
	for (i=thisform.problem.length-1; i > -1; i--) {
	if (thisform.problem[i].checked) {
	myOption = i; i = -1;
	}
	}
	if (myOption == -1) {
	alert("You must select a radio button");
	return false;
	}
	var disable = thisform.problem[myOption].value;
	//alert(" has a value of " + thisform.problem[myOption].value);
	

	if(disable == "other")
	{document.getElementById('textarea').style.display = 'block';}
	else
	{document.getElementById('textarea').style.display = 'none';}
	
}

// Popup window code
function newPopup(url) {
	popupWindow = window.open(
		url,'popUpWindow','height=500,width=660,left=10,top=10,resizable=no,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes')
}

	var minpwlength = 4;
	var fairpwlength = 7;
function updatestrength( pw ) {
	if( pw.length == 0 ){
	strengthlevel = '';
	}
	else if( istoosmall( pw ) ) {
	strengthlevel = '<strong style="color:red;">short</strong>';
	}
	else if( !isfair( pw ) ) { 
	strengthlevel = '<strong style="color:red;">weak</strong>';
	}    
	else if( hasnum( pw ) ) {
	strengthlevel = '<strong style="color:green;">strong</strong>';
	}
	else {
	strengthlevel = '<strong style="color:green;">fair</strong>';
	}
	document.getElementById('strength').innerHTML = strengthlevel;
}
function isfair( pw ) {
	if( pw.length < fairpwlength ) { return false; }
	else {  return true; }
}
function istoosmall( pw ) {
	if( pw.length < minpwlength ) { return true; }
	else { return false; }
}
function hasnum( pw ) {
	var hasnum = false;
	if( pw.length > 12 ) { hasnum = true; }
	for( var counter = 0; counter < pw.length; counter ++ ) {
	if( !isNaN( pw.charAt( counter ) ) ) { hasnum = true; }
	}
	return hasnum;
}
