var page=document.location.href;
var errorMessages = new Array();

if (page.indexOf("g1") != -1)
{
	var bsp = "g1";
	var bid = "oblfghome1";
	var sid = "optbiz_lf";
}
else if (page.indexOf("g2") != -1)
{
	var bsp = "g2";
	var bid = "oblfghome2";
	var sid = "optbiz_lf";
} 

else if (page.indexOf("g3") != -1)
{
	var bsp = "g3";
	var bid = "oblfghome3";
	var sid = "optbiz_lf";
} 
else if (page.indexOf("g4") != -1)
{
	var bsp = "g4";
	var bid = "lfbizgoo";
	var sid = "opt_lfbiz";

}

else if (page.indexOf("g5") != -1)
{
	var bsp = "g5";
	var bid = "lfbizgov";
	var sid = "opt_lfbiz";

}

else if (page.indexOf("g6") != -1)
{
	var bsp = "g6";
	var bid = "lfbizgio";
	var sid = "opt_lfbiz";

}

else if (page.indexOf("g7") != -1)
{
	var bsp = "g7";
	var bid = "lfbizgsip";
	var sid = "opt_lfbiz";

}
else {
	var bsp = "";
	var bid = "";
	var sid = "";
}

//To include dynamic business phone numbers in js-generated scrollboxes
/*if (page.indexOf("bsp") != -1) {
	var querystring = window.location.search.substring(1);
	if (querystring.indexOf("&") != -1) {
		var qsArgs = querystring.split('&');
		var qsPairs = qsArgs.split('=');
	} else {
		var qsPairs = querystring.split('=');
	}

	for (i=0;i<qsPairs.length;i++ )
	{
		if (qsPairs[i] === "bsp")
		{
			var bsp = qsPairs[i + 1];
		}
	}
}*/

//Omniture link tracking function


function linkCode(obj,rsuite,name,event,prop,eVar) {
	
	if (event === "" || event === null || event === undefined)
	{
		event = "None";
	}

	switch(rsuite) {
		case "cablebusiness": var rsid = "cablebusiness";break;
	}

	var s=s_gi(rsid);
	switch (prop) {
		case "1": s.prop1 = name;break;
		case "2": s.prop2 = name;break;
		case "11": s.prop11 = name;break;
	}
	switch (eVar)
	{
	case "8": s.eVar8 = name;break;	
	}
	s.events = event;
	s.tl(obj,'o',name);
}

/*var q = new qString();
if (querystring.indexOf("bsp") != -1) var bsp = q.get("bsp");*/

switch(bsp) {
	case "y": var pn="1-888-493-8460";break;
	case "g": var pn="1-888-827-2507";break;
	case "co": var pn="1-888-868-6376";break;
	case "ch": var pn="1-888-899-1768";break;
	case "e": var pn="1-866-200-7163";break;
	case "i": var pn="1-800-784-3087";break;
	case "b": var pn="1-800-784-5162";break;
	case "gc": var pn="1-866-218-1697";break;
	default: var pn="1-800-613-9857";break;
}
	

