
	function updateFranchiseList(franchiseID,franchiseName,invest,add){
		if(add){
        	document.getElementById("request").style.display="block";

            addToFranchiseList(franchiseID,franchiseName,invest);
         }
		else removeFranchiseList(franchiseID);
	}
	function addToFranchiseList(franchiseID, franchiseName,invest){
		if(franchiseListTotalCount < franchiseListLimit){

		   //build list of parameters
			var querystring_variables = new Array();
			querystring_variables["franchiseID"] = franchiseID;
			querystring_variables["franchiseName"] = franchiseName;
			querystring_variables["minimumInvest"] = invest;
			//make asynchoronous call to get_franchises_json.php
			var bindArgs = {
				url: '/startupnation/includes/siteStructure/addFranchiseToCart.php',
				type: 'text/javascript',
				content: querystring_variables,
				handler: displayFranchiseListResults
			};
			dojo.io.bind(bindArgs);

			if(document.getElementById("check"+franchiseID)) document.getElementById("check"+franchiseID).checked = true;
		} else {
			alert("You have reached the maximum of "+franchiseListLimit+" selections. To add more franchises, please uncheck selections in your request list.");
			if(document.getElementById("check"+franchiseID)) document.getElementById("check"+franchiseID).checked = false;
		}

	}

	function removeFranchiseList(franchiseID){
	   //build list of parameters
		var querystring_variables = new Array();
		querystring_variables["deleteFranchise"] = franchiseID;

		//make asynchoronous call to get_franchises_json.php
		var bindArgs = {
			url: '/startupnation/includes/siteStructure/addFranchiseToCart.php',
			type: 'text/javascript',
			content: querystring_variables,
			handler: displayFranchiseListResults
		};
		dojo.io.bind(bindArgs);
		if(document.getElementById("check"+franchiseID)) document.getElementById("check"+franchiseID).checked = false;
	}
	function franchiseList(){ 

    	requestListButton = document.getElementById("requestListButton");
    	if(requestListButton.src.toString().indexOf("Expand")!=-1){
        	expandFranchiseList();
            requestListButton.src = "/images/requestListContract.png";
        }
        else{
        	contractFranchiseList();
            requestListButton.src = "/images/requestListExpand.png";
        
        }
    }
	function expandFranchiseList(){
     	  var oFranchiseList = document.getElementById("request");
          
          if(!isIE6){
              oFranchiseList.style.position = "fixed";
	          oFranchiseList.style.height = "auto";
          }
          else 
	          document.body.onscroll = movepanel;
         // oFranchiseList.style.right = "0px";
         // oFranchiseList.style.top = "70px";
    }
    function contractFranchiseList(){
		var oFranchiseList = document.getElementById("request");
        oFranchiseList.style.position = "absolute";
        oFranchiseList.style.height = "35px";
    }
