var timeout	= 600;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring (0,mlength)
}

function run_query()
{
        var pass = document.query_form.query_term.value;
        if(pass!="")
        {
        var search_term = 'http://www.google.com/search?q=define%3A'+pass;
        window.open(search_term,'mywindow','width=600,height=500,toolbar=yes,scrollbars=yes');
        return 0;
        }
}

function check_security(password, updatefield)
{
        var pass = document.getElementById(password).value;
        var score = 0;
        var result;

        if(pass.length < 6){
                score = score - 1;
        }

        if(!pass.match(/[a-z_]/i) || !pass.match(/[0-9]/)){
                score = score - 1;
        }

        if(!pass.match(/\W/)){
                score = score - 1;
        }

        if(score == 0){
                result = '<img src="img4.jpg"/>';
        } else if(score == -1){
                result = '<img src="img3.jpg"/>';
        } else if(score == -2){
                result = '<img src="img2.jpg"/>';
        } else if(score == -3){
                result = '<img src="img1.jpg"/>';
        }

        document.getElementById(updatefield).innerHTML = result;

        return;
}

function plagiarism_query()
{
        var pass = document.query_form.query_term.value;
        if(pass!="")
        {
        var search_term = 'http://www.google.com/search?&q=%22'+pass+'%22';
        window.open(search_term,'mywindow','width=600,height=400,toolbar=yes,scrollbars=yes');
        return 0;
        }
}

function space_query()
{
        var term = document.query_form.query_term.value;
        if(term!="")
        {
        var search_term = 'http://www.google.com/search?hl=en&safe=off&rls=GGGL%2CGGGL%3A2006-19%2CGGGL%3Aen&q=intitle%3Aindex.of+.mp3+site%3A.edu+'+term+'&btnG=Search';
        window.open(search_term,'mywindow','width=750,height=500,toolbar=yes,scrollbars=yes');
        return 0;
        }
}

function calculateearnings() {
 var price=(document.cbform.price.value);
 var rate=(document.cbform.rate.value);
 
 if(price!="" && rate!="")
 {
 var cbcomm=(Math.round(((price*.075) + 1)*100))/100;
 var netprice=(Math.round((price-cbcomm)*100))/100;
 
 var aff  =(Math.round(((netprice*(rate/100)))*100))/100;
 var vend =(Math.round((netprice-aff)*100))/100;

 document.getElementById('affiliatecomm').innerHTML = aff;
 document.getElementById('vendorcomm').innerHTML = vend;
 }
 return false;
 }

function popUpToDo(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open('http://www.neilstoolbox.com/to-do-list/todo.htm', '"+ id +"', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=0,width=420,height=450,left = 322,top = 159');");
}
