var code_status = false;
var description_status = false;
var theForm = false;
var commentBox = false;
var logReg = false;
var chat =false;

/////////////////////////////LOCAL TIME
var currentTime = new Date();
var hour = currentTime.getHours();
var min = currentTime.getMinutes();
var sec = currentTime.getSeconds();
var clock = hour+":"+min+":"+sec;
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var today_date = year+"-"+month+"-"+day;
var timestamp = today_date+" "+clock;
/////////////////////////////

function addDate(a){
document.getElementById(a).value=timestamp;
}

function FadeEffect(element) {
    new Effect.Fade(element, {
        duration: 1
    });
}
function ShowEffect(element, limit) {
    new Effect.Appear(element, {
        duration: 1,
        from: 0,
        to: limit
    });
}

function SlideMenu(element, limit) {
    new Effect.SlideDown(element, {
        duration: limit
    });
}

function SlideHide(element, limit) {
    new Effect.SlideUp(element, {
        duration: limit
    });
}

function goToPage(pageLink) {
    window.location = pageLink;
}
function followOnTw() {
    window.location = ("http://twitter.com/awef");
}
function followOnFb() {
    window.location = ("http://facebook.com/");
}

function fb() {
}
function tw() {
}
function dil() {
}
function rss() {
}
function logIn() {
    new Ajax.Updater('login_msg', 'processing/login.php', {
        method: 'post',
        parameters: $('login_form1').serialize(),

        });

}
function getLoginForm() {

    if (logReg === false) {
        logReg = true;
        SlideMenu('login_div', 0.3);

    } else {
        logReg = false;
        SlideHide("login_div", 0.3);
    }
}
///////////////////////Donations
function donatePaypal() {
}
function donateEmail() {
}
function donatePost() {
}
function donateTel() {
}

///////////////////////
function lightBg(ph) {
    viewPhoto(ph);
    ShowEffect("light_bg", 1);

}
function viewPhoto(ph) {
    window.scrollTo(0, 0);

    document.getElementById('dis_image').innerHTML = "<div id=\"btnNtx\" onclick=\"galleryNext('" + ph + "')\"></div><div id=\"btnPrev\" onclick=\"galleryPrv('" + ph + "')\"></div><img src=\"public/images/gallery/" + ph + "\" onClick=\"galleryNext('" + ph + "')\" title=\"click on this photo to see photo slideshow\" \>";
    ShowEffect("dis_image", 1);
}
function photoOn() {
    FadeEffect("light_bg");
    clearInterval(bigSlide);
}

function doBig() {
    autoLoad('public/includes/gallery.php', 'dis_image');

}
function getGallery() {
    doBig();
    bigSlide = setInterval("doBig()", 5000);
}
function galleryNext(currentPhoto) {
    ShowEffect("dis_image", 1);
    new Ajax.Updater("dis_image", 'processing/get_next_photo.php?next_photo=1&current_photo=' + currentPhoto, {
        method: 'get',
        });

}

function galleryPrv(currentPhoto) {
    ShowEffect("dis_image", 1);
    new Ajax.Updater("dis_image", 'processing/get_next_photo.php?current_photo=' + currentPhoto, {
        method: 'get',
        });

}
///////////////////COMMENT
function showCommentBox() {
    commentBox = true;
    SlideMenu("comment_form", 0.3);
}
function hideCommentBox() {
    commentBox = false;
    SlideHide("comment_form", 0.3);
}
function getTheBox() {
    if (commentBox == true) {
        hideCommentBox();
    } else {
        showCommentBox();
    }

}
function submitComment() {
   var commentTxt = document.getElementById('page_txt').innerHTML;
   document.getElementById('mycomment').value = commentTxt;
   
   
    new Ajax.Updater('response_div', 'processing/comments.php', {
        method: 'post',
        parameters: $('commentForm').serialize(),
        onComplete:loadComments
        });


}


///////RESIZE
function getDivHeight(divId) {
    var DivHeight = document.getElementById(divId).offsetHeight;
    return DivHeight;
}
function getDivWidth(divId) {
    var DivWidth = document.getElementById(divId).offsetWidth;
    return DivWidth;
}

window.onresize = function() {

    resizeHeight();
}

function resizeHeight() {

    var site_leftHeightContent = getDivHeight("column_left");
    var site_rightHeightLeft = getDivHeight("column_right");

    //if(site_contentHeightLeft >site_contentHeightContent){
    //var heightNew = site_contentHeightLeft;
    if (site_rightHeightLeft > site_leftHeightContent) {
        var newHeight = site_rightHeightLeft;
        document.getElementById("column_left").style.height = "" + (newHeight + 100) + "px";
        document.getElementById("main_content").style.height = "" + (newHeight + 100) + "px";
        document.getElementById("trans_bg").style.height = "" + (newHeight + 153) + "px";
    } else {

        document.getElementById("column_right").style.height = "" + site_leftHeightContent + "px";

    }
resizeActivities();
}
function resizeActivities() {

    var site_activies = getDivHeight("latest_activies");
    var site_top_home = getDivHeight("top_home");
if(site_activies !== false){
 if (site_activies > site_top_home) {
        
        document.getElementById("top_home").style.height = "" + (site_activies+ 10) + "px";
    } 
}
   
}
function resizeLeftHeight() {

    var site_leftHeightContent = getDivHeight("main_content");
    var site_rightHeightLeft = getDivHeight("column_right");
    //if(site_contentHeightLeft >site_contentHeightContent){
    //var heightNew = site_contentHeightLeft;
    if (site_leftHeightContent > site_rightHeightLeft) {
        var newHeight = site_leftHeightContent;
    }
    if (site_leftHeightContent < site_rightHeightLeft) {
        var newHeight = site_leftHeightContent;
    }

    document.getElementById("column_right").style.height = "" + newHeight + "px";

}

