/**
 * Global javascript
 *
 * -----------------------------------------\
 * This program is written by Chi Fong LEE  |
 * Copyright reserved.                      |
 * -----------------------------------------/
 *
 * MODIFIED:  
 * @version 1.0,     17/9/2007,       Created.
 * @author  Chi Fong LEE
 */

function disableButton(button){
    button.disable();
}


function toggleFormDisplayNReset(formID_, hideElementID_){
    $(formID_).reset();
    val_ = $(hideElementID_).style.display;
    $(hideElementID_).style.display = (val_ == 'none' || val_=='') ? 'block' : 'none' ;
    $(formID_).enable();
}


function showNResetForm(formID_, hideElementID_){
    $(formID_).reset();
    $(hideElementID_).style.display = 'block';
    $(formID_).enable();
}

function hideNResetForm(formID_, hideElementID_){
    $(formID_).reset();
    $(hideElementID_).style.display = 'none';
    $(formID_).enable();
}

function sleep(millis)
{
    var date = new Date();
    var curDate = null;

    do { curDate = new Date(); }
    while(curDate-date < millis);
} 

function showAjaxLoadingNotice(){
    $('ajax-loading-notice-div').show();
}

function hideAjaxLoadingNotice(){
    $('ajax-loading-notice-div').hide();
}

function disableFormButtons(buttonNodesParentID_){
    var formChildNodes_ = $A($(buttonNodesParentID_).childNodes);
    formChildNodes_.each(  function(childNode_){
                                switch( childNode_.type ){
                                    case 'button':
                                    case 'submit':
                                    case 'reset':
                                        childNode_.disable();
                                        break;
                                    default:
                                        break;
                                }
                            }
                         );
}

function enableFormButtons(buttonNodesParentID_){
    var formChildNodes_ = $A($(buttonNodesParentID_).childNodes);
    formChildNodes_.each(  function(childNode_){
                                switch( childNode_.type ){
                                    case 'button':
                                    case 'submit':
                                    case 'reset':
                                        childNode_.enable();
                                        break;
                                    default:
                                        break;
                                }
                            }
                         );
}


function externallinks() { 
    if (!document.getElementsByTagName) return; 
    var anchors = document.getElementsByTagName("a"); 
    for (var i=0; i<anchors.length; i++) { 
        var anchor = anchors[i]; 
        if (anchor.getAttribute("href") &&     anchor.getAttribute("rel") == "external")anchor.target = "_blank"; 
    } 
} 


if(typeof(HTMLElement)!="undefined" && !window.opera) 
{ 
    HTMLElement.prototype.__defineGetter__("outerHTML",function() 
    { 
        var a=this.attributes, str="<"+this.tagName, i=0;for(;i<a.length;i++) 
        if(a[i].specified) 
            str+=" "+a[i].name+'="'+a[i].value+'"'; 
        if(!this.canHaveChildren) 
            return str+" />"; 
        return str+">"+this.innerHTML+"</"+this.tagName+">"; 
    }); 
    HTMLElement.prototype.__defineSetter__("outerHTML",function(s) 
    { 
        var r = this.ownerDocument.createRange(); 
        r.setStartBefore(this); 
        var df = r.createContextualFragment(s); 
        this.parentNode.replaceChild(df, this); 
        return s; 
    }); 
    HTMLElement.prototype.__defineGetter__("canHaveChildren",function() 
    { 
        return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase()); 
    }); 
} 
//---[ End of file ]-----------------------------------------------------------/
