rbn = {
	ell: function(id){
		return document.getElementById(id);
	}
	,
	signedIn: false
	,
	ses: ''
	,
	act: 0
	,
	addEvent: function(obj,ev,func,useCapture){
		if ( obj.addEventListener )
			obj.addEventListener(ev,func,useCapture);
		else if ( obj.attachEvent )
			obj.attachEvent('on'+ev,function(){func.call(obj,event);});//OMG....i actually got it...oh the relief...of never having to deal with ie and events ever again...well...shouldn't get my hopes too high :(
		else
			obj['on'+ev] = func;
	}
	,
	removeEvent: function(obj,ev,func,useCapture){
		if ( obj.removeEventListener )
			obj.removeEventListener(ev,func,useCapture);
		else if ( obj.detachEvent )
			obj.detachEvent('on'+ev,function(){func.call(obj,event);});
		else
			obj['on'+ev] = function(){};
	}
	,
	searchForm: {
		defaultQuery: ''
		,
		focusEvent: function(ref){
			if ( ref.value==rbn.searchForm.defaultQuery )
				ref.value = '';
			
			ref.className = 'search-focused search-input';
		}
		,
		blurEvent: function(ref){
			if ( ref.value=='' )
				ref.value = rbn.searchForm.defaultQuery;
			
			ref.className = 'search-blurred search-input';
		}
		,
		submit: function(){
			document.search_form.submit();
		}
	}
	,
	placeHolder: {
		focusEvent: function(){
			if ( this.value==this.baseValue ){
				this.value = '';
				this.className = this.focusClassName;
			}
		}
		,
		blurEvent: function(){
			if ( this.value=='' ){
				this.value = this.baseValue;
				this.className = this.blurClassName;
			}
		}
	}
	,
	getDocSize: function(){//Thanks to http://james.padolsey.com/javascript/get-document-height-cross-browser
		var D = document;
		
		return [
			Math.max(
				D.body.scrollWidth , D.documentElement.scrollWidth , 
				D.body.offsetWidth , D.documentElement.offsetWidth , 
				D.body.clientWidth , D.documentElement.clientWidth
			)
			,
			Math.max(
				D.body.scrollHeight , D.documentElement.scrollHeight , 
				D.body.offsetHeight , D.documentElement.offsetHeight , 
				D.body.clientHeight , D.documentElement.clientHeight
			)
		];
	}
	,
	getObjectPosition: function(inputElement){http://blog.firetree.net/2005/07/04/javascript-find-position/
		var coords = [0,0];
		
		try {
			targetElement = inputElement;
			
			if ( targetElement.x && targetElement.y ){
				coords[0] = targetElement.x;
				coords[1] = targetElement.y;
			}
			else {
				if( targetElement.offsetParent ){
					coords[0] += targetElement.offsetLeft;
					coords[1] += targetElement.offsetTop;
					
					while( targetElement = targetElement.offsetParent ){
						coords[0] += targetElement.offsetLeft;
						coords[1] += targetElement.offsetTop;
					}
				}
				else {
					//alert("Could not find any reference for coordinate positioning.");
				}
			}
			
			return coords;
		}
		catch(error) {
			//alert(error.msg);
			return coords;
		}
	}
	,
	getMousePosition: function(e){//Thanks to http://www.quirksmode.org/js/events_properties.html
		var x = 0, y = 0;
		
		if ( !e )var e = window.event;
		
		if ( e.pageX || e.pageY ){
			x = e.pageX;
			y = e.pageY;
		}
		else if ( e.clientX || e.clientY ){
			x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}
		
		return [x,y];
	}
	,
	getXMLHttp: function(){
		var xmlHttp;
		
		try {
			xmlHttp = new XMLHttpRequest();
		}
		catch(e){
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e){
				try {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e){
					return null;
				}
			}
		}
		
		return xmlHttp;
	}
	,
	attachHint: function(obj,hint,width,height){
		if ( typeof rbn.attachHint.hintIndex=='undefined' )
			rbn.attachHint.hintIndex = 0;
		
		obj.paragraphs = hint.split("\n");
		obj.hintIndex = rbn.attachHint.hintIndex++;
		
		rbn.addEvent( obj , 'mouseover' , function(){
			var hintBoxId = 'js_hint_box' + this.hintIndex,
				hintBox = rbn.ell(hintBoxId);
			
			if ( hintBox )
				hintBox.style.display = 'block';
			else {
				hintBox = document.createElement('div');
				hintBox.id = hintBoxId;
				hintBox.className = 'hint-box';
				hintBox.style.top = (this.offsetTop + this.offsetHeight) + 'px';
				hintBox.style.left = this.offsetLeft + 'px';
				hintBox.style.width = (width) ? ((width-4) + 'px') : 'auto';
				hintBox.style.height = (height) ? ((height-4) + 'px') : 'auto';
				
				for (var i=0; i<this.paragraphs.length; i++){
					var p = document.createElement('p');
					p.className = (i==0) ? 'first-hint' : '';
					p.appendChild( document.createTextNode(this.paragraphs[i]) );
					hintBox.appendChild(p);
				}
				
				document.body.appendChild(hintBox);
			}
			
			hintBox.style.top = (this.offsetTop + this.offsetHeight) + 'px';
			hintBox.style.left = this.offsetLeft + 'px';
		} );
		
		rbn.addEvent( obj , 'mouseout' , function(){
			var hintBox = rbn.ell('js_hint_box' + this.hintIndex);
			
			if ( hintBox )
				hintBox.style.display = 'none';
		} );
	}
	,
	submitForm: function(name,type){
		if ( type=='frame' ){
			window.frames['browse_frame'].document.forms[name].submit();
		}
		else
			document[name].submit();
	}
	,
	mc: {
		focusEvent: function(ref){
			if ( ref.value=='Email' )
				ref.value = '';
			
			rbn.ell('js_mce-hidden').style.display = 'block';
		}
		,
		blurEvent: function(ref){
			if ( ref.value=='' )
				ref.value = 'Email';
		}
	}
	,
	validateProduct: function(form){
		if ( /^[0-9]+$/.test(form.sku.value)==false || form.sku.value==0 ){
			alert('Please Select a Color/Option');
			return false;
		}
		
		return true;
	}
	,
	feedback: {
		eventOpen: function(){
			rbn.ell('js_feedback_anchor').blur();
			rbn.ell('js_feedback').className = 'feedback-selected';
			rbn.ell('js_feedback_submit').style.display = 'block';
			rbn.ell('js_feedback_close').style.display = 'block';
			rbn.ell('js_feedback_content').style.display = 'block';
		}
		,
		eventClose: function(){
			rbn.ell('js_feedback_anchor').blur();
			rbn.ell('js_feedback').className = 'feedback-unselected';
			rbn.ell('js_feedback_submit').style.display = 'none';
			rbn.ell('js_feedback_close').style.display = 'none';
			rbn.ell('js_feedback_content').style.display = 'none';
		}
		,
		content: {
			eventFocus: function(){
				rbn.ell('js_feedback_content').className = 'float-left content-focused';
				
				if ( rbn.ell('js_feedback_content').value=='Write your feedback here.' )
					rbn.ell('js_feedback_content').value = '';
			}
			,
			eventBlur: function(){
				rbn.ell('js_feedback_content').className = 'float-left content-blurred';
				
				if ( rbn.ell('js_feedback_content').value=='' )
					rbn.ell('js_feedback_content').value = 'Write your feedback here.';
			}
		}
	}
};

rbn.addEvent( window , 'load' , function(){
	rbn.addEvent( rbn.ell('js_search_submitter') , 'click' , rbn.searchForm.submit );
	
	rbn.addEvent( rbn.ell('js_feedback_anchor') , 'click' , rbn.feedback.eventOpen );
	rbn.addEvent( rbn.ell('js_feedback_close') , 'click' , rbn.feedback.eventClose );
	rbn.addEvent( rbn.ell('js_feedback_content') , 'focus' , rbn.feedback.content.eventFocus );
	rbn.addEvent( rbn.ell('js_feedback_content') , 'blur' , rbn.feedback.content.eventBlur );
	
	if ( screen.width<900 )
		document.body.style.width = '1000px';
} );
