// JavaScript Document
///RANDOMIZE AND ALTERNATE ROWS
function alternate(id){ 
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);   
   var rows = table.getElementsByTagName("tr");   
   for(i = 1; i < rows.length; i++){           
 //manipulate rows 
	 if(i % 2 == 0){ 
	   rows[i].className = "even"; 
	 }else{ 
	   rows[i].className = "odd"; 
	 }       
   } 
 } 
}

function bookmark(url,title){
	
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
}

///AJAX LOAD INCLUDES
function showevent(eid, time, action, recur){
	//build link
	document.getElementById('main_content').innerHTML='<img src="images/ajax-loader.gif" align="center" style="padding-top:20px;" />';
	var build = "system/scr_ajax.php?action="+action+"&time="+time+"&eid="+eid+"&recur="+recur;
	$("div#main_content").load(build);
	$('#alternate').columnHover();
	
}

function showmonth(time, action, recur){
	//build link
	document.getElementById('main_content').innerHTML='<img src="images/ajax-loader.gif" align="center" style="padding-top:20px;" />';
	var build = "system/scr_ajax.php?action="+action+"&time="+time+"&recur="+recur;
	$("div#main_content").load(build);
	$('#alternate').columnHover();

}

function showcalendar(time, action, type){
	//build link
	document.getElementById('calendar').innerHTML='<img src="images/ajax-loader.gif" align="center" style="padding-top:20px;" />';
	var build = "system/scr_ajax.php?action="+action+"&time="+time+"&type="+type;
	$("div#calendar").load(build);
	$('#alternate').columnHover();
	
}
function showdetails(eid, time, action, recur){
	document.getElementById('main_content').innerHTML='<img src="images/ajax-loader.gif" align="center" style="padding-top:20px;" />';
	//build link
	var build = "system/scr_ajax.php?action="+action+"&time="+time+"&eid="+eid+"&recur="+recur;
	$("div#main_content").load(build);
	$('#alternate').columnHover();
	
}

function showactivitydetails(aid){
	document.getElementById('sort_details').innerHTML='<img src="images/ajax-loader_white.gif" align="center" style="padding-top:20px;" />';
	//build link
	var build = "system/scr_ajax.php?action=showactivitydetails&aid="+aid;
	$("#sort_details").load(build);
	
}

function addevent(eid, time, action, recur){
	//build link
	document.getElementById('main_content').innerHTML='<img src="images/ajax-loader.gif" align="center" style="padding-top:20px;" />';
	var build = "system/scr_ajax.php?action="+action+"&time="+time+"&eid="+eid+"&recur="+recur;
	$("div#main_content").load(build);
	$('#alternate').columnHover();
	
}

function editevent(){
	document.getElementById('main_content').innerHTML='<img src="images/ajax-loader.gif" align="center" style="padding-top:20px;" />';
		var form = document.getElementById('edit_form');
		var query = "";
		for (var i=0; i<form.elements.length; i++) {
		query+= form.elements[i].name;
		query+= "=";
		query+= escape(form.elements[i].value);
		query+= "&";
		}
		data = query;	 
		$("div#main_content").load("system/scr_ajax.php?"+data);
		$('#alternate').columnHover();
	
}


function delete_member(userid){
	var answer = confirm("Are you sure you want to DELETE this member?")
	if (answer){
		
		var build = "system/scr_ajax.php?action=deleteuser&memberid="+userid;
		$("div#message_div").load(build);
	}
}

function delete_event(eventid){
	var answer = confirm("Are you sure you want to DELETE this event?")
	if (answer){
		var build = "system/scr_ajax.php?action=deleteevent&eid="+eventid;
		$("div#message_div").load(build);
	}
}

