/*
+---------------------------------------------------+
|                                                   |
|                   Daffny Engine                   |
|                                                   |
|                JavaScript Functions               |
|                                                   |
|                by Alexey Kondakov                 |
|             ©2006 - 2007 Daffny, Inc.             |
|                                                   |
|                  www.daffny.com                   |
|                                                   |
+---------------------------------------------------+
*/


/*----------------------------*/
// Java Button
/*----------------------------*/
function HideButton(name) {
    $('btn_' + name).style.display = 'none';
    $('proc_' + name).style.display = '';
}

/*----------------------------*/
// Delete Something
/*----------------------------*/
function deleteSomething(url, mess) {
    if ( !mess ) mess = 'Are you sure?';
	if ( confirm(mess) ) {
		document.location.href = url;
	} else {
		return false;
	}
}

/*----------------------------*/
// Create Cookie
/*----------------------------*/
function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

/*----------------------------*/
// Check Email Address
/*----------------------------*/
function checkEmailAddress(email) {
    // the following expression must be all on one line...
    var goodEmail = email.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
    if ( goodEmail ) {
        return true;
    } else {
        return false;
    }
}

/*----------------------------*/
// Get Scroll Height
/*----------------------------*/
function getScrollX() {
    
    var scrOfX = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
        //Netscape compliant
        scrOfX = window.pageXOffset;
        
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        //DOM compliant
        scrOfX = document.body.scrollLeft;
        
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        //IE6 standards compliant mode
        
        scrOfX = document.documentElement.scrollLeft;
    }
    return scrOfX;
}

/*----------------------------*/
// Preload Images
/*----------------------------*/
function preloadImages() {
    var d = document;
    if ( d.images ) {
        if ( !d.p ) d.p = new Array();
        var i,j=d.p.length,a=preloadImages.arguments;
        for ( i=0; i<a.length; i++ ) {
            if ( a[i].indexOf("#") != 0 ) {
                d.p[j] = new Image;
                d.p[j++].src = a[i];
            }
        }
    }
}
