function mOvr(src,clrOver){ 
	if (!src.contains(event.fromElement)){ 
		src.style.cursor = 'hand'; 
		src.bgColor = clrOver; 
	} 
} 
function mOut(src,clrIn){ 
	if (!src.contains(event.toElement)){ 
		src.style.cursor = 'default'; 
		src.bgColor = clrIn; 
	} 
} 
function mClk(src){ 
	if(event.srcElement.tagName=='td')
		src.children.tags('a')[0].click();
}

function preview( viewType ) {
	var leftpos = 0,
	toppos = 0;
		
	if (screen) {
		leftpos = screen.width/2-200;
		toppos = screen.height/2-200;
	}
	if ( viewType == 'sig' ) { window.open('user_prefs_preview_popup.asp?view=sig','','width=500,height=500,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no,left='+leftpos+',top='+toppos); }
	else if ( viewType == 'pro' ) { window.open('user_prefs_preview_popup.asp?view=pro','','width=500,height=500,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no,left='+leftpos+',top='+toppos);  }
	return;
}

function validateLogin(uname,passwd) {
	if ( uname.value == "" )
	{ alert("You have not entered your user name."); return false; }
	if ( passwd.value == "" )
	{ alert("You have not entered your password."); return false; }
	return true;
}

function gotoLink(forumlist) {
    var OptionIndex=forumlist.selectedIndex;
    if (OptionIndex > 0 && forumlist.options[OptionIndex].value && forumlist.options[OptionIndex].value != -1) {
        document.location = forumlist.options[OptionIndex].value;
    }
}

var passdfieldHasFocus = 0;
function focusLogin() {
	if(!passdfieldHasFocus && document.all.hclogin) {
		document.all.hclogin.uname.focus();
	}
}

function loginfocus(ref) {
    passdfieldHasFocus = 1;
}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

/* Set default focus as appropriate. 
	Add new element IDs to the list in order of priority
	ID are used for proper cross browser support, document.all should NEVER be used
*/
if(!document.$) { function $(e) { if(e.indexOf(".") == -1) { return document.getElementById(e); } else { return eval("document.all."+e+";"); } } } 
function defaultFocus(items) {
    try
    {
	    var ids = (items != undefined) ? items : "login-name,login-password,skeyword";
    	var elements = ids.split(",");
    	for(var i = 0; i < elements.length; i++) 
    	{
	    	if(document.getElementById(elements[i]) != null) 
	    	{
		    	if(document.getElementById(elements[i]).value == "") 
		    	{
		    		document.getElementById(elements[i]).focus();
		    		return;
		    	}
	    	}
    	}
    }
    catch(err)
    {
    }
}

function trim(str) 
{     
if(!str || typeof str != 'string')  
{      
    return "";     
}   
    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' '); 
}

function selectOptionInList( selectList, intID )
{
    var intIndex = 0;
    // Loop through all the options
    for( intIndex = 0; intIndex < selectList.options.length; intIndex++ )
    {
    // Is this the ID we are looking for?
        if( selectList.options[intIndex].value == intID )
        {
            // Select it
            selectList.selectedIndex = intIndex;
            // Yes, so stop searching
            break;
        }
    }
}

function toggleVisibility(elementID)
{
    if (document.getElementById(elementID) != null)
    {
        if(document.getElementById(elementID).style.display=='') 
        { 
            document.getElementById(elementID).style.display='none';
        }
        else 
        {
            document.getElementById(elementID).style.display='';
        }
    }
}

function validateInput(){
    if (document.getElementById("rating1").checked || document.getElementById("rating2").checked){
        return true;
    }
        alert("Please enter your vote!");
        return false;
}


// Toggle textfield form element class names when it is/isn't populated
function setFormElementClass(SourceID, DefaultClassName, PrefilledClassName)
{
    var source = document.getElementById(SourceID);
    if (source !== null)
    {
        if (source.value != '') { source.className = DefaultClassName; }
        else 
        {
            source.value = '';
            source.className = PrefilledClassName;
        }
        
        if (source.value == source.defaultValue) { source.value = ''; }
    }
}

function openWindow(url, width, height, resizable, scrollbars, menubar, toolbar, directories, location, status)
{
    var leftpos = 0, toppos = 0;
	if (screen) { leftpos = screen.width/2-(width/2); toppos = screen.height/2-(height/2); }
	var output = window.open(url,'','width=' + width + ',height=' + height + ',resizable=' + resizable + ',scrollbars=' + scrollbars + ',menubar=' + menubar + ',toolbar=' + toolbar + ',directories=' + directories + ',location=' + location + 'status=' + status + ',left=' + leftpos + ',top=' + toppos + '');
}