function deleteComment(comment, commentId) {
    new Ajax.Updater(commentId, 'processing/delete_comment.php?id=' + comment, {
        method: 'get',
        });

}

function deleteBlog(blog) {
    new Ajax.Updater('blog_content', 'processing/delete_blog.php?id=' + blog, {
        method: 'get',
        });

}
function editBlog(blog) {
    window.location = ("index.php?id=blogs&blog=" + blog + "&ed=admin");
}
/////////////////SUBMENU
function subMenu() {
    //offSubMenuForum();
    ShowEffect("media_sub", 0.9);
    showSenser();
    showSenser1();
}
function showSenser() {

    ShowEffect("media_sub_senser", 0.9);

}

function showSenser1() {

    ShowEffect("media_sub_senser1", 0.9);

}
function offSubMenu() {
    FadeEffect("media_sub", 0.9);
    FadeEffect("media_sub_senser", 0.9);
    FadeEffect("media_sub_senser1", 0.9);
}

function updateBlog() {
    var blogContent = document.getElementById('page_txt').innerHTML;
    var blogTitle = document.getElementById('blog_title').innerHTML;

    document.getElementById('blog_title_f').value = blogTitle;
    document.getElementById('blog_body_f').value = blogContent;

    new Ajax.Updater('response_div', 'processing/blogs.php', {
        method: 'post',
        parameters: $('blogForm').serialize(),

        });

}

/////////////////////////////////2
function subMenuFriends() {

    ShowEffect("friends_sub", 0.9);
    showSenserfriends();
    showSenser1friends();
}
function showSenserfriends() {

    ShowEffect("friends_sub_senser", 0.9);

}

function showSenser1friends() {

    ShowEffect("friends_sub_senser1", 0.9);

}
function offSubMenuFriends() {
    FadeEffect("friends_sub", 0.9);
    FadeEffect("friends_sub_senser", 0.9);
    FadeEffect("friends_sub_senser1", 0.9);
}
/////////////////////////////////Forum
function subMenuForum() {
    offSubMenu();
    SlideMenu("forum_sub", 0.3);;
    showSenserForum();
    showSenser1Forum();
}
function showSenserForum() {

    ShowEffect("forum_sub_senser", 0.9);

}

function showSenser1Forum() {

    ShowEffect("forum_sub_senser1", 0.9);

}
function offSubMenuForum() {
    SlideHide("forum_sub", 0.3);
    FadeEffect("forum_sub_senser", 0.9);
    FadeEffect("forum_sub_senser1", 0.9);
}
/////////////////////////////////Notice
function subMenuNotice() {
    offSubMenu();
    SlideMenu("notice_sub", 0.3);;
    showSenserNotice();
    showSenser1Notice();
}
function showSenserNotice() {

    ShowEffect("notice_sub_senser", 0.9);

}

function showSenser1Notice() {

    ShowEffect("notice_sub_senser1", 0.9);

}
function offSubMenuNotice() {
    SlideHide("notice_sub", 0.3);
    FadeEffect("notice_sub_senser", 0.9);
    FadeEffect("notice_sub_senser1", 0.9);
}
///////////////////////////////////////////
function getPage(page) {
    new Ajax.Updater('member_display', 'public/includes/members.php?pg=' + page, {
        method: 'get',
        });
    currentPage(page);
}

function currentPage(page) {
    //var pageToGet = document.getElementsByTagName('var').innerHTML;
    document.getElementById("g_btn" + page).style.background = '#b0c685';

}

function giveGift(giftId) {
    ShowEffect("gifts", 1);

    new Ajax.Updater('gifts', 'processing/give_gift.php?gft=' + giftId, {
        method: 'get',
        });

}
function addFriend(fd) {
    new Ajax.Updater('friend_btn', 'processing/add_friend.php?fd=' + fd, {
        method: 'get',
        });

}
function addClassmate(fd) {
    new Ajax.Updater('classmate_btn', 'processing/add_classmate.php?fd=' + fd, {
        method: 'get',
        });

}
////////////AUTO REFRESH
function autoLoad(urlLink, commentId) {
    ShowEffect(commentId, 1);

    new Ajax.Updater(commentId, urlLink, {
        method: 'get',
        });
    ShowEffect(commentId, 1);
    ShowEffect(commentId, 1);
    ShowEffect(commentId, 1);
}

