

//textarea counter
function textCounter(field, maxlimit, divID) {
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	} else {
	    character_message = maxlimit - field.value.length + ' character';
        if (maxlimit - field.value.length != 1) character_message += 's';
	    character_message += ' left';
		document.getElementById(divID).innerHTML = character_message;
	}
}

function toggle_div(targetId, targetId2) {
    if (document.getElementById) {
        target  = document.getElementById(targetId);
        target2 = document.getElementById(targetId2);
        if (target.style.display == "none") {
            target.style.display = "block";
            target2.style.display = "none";
        } else { 
            target.style.display = "none";
            target2.style.display = "block";
        }
    }
}


function toggle_div_show1_hide2(targetId, targetId2) {
    if (document.getElementById) {
        target  = document.getElementById(targetId);
        target2 = document.getElementById(targetId2);
        target.style.display = "block";
        target2.style.display = "none";
    }
}


function toggle_div_3way(targetId1, targetId2, targetId3) {
    if (document.getElementById) {
        target1 = document.getElementById(targetId1);
        target2 = document.getElementById(targetId2);
        target3 = document.getElementById(targetId3);
        if (target2.style.display == "none") {
            target1.style.display = "none";
            target2.style.display = "block";
            target3.style.display = "none";
        } else { 
            target1.style.display = "inline";
            target2.style.display = "none";
            target3.style.display = "block";
        }
    }
}

function toggle_new_panels(panel1, panel2, panel3) {
    if (document.getElementById) {
        document.getElementById('new_panel1').style.display = panel1;
        document.getElementById('new_panel2').style.display = panel2;
        document.getElementById('new_panel3').style.display = panel3;
    }
}

function ShowHideDiv(div) {
	var target = document.getElementById(div);
		
	if(target.style.display == "none" || target.style.display=="") {
		target.style.display = "block";
	}
	else {
		target.style.display = "none";
	}
}



function swapHomeNewPanel() {
    if (currentNewPanel) {
        
        if (currentNewPanel == 1) {
            toggle_new_panels('none', 'block', 'none');
            currentNewPanel = 2;
        } else if (currentNewPanel == 2) {
            toggle_new_panels('none', 'none', 'block');
            currentNewPanel = 3;
        } else if (currentNewPanel == 3) {
            toggle_new_panels('block', 'none', 'none');
            currentNewPanel = 1;
        }
        
        var newPanelAutoSwap = setTimeout('swapHomeNewPanel()',2500);
        
    } else {
        newPanelAutoSwap    = null;
        currentNewPanel     = false;
    }
}

/*
function image_link(url1, url2, width) {
    if (window.event) {
        if (window.event.x >= width || window.event.x < 1) {
            window.location=url2;
        } else {
            window.location=url1;
        }
    } else {
        window.location=url2;
    }
}
*/



function image_link(url1, url2, event) {
    if (document.body.clientWidth) {
        if (window.event) {
            thisX = window.event.x;
        } else {
            thisX = event.clientX;
        }
        if (thisX < (document.body.clientWidth / 2)) {
            if (url1) window.location=url1;
        } else {
            if (url2) window.location=url2;
        }
    }
}

function showAlbumPane(page){
	new Ajax.Updater('album_pane_data', '/365/ajax_365.php', {parameters: { page: page}});
	document.getElementById("album_pane").style.display = "block";
	
}

function hideAlbumPane(){
	document.getElementById("album_pane").style.display = "none";
}



// pre-load some images
search_button1      = new Image();
search_button1.src  = "/images/main/header_search_2a.png";
search_button2      = new Image();
search_button2.src  = "/images/main/header_search_2b.png";


tab_home1           = new Image();
tab_home1.src       = "/images/main/tabs/home1.gif";
tab_home2           = new Image();
tab_home2.src       = "/images/main/tabs/home2.gif";

tab_about1          = new Image();
tab_about1.src      = "/images/main/tabs/about1.gif";
tab_about2          = new Image();
tab_about2.src      = "/images/main/tabs/about2.gif";

tab_blog1           = new Image();
tab_blog1.src       = "/images/main/tabs/blog1.gif";
tab_blog2           = new Image();
tab_blog2.src       = "/images/main/tabs/blog2.gif";

tab_contact1        = new Image();
tab_contact1.src    = "/images/main/tabs/contact1.gif";
tab_contact2        = new Image();
tab_contact2.src    = "/images/main/tabs/contact2.gif";

tab_community1      = new Image();
tab_community1.src  = "/images/main/tabs/community1.gif";
tab_community2      = new Image();
tab_community2.src  = "/images/main/tabs/community2.gif";

tab_signup1         = new Image();
tab_signup1.src     = "/images/main/tabs/signup1.gif";
tab_signup2         = new Image();
tab_signup2.src     = "/images/main/tabs/signup2.gif";

tab_upgrade1        = new Image();
tab_upgrade1.src    = "/images/main/tabs/upgrade1.gif";
tab_upgrade2        = new Image();
tab_upgrade2.src    = "/images/main/tabs/upgrade2.gif";



home_login1         = new Image();
home_login1.src     = "/images/main/login1.gif";
home_login2         = new Image();
home_login2.src     = "/images/main/login2.gif";


header_login1       = new Image();
header_login1.src   = "/images/main/header_login1.png";
header_login2       = new Image();
header_login2.src   = "/images/main/header_login2.png";


gotomysite1         = new Image();
gotomysite1.src     = "/images/main/go_to_my_site1.gif";
gotomysite2         = new Image();
gotomysite2.src     = "/images/main/go_to_my_site2.gif";


eb_edit_small_solo1     = new Image();
eb_edit_small_solo1.src = "/images/edit_buttons/2/edit_small_solo1.gif";
eb_edit_small_solo2     = new Image();
eb_edit_small_solo2.src = "/images/edit_buttons/2/edit_small_solo2.gif";
eb_edit_small_solo3     = new Image();
eb_edit_small_solo3.src = "/images/edit_buttons/2/edit_small_solo3.gif";


eb_favadd1     = new Image();
eb_favadd1.src = "/images/edit_buttons/add_to_favorites1.gif";
eb_favadd2     = new Image();
eb_favadd2.src = "/images/edit_buttons/add_to_favorites2.gif";
eb_favadd3     = new Image();
eb_favadd3.src = "/images/edit_buttons/add_to_favorites3.gif";



contest_view1       = new Image();
contest_view1.src   = "/contest/images/view_entries1.png";
contest_view2       = new Image();
contest_view2.src   = "/contest/images/view_entries2.png";

contest_vote1       = new Image();
contest_vote1.src   = "/contest/images/vote1.png";
contest_vote2       = new Image();
contest_vote2.src   = "/contest/images/vote2.png";

album_pane       = new Image();
album_pane.src   = "/365/images/album_pane.png";