//OOL for business bottom box info
breakTag = document.createElement('br');

	var mainbusLink = new Array("https://www.optimumbusinesspanel.com/R.aspx?a=39","/pricing/dp.jsp?sbtrack=home_dp","http://www.optimum.com/pdf/user_guides/business_reference_guide.pdf","/online/boost/index.jsp?sbtrack=home_boost","http://www.optimumstore.com?sbtrack=from_biz_home","/voice/features/index.jsp?sbtrack=home_ov");
	var mainbusTitle = new Array("Your Opinion Counts","Special Offer","Reference Guide","Optimum Online Boost","Business Customers","Optimum Voice");
	var mainbusText = new Array ("Business customers: Join our research panel.","Combine Optimum Online and Optimum Voice and save.","View our Optimum Business Reference Guide (PDF).","Host your own Web site, plus increased e-mail storage.","Check out great deals for your business at OptimumStore.com.","14 popular calling features such as voicemail, caller ID and more.");

	var oolTitle = new Array("Your Opinion Counts","Optimum Packages","Optimum Security","Special Offers","Testimonials","Compare Optimum","Optimum Online Boost","24/7 Customer Service");
	var oolLink = new Array("https://www.optimumbusinesspanel.com/R.aspx?a=39","/pricing/index.jsp?sbtrack=ool_pricing","/online/features/index.jsp?sbtrack=ool_features","/pricing/dp.jsp?sbtrack=ool_dp","/testimonials.jsp?sbtrack=ool_testimonials","/online/features/compare.jsp?sbtrack=ool_compare","/online/boost/index.jsp?sbtrack=ool_boost","/support/index.jsp?sbtrack=ool_support");
	var oolText = new Array("Business customers: Join our research panel.","We offer a suite of packages depending on your business size.","We offer a range of features to protect your files and computer.","Combine Optimum Online and Optimum Voice and save!","Read what our business customers are saying.","Compare and take control of your communication.","Optimum Online Boost has more speed and features.","Our experienced local support team is just a phone call away.");

	var ovTitle = new Array("Your Opinion Counts","Save 50% or More","International Calling","Customer Support","14 Calling Features");
	var ovLink = new Array("https://www.optimumbusinesspanel.com/R.aspx?a=39","/pricing/dp.jsp?sbtrack=ov_dp","/voice/international/index.jsp?sbtrack=ov_international","/support/index.jsp?sbtrack=ov_support","/voice/features/index.jsp?sbtrack=ov_features");
	var ovText = new Array("Business customers: Join our research panel.","Get Optimum Voice and Data for your business today and save!","Get Optimum Voice International Calling for business customers.","Our experienced local support team is just a phone call away.","14 premium business calling features included at no extra cost.");

	var ioTitle = new Array("Your Opinion Counts","Testimonials","iO en Espa\u00f1ol","Get iO TV for Business","iO Sports Packages");
	var ioLink = new Array("https://www.optimumbusinesspanel.com/R.aspx?a=39","/testimonials.jsp?sbtrack=io_testimonials","/io/international/espanol.jsp?sbtrack=io_espanol","/contactus.jsp?sbtrack=io_contact_us","/io/sports/index.jsp?sbtrack=io_sports");
	var ioText = new Array("Business customers: Join our research panel.","Read what our business customers are saying.","Over 35 channels of news, sports and entertainment in Spanish.","$39.90/mo for first 12 mos.! Call\n" + pn + " today.","Sports packages let your patrons view out-of-market games.");

	var start;
				
	function scrollBoxes(site) {		

		for (i=0;i<3;i++) {
		
			switch (site) {
				case "ool": var title = oolTitle[i]; var link = oolLink[i]; var text = oolText[i];break;
				case "io": var title = ioTitle[i]; var link = ioLink[i]; var text = ioText[i];break;
				case "ov": var title= ovTitle[i]; var link = ovLink[i]; var text = ovText[i];break;
				case "mainbus": var title = mainbusTitle[i]; var link = mainbusLink[i]; var text = mainbusText[i];break;
			}

			//Create container box
			var box = document.createElement("div");
			box.className = "promoBox";
			if (i === 2) box.style.marginRight = "0";
			
			//Create content divs for all three boxes
			var boxTopContent = document.createElement("div");
			boxTopContent.className = "c";
			var boxMiddleContent = document.createElement("div");
			boxMiddleContent.className = "c";
			var boxBottomContent = document.createElement("div");
			boxBottomContent.className = "c";

			//Create top of scroll box
			var boxTop = document.createElement("div");
			(i === 2) ? boxTop.className = "hdGreen" : boxTop.className = "hdBlue";
			boxTop.appendChild(boxTopContent);
			
			//Create content div
			var boxMiddle = document.createElement("div");
			(i === 2) ? boxMiddle.className = "bdGreen" : boxMiddle.className = "bdBlue";
			var boxLink = document.createElement("a");
			boxLink.appendChild(document.createTextNode(title));
			boxLink.href = link;
			if (title === "Your Opinion Counts") boxLink.setAttribute('onclick','fullWin(this.href);return false');
			var content = document.createElement("p");
			content.appendChild(document.createTextNode(text));
			boxMiddleContent.appendChild(boxLink);
			boxMiddleContent.appendChild(content);
			boxMiddle.appendChild(boxMiddleContent);
			
			//Create bottom of scroll box
			var boxBottom = document.createElement("div");
			(i === 2) ? boxBottom.className = "ftGreen" : boxBottom.className = "ftBlue";
			boxBottom.appendChild(boxBottomContent);
			
			//Append top, middle and bottom to container
			
			box.appendChild(boxTop);
			box.appendChild(boxMiddle);
			box.appendChild(boxBottom);

			document.getElementById(site + "Scroll").appendChild(box);
		}
	}

	function scrollIt(site,direction) {
		switch (site) {
			case "ool": var x = oolTitle; var y = oolLink; var z = oolText; break;
			case "ov": var x = ovTitle; var y = ovLink; var z = ovText; break;
			case "io": var x = ioTitle; var y = ioLink; var z = ioText; break;
			case "mainbus": var x = mainbusTitle; var y = mainbusLink; var z = mainbusText; break;
		}
		if (direction === "next") {
			var firstElTitle = x.shift();
			x.push(firstElTitle);
			var firstElLink = y.shift();
			y.push(firstElLink);
			var firstElText = z.shift();
			z.push(firstElText);
		} else {
			var lastElTitle = x.pop();
			x.unshift(lastElTitle);
			var lastElLink = y.pop();
			y.unshift(lastElLink);
			var lastElText = z.pop();
			z.unshift(lastElText);
		}
		document.getElementById(site + "Scroll").innerHTML = "";
		scrollBoxes(site);
	}