function frontPageLoad() {

    autoLoad('processing/photos_home.php', 'home_photos_thumbs_inner')
    }
function footerMsg() {

    autoLoad('processing/live_chat_counter.php', 'msg_counter')
    }
    
function resetPass() {
    autoLoad('public/forms/reset_pass.php', 'nav');
}

function resetNow() {
    new Ajax.Updater('nav', 'processing/reset_password.php', {
        method: 'post',
        parameters: $('login_form').serialize(),

        });
}

function getChat(chatId,chatDel){
if(chat ===false){
ShowEffect("chat_box"+chatId, 1);
chat = true;
}else{
FadeEffect("chat_box"+chatId);
chat = false;
 new Ajax.Updater(chatId, 'processing/delete_live_msg.php?id='+chatDel, {
        method: 'get',
        });
}

}

function enter(evt,respondTo,formId)
		{
		var charCode = (evt.which) ? evt.which : window.event.keyCode; 
		 
		    if (charCode == 13) 
		    { 
			new Ajax.Updater(respondTo, 'processing/live_chat.php', {
                 method: 'post',
                 parameters: $(formId).serialize(),

                 });
			} 
		
		}
		
function getChatForm(idNumber,receiver,sender){
		autoLoad('public/forms/live_chat.php?id='+idNumber+'&r='+receiver+'&s='+sender, "chat_box_msg_l"+idNumber);
		
		}
function chatMember(memMsg){

ShowEffect(memMsg, 1);
}
function approveFriend(approve){
       autoLoad('public/views/approve_friend.php?id='+approve, "show_all");
}

function approveNow(friend,res){
       autoLoad('processing/approve_friend.php?id='+friend, res);
}
function signUp(res){
       ShowEffect("sign_up_bg", 1);
       autoLoad('public/forms/sign_up.php', res);
       
        var heightForm = getDivHeight(res);
        document.getElementById("main_content").style.height = "" + (heightForm + 100) + "px";
}
function newMember(){
                  new Ajax.Updater("response_vid", 'processing/sign_up.php', {
                 method: 'post',
                 parameters: $("members_form").serialize(),

                 });
}
function showDetailsFor(member_entry){

   ShowEffect(member_entry, 1);
}
function hideDetailsFor(member_entry){
   FadeEffect(member_entry);
}
function publishForum(){
var blogBody = document.getElementById("forum_body_txt").innerHTML;
var blogTitle = document.getElementById("forum_title_txt").innerHTML;
//var blogSource = document.getElementById('source_blog').innerHTML;
    document.getElementById("body_forum").value = blogBody;
    document.getElementById("title_forum").value = blogTitle;
    //document.getElementById('blog_source').value = blogSource

new Ajax.Updater( 'response_forum', 'processing/forums.php', 
			                         { 
			                           method: 'post', 
			                           parameters: $('forum_form').serialize(),
			    
				                      }         );

}
function approveMemNow(member){

autoLoad('processing/approve_member.php?id='+member, "show_"+member);
}
function declineMemNow(member){

autoLoad('processing/approve_member.php?dl='+member, "show_"+member);
}
function showPm(member){

autoLoad('public/forms/pm.php?id='+member, "show_all");
}
function showBroadcast(){

autoLoad('public/forms/broadcast.php', "show_all");
}
function sendPm(member){

new Ajax.Updater( 'response_pm', 'processing/pm.php?send=send', 
			                         { 
			                           method: 'post', 
			                           parameters: $('pm_form').serialize(),
			    
				                      });
}
function broadcastPm(){

new Ajax.Updater( 'response_pm', 'processing/broadcast.php', 
			                         { 
			                           method: 'post', 
			                           parameters: $('pm_form').serialize(),
			    
				                      });
}

function replyPm(member){

autoLoad('processing/pm.php?reply='+member, "show_all");
}

function getBigPhoto(photo){
autoLoad('processing/gallery_show.php?id='+photo, "gallery_display_thumb_inner");

}
function getPhoto(photo){
autoLoad('processing/show_big_image.php?id='+photo, "big_image");

}
function getForum(id,cat){
autoLoad('public/includes/forums.php?pg='+id+'&category='+cat, "page_holder");

}
function deleteForum(forum){
autoLoad('processing/delete_forum.php?id='+forum, "forum_content");

}
function searchForMember(){
var keywords = document.getElementById('keywords').value;
autoLoad('public/includes/search_members.php?pg=1&keywords='+keywords, "member_display");

}
function shareThis(){
ShowEffect("share_with", 0.9);
}
function shareNow(id,sender){
autoLoad('processing/share.php?id='+id+'&sender='+sender, "share_response");
}
function showVideo(video,title){
                  var editedHtml = '<object width="624" height="330" type="application/x-shockwave-flash" data="public/flash/duze_player.swf" id="home_top_player" style="visibility: visible;"><param name="wmode" value="transparent"><param name="flashvars" value="youtube='+video+'&amp;video_title='+title+'&amp;autoplay=true"></object>';
	                             document.getElementById('home_top_player_outer').innerHTML= editedHtml;
                     } 
function openReset(){

document.getElementById('reset_form').style.display='block';
}