function signup(){
		var form = document.getElementById('signup_form');
		var query = "";
		for (var i=0; i<form.elements.length; i++) {
		query+= form.elements[i].name;
		query+= "=";
		query+= escape(form.elements[i].value);
		query+= "&";
		}
		data = query;	 
		$("div#signupmessage").load("system/scr_ajax.php?"+data);
		for (var i=0; i<form.elements.length; i++) {
			if(form.elements[i].name != "Submit"){
				form.elements[i].value = "";
			}
		}
}

function reports(){
	document.getElementById('sort_result').innerHTML='<img src="images/ajax-loader_white.gif" align="center" style="padding-top:20px;" />';
		var form = document.getElementById('form');
		var query = "";
		for (var i=0; i<form.elements.length; i++) {
		query+= form.elements[i].name;
		query+= "=";
		query+= escape(form.elements[i].value);
		query+= "&";
		}
		data = query;	 
		$("#sort_result").load("system/scr_ajax.php?"+data);
		document.getElementById('sort_details').innerHTML='<img src="images/ajax-loader_white.gif" align="center" style="padding-top:20px;" />';
		var form = document.getElementById('form');
		var query = "";
		for (var i=0; i<form.elements.length; i++) {
			if(form.elements[i].name !="action"){
				query+= form.elements[i].name;
				query+= "=";
				query+= escape(form.elements[i].value);
				query+= "&";
			}
		}
		data = query;
		$("#sort_details").load("system/scr_ajax.php?action=activity_total&"+data);
		
		
}

function edit_event(){
		var form = document.getElementById('edit_event');
		var query = "";
		for (var i=0; i<form.elements.length; i++) {
		query+= form.elements[i].name;
		query+= "=";
		query+= escape(form.elements[i].value);
		query+= "&";
		}
		data = query;	 
		$("#edit_event").load("system/scr_ajax.php?"+data);
		
}

function activate_member(userid){
	var answer = confirm("Are you sure you want to ACTIVATE this member?")
	if (answer){
		var build = "system/scr_ajax.php?action=activateuser&memberid="+userid;
		$("div#message_div").load(build);
	}
}
jQuery(function($){
   $("#eventDate").mask("99-99-9999");
   $("#eventTime").mask("99:99 aa");
});

function MM_jumpMenuGo(objId,targ,restore){ //v9.0

  var selObj = null;  with (document) { 
  if (getElementById) selObj = getElementById(objId);
  if (selObj) eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0; }
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

$(function() {	// shorthand for $(document).ready() BTW
    $('div.demo').each(function() {
        $(this).corner();
    });
    
    $('.matchinghelp').qtip({
        content: 'This information is optional. We will use this information to better match you with another person in LINC.',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'bottomRight',
                tooltip: 'topLeft'
            }
        },
        style: {
            border: {
                radius: 5
            },
            tip: {
                corner:'topLeft',
                color:'#BF3C2F',
                size: {
                    x: 20,
                    y: 8
                }
            }
       }
    });
    
    $('.agehelp').qtip({
        content: 'We try to match you with someone in your age group.',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'bottomLeft',
                tooltip: 'topRight'
            }
        },
        style: {
            border: {
                radius: 5
            },
            tip: {
                corner: 'topRight',
                color: '#BF3C2F',
                size: {
                    x: 20,
                    y: 8
                }
            }
        }
    });
    
    $('.livinghelp').qtip({
        content: 'We try to make sure you\'ll be able to visit your partner easily.',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'bottomLeft',
                tooltip: 'topRight'
            }
        },
        style: {
            border: {
                radius: 5
            },
            tip: {
                corner: 'topRight',
                color: '#BF3C2F',
                size: {
                    x: 20,
                    y: 8
                }
            }
        }
    });
    
    $('.attendhelp').qtip({
        content: 'You will be matched with your LINC partner at the Connections Party. If you can\'t attend, we can still match you after the Party.',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'bottomLeft',
                tooltip: 'topRight'
            }
        },
        style: {
            border: {
                radius: 5
            },
            tip: {
                corner: 'topRight',
                color: '#BF3C2F',
                size: {
                    x: 20,
                    y: 8
                }
            }
        }
    });
    
});