if (!window.addEventListener) {
    window.addEventListener = function (type, listener, useCapture)
    {
        attachEvent('on' + type, function() { listener(event) });
    };
}
var CWR_PRODUCT_SEARCH = {
    qText : 'Search for ...',
    fs    : '',
    fc    : '',

	init : function()
	{
	    var q = document.getElementById('q');
	    var qPrev = document.getElementById('qPrev').value;
	    q.value = qPrev;
	    var fs, fc;
	    if (typeof q.currentStyle == 'undefined') {
	        fs = document.defaultView.getComputedStyle(q, null).getPropertyValue('font-style');
	        fc = document.defaultView.getComputedStyle(q, null).getPropertyValue('color');
	    } else {
	        fs = q.currentStyle.fontStyle;
	        fc = q.currentStyle.color;
	    }
	    CWR_PRODUCT_SEARCH.fs = fs;
	    CWR_PRODUCT_SEARCH.fc = fc;
	    if (qPrev != CWR_PRODUCT_SEARCH.qText) {
	        q.style.fontStyle = 'normal';
	        q.style.color = 'black';
	    }
	    document.getElementById('q').onfocus = CWR_PRODUCT_SEARCH.qFocus;
	    document.getElementById('q').onblur = CWR_PRODUCT_SEARCH.qBlur;
	    document.getElementById('qForm').onsubmit = CWR_PRODUCT_SEARCH.qFormCheck;
	},

    qFocus : function()
    {
        if (this.value == CWR_PRODUCT_SEARCH.qText) {
            this.value = '';
            this.style.fontStyle = 'normal';
            this.style.color = 'black';
        }
        return true;
    },

    qBlur : function()
	{
        if (!this.value) {
            this.value = CWR_PRODUCT_SEARCH.qText;
            this.style.fontStyle = CWR_PRODUCT_SEARCH.fs;
            this.style.color = CWR_PRODUCT_SEARCH.fc;
        }
		return true;
	},

	qFormCheck : function() 
	{
		var q = document.getElementById('q');
        if (q.value == CWR_PRODUCT_SEARCH.qText) {
            q.value = '';
        }
        return true;
	}
};

window.addEventListener('load', function(e) {CWR_PRODUCT_SEARCH.init();}, false);
