﻿// JScript File
window.addEvent('domready', function() {
    var list = $$('#navList li');
    list.each(function(element) {
	    var fx = new Fx.Styles(element, {duration:200, wait:false});
	    element.addEvent('mouseover', function(){
		    fx.start({
			    'background-color': '#666',
			    color: '#ff8'
		    });
	    });
	    element.addEvent('mouseout', function(){
		    fx.start({
			    'background-color': '#333',
			    'color': '#888'
		    });
	    });
    });
});

function setHomePage() {
    var myFx = new Fx.Style('RuppRiggers', 'opacity',{duration: 300}).start(0,1);//
    
    $$('#catThumb a').each(function(el) {
        el.addEvents({
		mouseover: function(e) {	
			var e = new Event(e).stop();	
			var myDiv = el.getProperty('title');
			if ($(myDiv).getStyle('visibility') == 'hidden') { 
                     $$('.homeProduct').each(function(el) {el.setOpacity(0);});
                   $(myDiv).effect('opacity', {duration: 300}).start(0,1);   
			    }
	    	}
	    });
    });
}

function SendRequest(url, action, params) {
    var pageURL = url + "?action=" + action + "&param=" + params;
    var xmlRequest, e;
    try {
        xmlRequest = new XMLHttpRequest();
        }
        catch(e) {
            try {
                xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e) {}
        }
        xmlRequest.open("POST",pageURL, false);
        xmlRequest.setRequestHeader("Contect-Type","application/x-www-form-urlencoded");
        xmlRequest.send(null);
}  

function URLEncode(string)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = string;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	
	return encoded;
};