/* ---------------------------- */
/* XMLHTTPRequest Enable		*/
/* ---------------------------- */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();

/* ------------- */
/* Menu Updates  */
/* ------------- */
function RFMsearch(Category_ID,CatLinkColor,CatPrefix) {
	nocache = Math.random();
	http.open('get', parent.location.protocol + '//' + document.domain + '/SB-RFMsearch.cfm?RFMcategory_ID='+Category_ID+'&CatLinkColor='+CatLinkColor+'&CatPrefix='+CatPrefix+'&nocache='+nocache);
	http.onreadystatechange = RFMsearchReply;
	http.send(null);
}
function RFMsearchReply() {
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('RFMsearch').innerHTML=response;
	}
}

function SFXsearch(Category_ID,CatLinkColor,CatPrefix) {
	nocache = Math.random();
	http.open('get', parent.location.protocol + '//' + document.domain + '/SB-SFXsearch.cfm?SFXcategory_ID='+Category_ID+'&CatLinkColor='+CatLinkColor+'&CatPrefix='+CatPrefix+'&nocache='+nocache);
	http.onreadystatechange = SFXsearchReply;
	http.send(null);
}
function SFXsearchReply() {
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('SFXsearch').innerHTML=response;
	}
}

function loopsearch(Category_ID,CatLinkColor,CatPrefix) {
	nocache = Math.random();
	http.open('get', parent.location.protocol + '//' + document.domain + '/SB-loopsearch.cfm?loopcategory_ID='+Category_ID+'&CatLinkColor='+CatLinkColor+'&CatPrefix='+CatPrefix+'&nocache='+nocache);
	http.onreadystatechange = loopsearchReply;
	http.send(null);
}
function loopsearchReply() {
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('loopsearch').innerHTML=response;
	}
}

function EUsearch(Category_ID,CatLinkColor,CatPrefix) {
	nocache = Math.random();
	http.open('get', parent.location.protocol + '//' + document.domain + '/SB-EUsearch.cfm?EUcategory_ID='+Category_ID+'&CatLinkColor='+CatLinkColor+'&CatPrefix='+CatPrefix+'&nocache='+nocache);
	http.onreadystatechange = EUsearchReply;
	http.send(null);
}
function EUsearchReply() {
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('EUsearch').innerHTML=response;
	}
}

//Jump Menu
function TT_jumpMenu(Product_ID,selObj,restore) {
	if (selObj.options[selObj.selectedIndex].value != 'Add to Cart') {
		eval("self"+".location=parent.location.protocol + '//' + document.domain + '/shopping/order.cfm?doOption="+selObj.options[selObj.selectedIndex].value+"&Product_ID="+Product_ID+"'"); if (restore) selObj.selectedIndex=0;
	} else {
		document.getElementById('orderbox'+Product_ID).innerHTML='<div align="center"><b><a href="http://www.twistedtracks.com/shopping/basket.cfm">Item is in cart!</a></b></div>';
		Accordion2.openPanel(0);
		nocache = Math.random();
		http.open('get', parent.location.protocol + '//' + document.domain + '/SB-cart.cfm?AddProduct_ID='+Product_ID+'&nocache='+nocache);
		http.onreadystatechange = JumpMenuReply;
		http.send(null);
	}
}

function JumpMenuReply() {
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('UpdateCartSB').innerHTML=response;
	}
}

function TT_searchMenu(targ,selObj,restore) {
  eval(targ+".location=parent.location.protocol + '//' + document.domain + '/quicksearch.cfm?search="+document.search.Type.value+document.search.operator.value+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

var lastClicked;
var lastPrefix;
var lastSubType;

function UpdatePreview(PreviewFile,PreviewFilePath,Preview_ID,PreviewProtect,PreviewFontColor,PreviewLinkColor,PreviewPageColor,PreviewCatPrefix,WhichLink,SubType,PreviewName)
{	
	nocache = Math.random();
	http.open('get', parent.location.protocol + '//' + document.domain + '/putpreview.cfm?PreviewFile='+PreviewFile+'&PreviewFilePath='+PreviewFilePath+'&Preview_ID='+Preview_ID+'&PreviewProtect='+PreviewProtect+'&PreviewFontColor='+PreviewFontColor+'&PreviewLinkColor='+PreviewLinkColor+'&PreviewPageColor='+PreviewPageColor+'&PreviewCatPrefix='+PreviewCatPrefix+'&PreviewName='+PreviewName+'&nocache='+nocache);
	http.onreadystatechange = putPreviewReply;
	http.send(null);
	if (WhichLink != '') { document.getElementById(WhichLink).className=PreviewCatPrefix + 'playing' + SubType; };
	if ((lastClicked != undefined) & (lastClicked != '') & (lastClicked != WhichLink)) { 
		document.getElementById(lastClicked).className=lastPrefix + 'preview' + lastSubType; };
	lastClicked = WhichLink;
	lastPrefix = PreviewCatPrefix;
	lastSubType = SubType;
}

function putPreviewReply() {
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('previewDiv').innerHTML=response;
	}
}

function UpdateHistory(Product_ID)
{	
	nocache = Math.random();
	http.open('get', parent.location.protocol + '//' + document.domain + '/SB-history.cfm?product_ID='+Product_ID+'&nocache='+nocache);
	http.onreadystatechange = historyupdateReply;
	http.send(null);
}

function historyupdateReply() {
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('historyupdate').innerHTML=response;
	}
}

function DisplayRelated2(Product_ID,CatFontColor,CatLinkColor,CatPageColor,CatPrefix)
{	
	document.getElementById('pt_related2').innerHTML='<div align="center"><span style="font-size:18px; color:#'+CatLinkColor+';">Loading...</span></div><br />';
	nocache = Math.random();
	http.open('get', parent.location.protocol + '//' + document.domain + '/pt_displayrelated.cfm?product_ID='+Product_ID+'&CatFontColor='+CatFontColor+'&CatLinkColor='+CatLinkColor+'&CatPageColor='+CatPageColor+'&CatPrefix='+CatPrefix+'&nocache='+nocache);
	http.onreadystatechange = DisplayRelated2Reply;
	http.send(null);
}

function DisplayRelated2Reply() {
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('pt_related2').innerHTML=response;
	}
}

function CartRemove(Item)
{	
	nocache = Math.random();
	http.open('get', parent.location.protocol + '//' + document.domain + '/SB-cart.cfm?remove='+Item+'&nocache='+nocache);
	http.onreadystatechange = CartRemoveReply;
	http.send(null);
}

function CartRemoveReply() {
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('UpdateCartSB').innerHTML=response;
	}
}

