
function setfocus() {
$("#username").focus();
}

function confirmDeletePost(clickeditem, postid) {
$(clickeditem).before('<a href="#" onclick="deletePost(this, \'' + postid + '\'); return false;"> [Confirm Delete]</a>');
$(clickeditem).remove();
}

function deletePost(clickeditem, postid) {
	$(clickeditem).parent().parent().parent().parent().remove();
    $.post("scripts.php?id=68", { postid: postid });	

}

function confirmDeleteComment(clickeditem, commentid) {
$(clickeditem).before('<a href="#" onclick="deleteComment(this, \'' + commentid + '\'); return false;"> [Confirm Delete]</a>');
$(clickeditem).remove();
}

function deleteComment(clickeditem, commentid) {
	$(clickeditem).parent().parent().parent().parent().remove();
    $.post("scripts.php?id=71", { commentid: commentid });	

}

function confirmDeleteSubComment(clickeditem, subcommentid) {
$(clickeditem).before('<a href="#" onclick="deleteSubComment(this, \'' + subcommentid + '\'); return false;"> [Confirm Delete]</a>');
$(clickeditem).remove();
}

function deleteSubComment(clickeditem, subcommentid) {
	$(clickeditem).parent().parent().parent().parent().remove();
    $.post("scripts.php?id=74", { subcommentid: subcommentid });	

}


function clearsearch () {
	if($("#searchField").val() == "search MMCC" || "Enter Keywords") {
	$("#searchField").val("");
    $("#searchField").css("color", "#000");
    }
    if($("#interiorsearchField").val() == "search MMCC") {
	$("#interiorsearchField").val("");
    $("#interiorsearchField").css("color", "#000");
    }
}
function getCookie(c_name) {
    if (document.cookie.length>0)
      {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1)
        { 
        c_start=c_start + c_name.length+1; 
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
        } 
    }
	return "";
}

function setCookie(c_name,value,expiredays) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function delCookie(c_name) {
	document.cookie = c_name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}

function checkMenuStatus() {
	var oldcookiei = getCookie('cookiei');
    var oldsid = getCookie('sid');
    var thissid = '33';
    if(thissid == oldsid) {
        for(i=1; i<=oldcookiei; i++) {
            eval("var menuitem = getCookie('menuitem" + i + "');");
            if(menuitem != "") {
            $("#deptNav").children("li:eq(" + menuitem + ")").children(":first-child").next().show();
            $("#deptNav").children("li:eq(" + menuitem + ")").children(":first-child").children(":first-child").attr("id", "minus");
            $("#deptNav").children("li:eq(" + menuitem + ")").children(":first-child").css({"backgroundImage" : "url(../images/opensubnav.gif)", "backgroundRepeat" : "repeat-x", "fontWeight" : "bold", "borderBottom" : "solid 1px #acd2e4"});

            }
            
        }
    } else {
        setCookie('cookiei', 0, null);
        setCookie('sid', 0, null);
    }
}

function deletePage(pid, clickeditem) {
	$(clickeditem).parent().append('<a href="#" onclick="confirmDelete(\'' + pid + '\', this); return false;" style="font-size:12px; color:#FF0000">Confirm Delete</a>');
	$(clickeditem).remove();	
	
}

function confirmDelete(pid, clickeditem) {
    $.post("scripts.php?id=52", { pid: pid },
    function(data){
        $(clickeditem).parent().html(data);
    });		
}

function newUser(username) {
	$.nyroModalSettings({ endRemove: newUserForm });
    $.nyroModalRemove();
   	
}
function newUserForm () {
 $.post("scripts.php?id=55", { username: '' },
    function(data){
          $.fn.nyroModalManual({
                height: null, 
                width: null, 
                content: data
         });
    });
}

$("#distedloginform").livequery('submit', function(event) {
	$(this).ajaxSubmit({ 
			url:       'scripts.php?id=130',
			target:        '#syncmessage'
	});
	return true;
});

$(document).ready(function(){
$(":password").keypress(function (e) {
      if (e.which == 13){
      	
        $("#shareloginform").submit();
      	
      }
});

$(".formattable1 tr:odd").css({backgroundColor:"#f9f7f3"});
$(".formattable2 tr:even").css({backgroundColor:"#d7e9f7"});

    var getnoticemeWidth = 170;
    
    var setnoticemeWidth = 0;
    
    $('a.shiftleft').click(function(){
    setnoticemeWidth = setnoticemeWidth + getnoticemeWidth; 
    $('#noticemewindow').animate({left: setnoticemeWidth}, 500);
    return false;
    });
    $('a.shiftright').click(function(){
    setnoticemeWidth = setnoticemeWidth - getnoticemeWidth;
    $('#noticemewindow').animate({left: setnoticemeWidth}, 500);
    return false;
    });

	

	checkMenuStatus();
	
	$(".bigli").hover(
      function () {
      	$(this).children(":first-child").css("background-image","url(images/mainnavhoverbg.jpg)");
		var id = '#' + $(this).attr("id") + '-hover';
       
		 $(id).show();

      }, 
      function () {
       $(this).children(":first-child").css("background-image","none");
       var id = '#' + $(this).attr("id") + '-hover';
       
         $(id).hide();
         
         
      }
    );
    
    
    
    
    
	
	$("div").each(function() {
			
		if ($(this).is("#navslide")) {
			

            
            
			$(this).click(function () { 
            	var changebg = $(this).is(":visible");
                if (changebg == true) {
                        $(this).css({"backgroundImage" : "url(../images/opensubnav.gif)", "backgroundRepeat" : "repeat-x", "fontWeight" : "bold", "borderBottom" : "solid 1px #acd2e4"});
                }
				$(this).next().slideToggle(400,function() {
            		var slidevisible = $(this).is(":visible");
                    if (slidevisible == true) {
                    	$(this).prev().children(":first-child").attr("id", "minus");
                    	var oldcookiei = getCookie('cookiei');
                        oldcookiei++;
                        var containingli = $(this).parent(); 
                        var liindex = $(containingli).parent().children("li").index(containingli); 
                     	eval("setCookie('menuitem" + oldcookiei + "', '" + liindex + "', null);");
                        setCookie('cookiei', oldcookiei, null);
                        setCookie('sid', '33', null);
                    } else {
                        $(this).prev().css({"background-color" : "#F7F7F7", "backgroundImage" : "none", "fontWeight" : "normal", "borderBottom" : "none"});
                   		$(this).prev().children(":first-child").attr("id", "plus");
                    	var oldcookiei = getCookie('cookiei');
                        var containingli = $(this).parent(); 
                        var liindex = $(containingli).parent().children("li").index(containingli); 
                        for(i=1; i<=oldcookiei; i++) {
                            eval("var menuitem = getCookie('menuitem" + i + "');");
                            
                            if(menuitem == liindex) {
                            	eval("delCookie('menuitem" + i + "');");
                                
                        	}
                        }
                                
                    }
                });
                
				return false;
			});
            
   
			
		}	
	});
    
    
	
	
		
	
});	 
 
