//user name and password top and bottom	
var	pVal;

if(document.getElementById('username1')) {
	var u1 = document.getElementById('username1');
	var p1 = document.getElementById('password1');
	var f1 = document.getElementById('fake1');
}

if(document.getElementById('username2')) {
	
	var u2 = document.getElementById('username2');
	var p2 = document.getElementById('password2');
	var f2 = document.getElementById('fake2');

	
}

function addFieldAction(myField,myVal,myPField) {
	var val = myVal;

	myField.onfocus = function() {
	    if (this.value == val) {
	        this.value = "";
	        this.style.color = "#555";

	    }
	}

	myField.onblur = function() {
	    if (this.value == "") {
	        this.value = val;
	        this.style.color = "#aaaaaa";
	    }
	}
}

function addPasswordAction(pField,fake) {
	
	fake.onfocus = function() {
		
		fake.style.display="none";
		fake.style.visibility="hidden";
		pField.style.display="inline";
		pField.style.visibility="visible";
		pField.style.color="#555"
		pField.focus();
		

	}
	
	pField.onblur = function() {
		pVal = this.value;
		if(pVal == ""){
			fake.style.display="inline";
			fake.style.visibility="visible";
			pField.style.display="none";
			pField.style.visibility="hidden";
			pField.value=pVal;

		}else{pField.value=pVal;}
	}
}

if(document.getElementById('username1')) {
	addFieldAction(u1,'username or email',p1);
	addPasswordAction(p1,f1);
}

if(document.getElementById('username2')) {
	addFieldAction(u2,'username or email',p2);
	addPasswordAction(p2,f2);
}

if (document.getElementById('logIn')) {
    //top login
    var IE = (navigator.userAgent.indexOf("MSIE") >= 0)
    var login = document.getElementById('logIn')
    var logout = document.getElementById('logOut')
    var loginfield = document.getElementById('headerLogin')

    login.onclick = function() {
        this.style.display = "none";
        loginfield.style.display = "block";
        loginfield.style.opacity = "0";
        loginfield.style.filter = "alpha(opacity=0)";

        for (fd = 0; fd < 11; fd++) {
            if (IE) { setTimeout('document.getElementById("headerLogin").style.filter="alpha(opacity=' + (fd * 10) + ')"', fd * 50) }
            else { setTimeout('document.getElementById("headerLogin").style.opacity="' + fd / 10 + '"', fd * 50) } 
        }

        return false;
    }
}

// RANDOM BANNER IMAGE
if(document.getElementById('rotatingBanner')) {
	var randomImages = ['1','2','3','4','5'];
	var rndNum = Math.floor
	(Math.random() * randomImages.length);
	document.getElementById('rotatingBanner').style.backgroundImage="url(images/photos_"+randomImages[rndNum]+".jpg)";
}

// light box function "colorbox"
$(document).ready(function(){
	//Examples of how to assign the ColorBox event to elements
	$(".colorbox").colorbox();
				
});

function quickentryText() {
    $('#quickentry .text').each(function(index) {

        var sval = $(this);
        var sStart = $(this).val();

        if (sval.val() == "") {
            sval.val(sStart);
        }
        sval.bind({
            focus: function() {
                if (sval.val() == sStart) {
                    sval.val("");
                }
            },
            blur: function() {
                if (sval.val() == "") {
                    sval.val(sStart);
                }
            }
        });
    });
}

$(document).ready(function() {
    quickentryText();
    /*
    $('#quickentry .text').each(function(index){
		
	    var sval = $(this);
    var sStart = $(this).val();
		
	    if ( sval.val() == "" ) {
    sval.val(sStart);
    }
    sval.bind({
    focus : function() {
    if ( sval.val() == sStart ) {
    sval.val("");
    }	
    },
    blur : function() {
    if ( sval.val() == "" ) {
    sval.val(sStart);
    }	
    }
    });
    });
    */
});


//add .even class to tables
//$(document).ready(function(){
//	$('tbody tr:odd').addClass('odd')
//});

