// added JS redirects with out having to add directories, cgerikh
var formatted_url;
var redirect = location.href.toLowerCase();
var split = redirect.split("?", 1);
redirect = split[0];
var trailing_slash = redirect.charAt(redirect.length - 1);


var http_path = "http://www.onecommunications.com/";
if(redirect.indexOf('http://www.onecommunications.com/') == 0) {
	http_path = "http://www.onecommunications.com/";
}
if(redirect.indexOf('http://newstaging.onecommunications.com/') == 0) {
	http_path = "http://newstaging.onecommunications.com/";
}
if(redirect.indexOf('http://localhost/') == 0) {
	http_path = "http://localhost/";
}

if(trailing_slash == "/") {
	formatted_url = redirect;
} else {
	formatted_url = redirect+"/";
}

switch(formatted_url) {

	case http_path+"onesolutionsconferencing/":
	case http_path+"conferencing/":
		location.href=http_path+"conferencing.aspx";
		break;

	case http_path+"mnsuserguide/":
		location.href=http_path+"uploadedFiles/Knowledgebase/Documents/User_Guides/Managed_Services_Web_Portal_User_Guide.pdf";
		break;

	case http_path+"uc500userguide/":
		location.href=http_path+"knowledgecenter.aspx?id=4476";
		break;

	case http_path+"claimform/":
		location.href=http_path+"claimform.aspx";
		break;

	case http_path+"guarantee/":
		location.href=http_path+"service.aspx?id=1095";
		break;

	case http_path+"mobile/":
		location.href=http_path+"support/onesolutionsmobile-support.aspx";
		break;

	case http_path+"mobileaccount/":
		location.href="http://209.117.79.47:8011/enduser/Login/tabid/597/Default.aspx";
		break;

	case http_path+"callforwarding/":
		location.href="http://vovici.com/wsb.dll/s/136a0g2a22a";
		break;

	case http_path+"repairsurvey/":
		location.href="http://vovici.com/wsb.dll/s/136a0g303a2";
		break;

	case http_path+"2008agentmastersclub/":
		location.href=http_path+"masters-club/2008-agent-masters-club.aspx";
		break;

	case http_path+"confguide/":
		location.href=http_path+"support/confguide.aspx";
		break;

	case http_path+"userguide/":
		location.href=http_path+"uploadedFiles/Knowledgebase/Documents/User_Guides/onesols_userguide.pdf";
		break;

	
	case http_path+"c1userguide/":
		location.href=http_path+"uploadedFiles/OneComm_Root/Service_and_Support/Choice_One/How-To_Quick_Links/User_Guides/ug_local.pdf";
		break;


	case http_path+"rcnvuserguide/":
		location.href=http_path+"uploadedFiles/Knowledgebase/Documents/User_Guides/Conversent/Product_Support/businesslinefeatures.pdf";
		break;

	case http_path+"cnvuserguide/":
		location.href=http_path+"uploadedFiles/Knowledgebase/Documents/User_Guides/Conversent/Product_Support/businesslinefeatures-nonri.pdf";
		break;

	case http_path+"aita/":
		location.href=http_path+"aita/aita-discount-information.aspx";
		break;

	case http_path+"status/":
		location.href=http_path+"status/network-upgrade-status.aspx";
		break;

	case http_path+"signup/":
		location.href="https://oneconnect.onecommunications.com/register.aspx?WT.mc_id=OCOS002";
		break;

	case http_path+"connect/":

		var id = gup('WT.mc_id');
		var ev = gup('WT.mc_ev');
		
		if (id == "")
			id = "OCOS008";

		var address = "register.aspx?WT.mc_id=" + id;
		if (ev != "")
			address += "&WT.mv_ev=" + ev;

		location.href="https://oneconnect.onecommunications.com/" + address;
		break;

	case http_path+"online/":
		location.href="https://oneconnect.onecommunications.com/";
		break;

	case http_path+"flexfreemonthrebate/":
		location.href=http_path+"flexiblefree/default.aspx";
		break;

	case http_path+"support/":
		location.href=http_path+"contact/clec-one.aspx";
		break;

	case http_path+"register/":
		location.href="https://oneconnect.onecommunications.com/register.aspx?WT.mc_id=OCOS001";
		break;

	case http_path+"activate/":
	case http_path+"paybill/":
		location.href="https://oneconnect.onecommunications.com/";
		break;

	case http_path+"csatsweepstakes/":
		location.href=http_path+"csatsweepstakes/default.aspx";
		break;

	case http_path+"feedback/care/":
		location.href="http://vovici.com/wsb.dll/s/136a0g42185";
		break;

	case http_path+"passwords/":
		location.href=http_path+"knowledgecenter.aspx?id=4172";
		break;

	case http_path + "firsthand/":
		location.href = http_path + "testimonial-form.aspx";
		break

	case http_path + "hostedoverview/":
		location.href = http_path + "uploadedFiles/Knowledgebase/Documents/User_Guides/OneSols_Hosted_IP_PBX_Overview.pdf";
		break
		
	case http_path + "speedtest/":
		location.href = "http://speedtest.onecommunications.com/";
		break

	case http_path + "emailhelp/":
		location.href = "http://www.onecommunications.com/knowledgecenter.aspx?id=4008";
		break

	case http_path+"email-filtering/":
		location.href=http_path+"uploadedFiles/Knowledgebase/Documents/User_Guides/eServices/OneComMailFilterAdmin.pdf";
		break;


	default:
	// do nothing
}

/* misc scripts carried over from old site */
function QuickLink(elTargetURL) {
	var strTargetURL = elTargetURL[elTargetURL.selectedIndex].value;
	window.location.href = strTargetURL;
}

// added so that select option spawns new window, cgerikh
function QuickLinkWindow(elTargetURL) {
	var strTargetURL = elTargetURL[elTargetURL.selectedIndex].value;
	//window.location.href = strTargetURL;
	window.open(strTargetURL, "Support");
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}