function displayForm(){
 	document.getElementById("overlay").style.display = "block";
    var querystring_variables = new Array();
//    querystring_variables["returnFranchise"] = true;

	var bindArgs = {
        url: '/startupnation/includes/siteStructure/addFranchiseToCart.php',
        type: 'text/javascript',
        content: querystring_variables,
        handler: displayFranchiseListForm
    };
    dojo.io.bind(bindArgs);

}
function displayFranchiseListForm(type,data,evt){

    var docWidth = document.body.offsetWidth;
    var offsetLeft = (docWidth - 1024) / 2;
    document.getElementById("formContainer").style.display="block";
    document.getElementById("formContainer").style.left = offsetLeft+"px";
   var list = document.getElementById("formRequestList"); 
   	franchiseListResults = data.parseJSON();
    someHTML = "<table class=\"requestTable\"><tr>";
    for (var i=0; i < franchiseListResults.count; i++) {
        var franchiseID = franchiseListResults.franchises[i].id;
       // alert(franchiseID);
        var franchiseName = franchiseListResults.franchises[i].name.replace(/\'/g, "&#39;"); 
        //'

        var minInvest = franchiseListResults.franchises[i].invest;
        if(i % 3 == 0 && i != 0) someHTML += "</tr><tr>";
       someHTML += "<td class=\"formRequest\"><input type=\"checkbox\" name=\"key[] \"value=\"" + franchiseID +  "\" onclick=removeFranchiseList(" + franchiseID +") checked=\"checked\">" + franchiseName + "<br />Min. Investment: $"+minInvest+"<br /></td>"; 
    }
    someHTML += "</tr></table>";
    dojo.byId("formRequestList").innerHTML = someHTML;

}

function displayFranchiseListResults(type, data, evt) {
		franchiseListResults = data.parseJSON();
      	oFranchiseList = document.getElementById("requestContent");
		oFranchiseList.innerHTML = "";

		franchiseListTotalCount = franchiseListResults.count;

		if(franchiseListResults.count > 0){
			oFranchiseList.innerHTML += "<div class=\"title\">Franchise Request List</div><div class=\"list\">You have " + franchiseListResults.count + " items in your request list</div>";
			for (var i=0; i < franchiseListResults.count; i++) {
				var franchiseID = franchiseListResults.franchises[i].id;
				var franchiseName = franchiseListResults.franchises[i].name.replace(/\'/g, "&#39;"); 
				var minInvest = franchiseListResults.franchises[i].invest;
                dojo.byId('requestContent').innerHTML += "<div class=\"requestlist input\"><input type=\"checkbox\" name=\"keys[] \"value=\"" + franchiseID +  "\" onclick=removeFranchiseList(" + franchiseID +") checked=\"checked\">";
               dojo.byId('requestContent').innerHTML += "</div><div class=\"requestlist name\">" + franchiseName +"</div><div class=\"invest\">Min. Investment: $"+minInvest+"</div>";
			}
			dojo.byId('requestContent').innerHTML += "<input type=\"image\" class=\"requestListButton\" src=\"/startupnation/images/requestListButton.png\" value=\"Request Information Now\" id=\"submit\"/>";
		} else {
			dojo.byId('requestContent').innerHTML = "<div class=\"requestheader\"><strong>Your franchise list is empty.</strong></div>";
		}
	}
var isIE6 = (navigator.appVersion.indexOf("MSIE")!=-1 && parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE")+5))<7);
var isIE = (navigator.appVersion.indexOf("MSIE")!=-1);

function movepanel(){
	if(isIE6)
		reformatPanel();
	var franchiseListObj = document.getElementById("request");
	var docWidth = document.body.offsetWidth;
	var offsetLeft = ((docWidth - 1024) / 2) +240;	
	var scrollArray = getScrollXY();
	var scrollerOffset = 95;
	var startScroll = 230 ;//topOfRequestList - scrollerOffset;
	if(scrollArray[1] < startScroll){
		if(!isIE)
			franchiseListObj.style.position = "absolute";
		franchiseListObj.style.top = startScroll + scrollerOffset + "px";
		previousSpot = scrollerOffset;
	} else {
		if(isIE)
			franchiseListObj.style.top = (scrollArray[1] + ( scrollerOffset)) + "px";
		else{
			franchiseListObj.style.position = "fixed";
			franchiseListObj.style.top = scrollerOffset +"px";
		}
		previousSpot = scrollArray[1];
	}
}
function reformatPanel(){
	if(document.getElementById("request").className.indexOf("IE6") == -1){
		
		document.getElementById("requestHeader").className = "requestHeader IE6head";
		document.getElementById("requestContent").className = "IE6l";
		document.getElementById("requestContent").style.paddingLeft = "5px";
		document.getElementById("requestFooter").className = "requestFooter IE6foot";
		document.getElementById("request").className = "request IE6r";
	}
}
	function jumpToSubCategory(){
		var oSubCategorySelection = document.getElementById("subCategoryDropdown");
		if(oSubCategorySelection.options[oSubCategorySelection.selectedIndex].value != ""){
			window.location.href = "/category.php?html_id=" + oSubCategorySelection.options[oSubCategorySelection.selectedIndex].value;
		}

	}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}    
function getScrollXY() {
	var scrOfX = 0, scrOfY = 0;
	
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	
	var scrollArray = [scrOfX, scrOfY];
	
	return scrollArray;
}
function closeRequestForm(){
	document.getElementById("overlay").style.display = "none";
    document.getElementById("formContainer").style.display="none";
}
function wSWFt(swfObject) {
	document.write("<object type=\"application/x-shockwave-flash\"" + swfObject + "</object>");
}
function popWin(url,wid,hit){
	var extras = "width="+wid+",height="+hit+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no";
	var nwin = window.open(url,"fgpop",extras);
}


// JavaScript Document