var req;
try {
	req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
	try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e2) {
		req = null;
	}
}
if (!req && typeof XMLHttpRequest != "undefined") {
	req = new XMLHttpRequest();
}
function callServer() {
  var url = "active.htm";
  req.open("GET", url, true);
  req.onreadystatechange = requestDone;
  req.send(null);
}
function requestDone() {
	if (req.readyState == 4) {
		var response = req.responseText;
		if(response.indexOf("live_on")>=0){
			setLiveOn();
		}
	}
}
function setLiveOn(){
	var ls = document.getElementById('live_support');
	ls.href = "#";
	ls.onclick = function () { window.open("http://livechat.rx-partners.biz/cust_chat.php",'Cust','toolbar=no location=no directories=no menubar=no resizable=yes scrollbars=yes width=450 height=450'); return false; };
	ls.alt="Live Support - ONLINE"
	//ls.firstChild.src = "imgs/live_on.gif";
}
// -------------------

var flash_id = 0;

function setFlId(el){
	if(el.id.indexOf("flash_id")==0) return el.id;
	flash_id++;
	el.id = "flash_id"+flash_id;
	return el.id;
}
function setSO(id,swfName,w,h,txt){
	if(id==null)return;
	var so = new SWFObject(swfName+".swf", null, w, h, 8);
	so.addVariable("txt", txt);
	so.write(id);
	//return so;
}

var myrules = {
	'.fl_hdr' : function(el){
		var txt = el.firstChild.innerHTML.split(" #");
		var w = txt[1] || 120;
		setSO(setFlId(el),"hdr",w,24,txt[0]);
	},
	'.prod .price' : function(el){
		setSO(setFlId(el),"pr",94,45,el.innerHTML);
	},
	'.also .price' : function(el){
		setSO(setFlId(el),"pr",94,45,el.innerHTML);
	},
	'#fl_top' : function(el){
		var so = new SWFObject("top.swf", null, 900, 247, 5);
	    so.addParam("quality", "medium");
		if(el.title!=null){
			so.addVariable("active", el.title);
		}
		so.write("fl_top");
	},
	'.buy img' : function(el){
		el.title = "Buy now!";
		el.onmouseover = function(){
			this.src = "imgs/buy_over.gif";
		}
		el.onmouseout = function(){
			this.src = "imgs/buy.gif";
		}
	},
	'p.test' : function(el){
		el.onmouseover = function(){
			this.style.border = "solid #CCCCCC 1px";
			this.style.background = "#FAFAFA";
		}
		el.onmouseout = function(){
			this.style.border = "dotted #CCCCCC 1px";
			this.style.background = "#FFFFFF";
		}
	},
	'.also' : function(el){
		el.onmouseover = function(){
			this.style.borderStyle = "solid";
		}
		el.onmouseout = function(){
			this.style.borderStyle = "dotted";
		}
	},
	'#live_support' : function(el){
		callServer();
	}
	
}

Behaviour.register(myrules);