/* ------------------------------------------------------------
 * PROJECT        : NBuy Student Products
 * FILENAME       : nbsp.js
 * ------------------------------------------------------------
 * DATE CREATED   : 29 May 2008
 * LAST UPDATED   : 16 June 2008
 * ------------------------------------------------------------
 * AUTHOR(S)      : Kevin Scholl (http://www.ksscholl.com/)
 * ------------------------------------------------------------
 * NOTE(S)        : 
 * ------------------------------------------------------------ */
 
function buildLinks() {
	// remove current subnavigation
	$("#navSub p").remove();
	$.getJSON("link_lib.php",{category: $("#category").val(), realm: $("#realm").val(), ajax: 'true'}, function(n){
																																																							
    if ($("#realm").val() == "ebay" || $("#realm").val() == "ebay" || $("#realm").val() == "nbuycenters" || $("#realm").val() == "nbuy" || $("#realm").val() == "saynetwork") {
		  var THE_TARGET = "_top";
			}
		else {
		  var THE_TARGET = "contentMain";
  		$("#columnMain").html("");
			$("#columnMain").prepend("<iframe src=\"\" frameborder=\"no\" id=\"contentMain\" name=\"contentMain\"></iframe>");
			}

    $("#contentMain")
			.css("height", $(window).height() - 244 + "px")
			.attr("src", "intros/" + $("#category").val() + "-intro-page.php");			

    // ***** BEGIN REVISED CODE - 2009-09-30 KSS
		$("#navSub")
			.prepend("<span><a href=\"\" title=\"open site below in a new window...\" target=\"_blank\"><img src=\"images/bg_tab_sub-nav.gif\" width=\"20\" height=\"25\" border=\"0\" style=\"vertical-align: middle;\" /></a></span>");
    // ***** END REVISED CODE

		var LNK_STRING = "\n<p>";
		if (n.length > 0) { // make sure there are products listed in library for this tab combination
			for (var i = 0; i < n.length; i++) {
				// Amazon
				// ***** BEGIN REVISED CODE - 2009-09-30 KSS
				LNK_STRING += "<a href=\"" + n[i].lnkURL + "\" target=\"" + THE_TARGET + "\" onclick=\"$('#navSub span a').attr('href',$(this).attr('href'));\">" + n[i].lnkDisplay + "</a>";
				// ***** END REVISED CODE
				if(i != n.length - 1)
					LNK_STRING += " &nbsp;|&nbsp; \n";
				}
			}
		else // if there are no products listed in library for this tab combination
		  LNK_STRING += "No items available at this time.";
		LNK_STRING += "</p>";
		
		// display new subnavigation
		$("#navSub").prepend(LNK_STRING);
		});	
	}


function loadStore(theStore, tabIndex) {
  $("#realm").val(theStore);
	$("#navSub ul li:eq(" + tabIndex + ") a").click();
  }



/* ===================================================== *
 * CHANGE FORMS
 * ===================================================== */
 
function goToURL(theTarget,theURL) {
	var theDestination = "" + theURL;
	eval(theTarget + ".location='" + theDestination + "'");
	}
	
function goToURL2(theTarget,theURL) {
	var theDestination = "" + theURL;
	eval(theTarget + ".location='" + theDestination + "'");
	}
	
function OpenWin9(sLocation) 
{
window.open(sLocation, 'NewWin', 'height=180,width=390,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no')
}

/* ===================================================== *
 * BOOKMARK
 * ===================================================== */ 


function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

/* ===================================================== *
 * BBB
 * ===================================================== */

function Rcertify() 
{
popupWin = window.open('https://www.bbb.org/online/consumer/cks.aspx?id=103062410364733225', 'Participant','location=yes,scrollbars=yes,width=750,height=600'); 
window.name = 'opener';
}