function fullWin(url) {
	if (url == "fedex")
	{
	window.open("http://www.optimumbusiness.com/obb/fedex.jsp","new_window","width=790,height=450,scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,location=yes,status=yes");
	return false;
	} else {
	window.open(url,"new_window","width=790,height=450,scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,location=yes,status=yes");
	return false;
	}
}


function openWin(url,name,width,height,scrollbars,resizable,menubar,toolbar) {
	
	if (!resizable)	resizable = "no";
	if (!menubar) menubar = "no";
	if (!toolbar) toolbar = "no";
	winFeatures = "width=" + width + ",height=" + height + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",menubar=" + menubar + ",toolbar=" + toolbar + ",top=100,left=100,screenX=100,screenY=100";
	window.open(url,name,winFeatures);
}

function autoTab(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode;
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if (input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+2) % input.form.length].focus();
	}
	function containsElement(arr, ele) {
		var found = false, index = 0;
		while(!found && index < arr.length) if(arr[index] == ele) found = true;
		else index++;
		return found;
	}
	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1) if (input.form[i] == input) index = i;
		else i++;
		return index;
	}
	return true;
}
var isNN = (navigator.appName.indexOf("Netscape") != -1);
function checkAll(field) {
	for (i = 0; i < field.length; i++) field[i].checked = true;
}
function uncheckAll(field) {
	for (i = 0; i < field.length; i++) field[i].checked = false;
}


var submitted = false;
function doSubmit(form) {
	//alert("check");
	if (!submitted) {
		submitted = true;
		//alert("submitting");
		return (true) ;
	}
	else {
		//alert("no");
		return (false) ;
	}
}

function tabomatic(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus()
}

function shadeRow (x,color) {
	document.getElementById(x).style.backgroundColor = color;
}

var temp
function openIt(name) {
	var win = window.open('/order/install_calendar.jsp','calendar1','scrollbars=no,width=450,height=200,top=0,left=10');
	temp = name;
}

function ChangeImage(sSrc) {
	document.fmProduct.ProductImage.src = sSrc;
}

function changeLanguage(language) {
	if (language == 'english') {
		document.getElementById('english').style.display = 'block';
		document.getElementById('espanol').style.display = 'none';
	} 
	
	else if (language == 'englishUG')
	{
		document.getElementById('englishUG').style.display = 'block';
		document.getElementById('espanolUG').style.display = 'none';
	}

	else if (language == 'espanolUG')
	{
		document.getElementById('espanolUG').style.display = 'block';
		document.getElementById('englishUG').style.display = 'none';
	} 
	
	else 
	{
		document.getElementById('espanol').style.display = 'block';
		document.getElementById('english').style.display = 'none';
	}
}

function showHide(divToChange) {
	var x = document.getElementById(divToChange);
	if (x.style.display === "block")
	{
		x.style.display = "none";
	} else {
		x.style.display = "block";
	}
}

//Flash Active X fix

function VM_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
    }

function VM_EmbedFlash(){
  var ret = 
    VM_GetArgs
    (  arguments, "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  VM_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function VM_GetArgs(args, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
       ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
   }
}
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

//TransMotion espanol links
var MP = {
	<!-- mp_trans_disable_start -->     
	Version: '1.0.15',    
	Domains: {'es':'espanol.optimumbusiness.com'},				
	SrcLang: 'en',
	<!-- mp_trans_disable_end -->	
	UrlLang: 'mp_js_current_lang',	
	SrcUrl: unescape('mp_js_orgin_url'),
	<!-- mp_trans_disable_start --> 		
	init: function() {	   
		if (MP.SrcUrl.indexOf('p_js_')==1) {	       
			MP.SrcUrl = location.href;           
			MP.UrlLang = MP.SrcLang;	   
		}	
	},    
	switchLanguage: function(lang) {		
		if (lang!=MP.SrcLang) {            
			var script = document.createElement('SCRIPT');            
			script.src = location.protocol+'//'+MP.Domains[lang]+'/en'+lang+'/?1023749632;'+escape(MP.SrcUrl);            
			document.body.appendChild(script);        
					
		} else if (lang==MP.SrcLang) {		    
			MP.switchToLang(MP.SrcUrl);				
		}		
		return false;    
	},	
	switchToLang: function(url) {        
		var mplink=document.createElement('A');		
		if (mplink.click) { // using location.href will cause IE6 to not report referrer		    
			mplink.href=url;            
			document.body.appendChild(mplink);            
			mplink.click();
		} else {		    
			location.href=url; 		
		}	
	}
<!-- mp_trans_disable_end -->	
};

function createIt(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readIt(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseIt(name) {
	createCookie(name,"",-1);
}

var sidValue = '<dsp:valueof param="sid"/>';
if (sidValue === "optbizes_lf") {
	createIt("sid","optbizes_lf",0);
	var itExists = readIt("sid");
}

