//rackspace.js

var $ 								= jQuery;

var BLANK							= "";
var BLOCK							= "block";
var EMPTY_STRING					= "";
var NONE							= "none";
var SPACE							= " ";
var STAR							= "*";
var STRING							= "string";

var SITEMAP_HIGHLIGH_CLASS_NAME 	= "sitemap-highlighted";

var DOCUMENTGROUP					= "Contact US";
var DOCUMENTNAME					= "Contact Sales Form";
var ACTION							= "5";

var FORM_STATE_SELECT_WRAP_ID		= "form-state-select-wrap";
var STATE_SELECT_CLASS_NAME			= "state-select";

var EXIT_STATEMENT					= "You are now leaving the Rackspace Hosting website. Any links on our website have been provided strictly for the convenience of our users. The linked sites are not under our control and we are not responsible for the content of any linked site or any link contained in a linked site. We do not endorse companies, products or any information contained on the sites to which we link. If you decide to access any of the third party sites linked to our website, you do this entirely at your own risk.";
	
function optionHighlight(div,classname) {
	
	var cell = document.getElementById(div);
	toggleClass(cell,classname);
}

function optionDefault(div,classname) {
	
	var cell = document.getElementById(div);
	toggleClass(cell,classname);
}

function isClass(target,className) {

	if (!target.className) {
		return false;
	}
	
	if (isType(className,STRING)) {
	
		return target.className.indexOf(className) > -1;
		
	} else if (isType(className,OBJECT)) {
	
		for (var i = 0; i < className.length; i++) {
		
			if (target.className.indexOf(className[i]) > -1) {
			
				return true;
			}
		}
	}
	
	return false;
}

function addClass(target,k) {

	var cn = target.className;
	
	if (cn && cn.indexOf(k) > -1) {
	
		return;
	}
	
	if (cn && cn.length > 0) {
	
		k = SPACE + k;
		cn += k;	
		
	} else {
	
		cn = k;
	}
	
	target.className = cn;
}

function removeClass(target,k) {

	var cn = target.className;
	
	if (!cn) {
	
		return;
	}
	
	cn = trim(cn);
	
	var index;
	
	if ((index = cn.indexOf(k)) > -1) {
	
		cn = cn.substring(0,index)+cn.substring(index+k.length);
		
	}
	
	target.className = cn;
}

function toggleClass(target,k) {

	if (isClass(target,k)) {
	
		removeClass(target,k);
		
	} else {
	
		addClass(target,k);
	}	
}

function getURL(URL) {
	
	location.href = URL;
}

function getURLNewWindow(URL) {
	
	window.open (URL);
}

function cleanSlate(id) {

	var slate;
	slate = document.getElementById(id);
	slate.value = "";
	slate.style.color = "#292929";
}

function popUpDataCenter(URL) {

	var left 		= (screen.width / 2) - 240;
	var top 		= (screen.height / 2) - 380;
	var attributes  = "toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=0,width=760,height=480,left="+left+",top="+top+";w.focus();";
	
	window.open (URL,'name',"'" + attributes + "'");
}

function popUpManagedExchangeDemo(URL) {

	var left 		= (screen.width / 2) - 390;
	var top 		= (screen.height / 2) - 215;
	var attributes  = "toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=0,width=780,height=431,left="+left+",top="+top+";w.focus();";
	
	window.open (URL,'name',"'" + attributes + "'");
}

function popUpPartnerPortalDemo(URL) {

	var left 		= (screen.width / 2) - 240;
	var top 		= (screen.height / 2) - 380;
	var attributes  = "toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=0,width=760,height=480,left="+left+",top="+top+";w.focus();";
	
	window.open (URL,'name',"'" + attributes + "'");
}

function popUpLoophole(URL) {

	var left 		= (screen.width / 2) - 251;
	var top 		= (screen.height / 2) - 281;
	var attributes  = "toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=0,width=502,height=562,left="+left+",top="+top+";w.focus();";
	
	window.open (URL,'name',"'" + attributes + "'");
}

function popUpRackspaceOnTheRoad(URL) {

	var left 		= (screen.width / 2) - 270;
	var top 		= (screen.height / 2) - 400;
	var attributes  = "toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=539,left="+left+",top="+top+";w.focus();";
	
	window.open (URL,'name',"'" + attributes + "'");
}

function popUpSupportVideos(URL) {

	var left 		= (screen.width / 2) - 400;
	var top 		= (screen.height / 2) - 280;
	var attributes  = "toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=560,left="+left+",top="+top+";w.focus();";
	
	window.open (URL,'name',"'" + attributes + "'");
}

function popUpInstalledSoftware(URL) {

	var left 		= (screen.width / 2) - 280;
	var top 		= (screen.height / 2) - 150;
	var attributes  = "toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=0,width=560,height=300,left="+left+",top="+top+";w.focus();";
	
	window.open (URL,'name',"'" + attributes + "'");
}

function popUpGraphic(URL,width,height) {

	var left 		= (screen.width / 2) - (width / 2);
	var top 		= (screen.height / 2) - (height / 2);
	var attributes  = "toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left="+left+",top="+top+";w.focus();";
	
	window.open (URL,'name',"'" + attributes + "'");
}

function popUpRackGivesBackPhotos(URL) {

	var left 		= (screen.width / 2) - 400;
	var top 		= (screen.height / 2) - 235;
	var attributes  = "toolbar=0,scrollbars=no,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=470,left="+left+",top="+top+";w.focus();";
	
	window.open (URL,'name',"'" + attributes + "'");
}

function popUpWindow(URL,width,height) {

	var width		= width;
	var height		= height;
	var left 		= (screen.width / 2) - (width / 2);
	var top 		= (screen.height / 2) - (height / 2);
	var attributes  = "toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left="+left+",top="+top+";w.focus();";
	
	window.open (URL,'name',"'" + attributes + "'");
}

function selectInterest(interest) {

	var url = document.getElementById(interest).value;
	
	getURL(url);
}

function toggleCalculator(target,image) {

	var target 	= document.getElementById(target);
	var image	= document.getElementById(image);
	
	if (isShowing(target)) {
	
		hide(target);
		image.src = "/images/elements/arrow-up.gif";
		
	} else {
	
		show(target);
		image.src = "/images/elements/arrow-down.gif";
	}
}

function toggleByClassName(className) {

	$('.'+className).each(function(){
		$(this).toggle();
	});
}

function toggleDiv(target) {

	var target 	= document.getElementById(target);
	
	if (isShowing(target)) {
	
		hide(target);
		
	} else {
	
		show(target);
	}
}

function showDiv(target) {

	var target = document.getElementById(target);
	
	show(target);
}

function hideDiv(target) {

	var target = document.getElementById(target);
	
	hide(target);
}

function toggleGreen(target,image) {

	var target 	= document.getElementById(target);
	var image	= document.getElementById(image);
	
	if (isShowing(target)) {
	
		hide(target);
		image.src = "/images/information/events/green/learnmore.png";
		
	} else {
	
		show(target);
		image.src = "/images/information/events/green/learnmore-open.png";
	}
}

$(document).ready(function(){
	
	$('.tab-wrap').find('div.tab').click(function(){
	
		var wrapid 	= $(this).parent().parent().attr('id');
		var tabid	= $(this).parent().attr('id');
		var paneid 	= $(this).parent().attr('id').replace(/tab/g,'pane');
		
		$('#'+wrapid).find('div.tab-on').addClass('tab-off').removeClass('tab-on');
		$('#'+tabid).find('div.tab').addClass('tab-on').removeClass('tab-off');
		
		$('#'+wrapid).find('div.pane').hide();
		$('#'+paneid).show();
	});
	
	$('.tabs .tab').click(function(){
		
		if($(this).parent().attr('id').indexOf('tabs') >= 0){
			$tabWrapId  = '#'+$(this).parent().attr('id');
			$paneWrapId = '#'+$(this).parent().attr('id').replace(/tabs/g,'pane');
		} else {
			$tabWrapId  = '';
			$paneWrapId = '';
		}
		
		console.log($tabWrapId);
		 
		var $tabId 		= $(this).attr('id');
		var $paneId		= $tabId.replace(/tab/g,'pane');
	
		$($tabWrapId + '.tabs .tab').each(function(){
			$(this).removeClass('tabActive');
		});
		
		$($paneWrapId + ' .pane').each(function(){
			$(this).removeClass('paneActive');
		});
		
		$(this).addClass('tabActive');
		$('#'+$paneId).addClass('paneActive');
	});
});

function populateStates(node) {

	var countries 	= document.getElementById(node.id);
	var state_wrap	= document.getElementById(countries.value);
	var	root		= document.getElementById(FORM_STATE_SELECT_WRAP_ID);
	
	var divs		= getDescendantsByTagAndClassName(root,DIV,STATE_SELECT_CLASS_NAME);
	
	for (i = 0; i < divs.length; i++) {
	
		hide(divs[i]);
	}
	
	show(state_wrap);
}

function getUrlVars() {
	var vars = {};
	var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
		vars[key] = value;
	});
	return vars;
}

function getStateValue(thisForm,country) {

	if (country == "Argentina") {
	
		state = thisForm.statestateArgentina.value;
	
	} else if (country == "Australia") {
	
		state = thisForm.stateAustralia.value;
	
	} else if (country == "Austria") {
	
		state = thisForm.stateAustria.value;
	
	} else if (country == "Belgium") {
	
		state = thisForm.stateBelgium.value;
	
	} else if (country == "Bolivia") {
	
		state = thisForm.stateBolivia.value;
		
	} else if (country == "Brazil") {
		
		state = thisForm.stateBrazil.value;
	
	} else if (country == "Bulgaria") {
				
		state = thisForm.stateBulgaria.value;				

	} else if (country == "Canada") {
	
		state = thisForm.stateCanada.value;
	
	} else if (country == "Chile") {
	
		state = thisForm.stateChile.value;
	
	} else if (country == "China") {
	
		state = thisForm.stateChina.value;
	
	} else if (country == "Colombia") {
	
		state = thisForm.stateColombia.value;
	
	} else if (country == "Czech Republic") {
	
		state = thisForm.stateCzechRepublic.value;
	
	} else if (country == "Denmark") {
	
		state = thisForm.stateDenmark.value;
	
	} else if (country == "France") {
	
		state = thisForm.stateFrance.value;
	
	} else if (country == "Germany") {

		state = thisForm.stateGermany.value;			
								
	} else if (country == "Greece") {
			
		state = thisForm.stateGreece.value;	
								
	} else if (country == "Hungary") {
				
		state = thisForm.stateHungary.value;
								
	} else if (country == "India") {
				
		state = thisForm.stateIndia.value;
								
	} else if (country == "Ireland") {
				
		state = thisForm.stateIreland.value;
								
	} else if (country == "Israel") {
				
		state = thisForm.stateIsrael.value;		
								
	} else if (country == "Italy") {

		state = thisForm.stateItaly.value;
								
	} else if (country == "Japan") {
				
		state = thisForm.stateJapan.value;		
								
	} else if (country == "Korea, Republic of") {
				
		state = thisForm.stateKorea,Republicof.value;		
								
	} else if (country == "Malaysia") {
				
		state = thisForm.stateMalaysia.value;
								
	} else if (country == "Mexico") {
				
		state = thisForm.stateMexico.value;
								
	} else if (country == "Netherlands") {
				
		state = thisForm.stateNetherlands.value;
								
	} else if (country == "New Zealand") {

		state = thisForm.stateNewZealand.value;
								
	} else if (country == "Norway") {
				
		state = thisForm.stateNorway.value;
								
	} else if (country == "Paraguay") {
				
		state = thisForm.stateParaguay.value;
								
	} else if (country == "Peru") {
				
		state = thisForm.statePeru.value;
								
	} else if (country == "Poland") {
				
		state = thisForm.statePoland.value;
								
	} else if (country == "Portugal") {
				
		state = thisForm.statePortugal.value;
								
	} else if (country == "Romania") {

		state = thisForm.stateRomania.value;
								
	} else if (country == "Slovakia") {
				
		state = thisForm.stateSlovakia.value;
								
	} else if (country == "Spain") {
				
		state = thisForm.stateSpain.value;
								
	} else if (country == "Switzerland") {
				
		state = thisForm.stateSwitzerland.value;			
					
	} else if (country == "Turkey") {
				
		state = thisForm.stateTurkey.value;		
								
	} else if (country == "United Kingdom") {
				
		state = thisForm.stateUnitedKingdom.value;		
								
	} else if (country == "United States") {

		state = thisForm.stateUnitedStates.value;
								
	} else if (country == "Uruguay") {
				
		state = thisForm.stateUruguay.value;		
								
	} else if (country == "Venezuela") {
	
		state = thisForm.stateVenezuela.value;
	}
	
	return state;
}

function loadVideo(evt,url,divid) {

	if (navigator.appName == "Microsoft Internet Explorer") {
	
		var obj = new ActiveXObject("microsoft.XMLHTTP");
		
	} else {
	
		var obj = new XMLHttpRequest();
	}

	obj.open("GET", url, true);
	
	obj.onreadystatechange = function() {
	
		if (obj.readyState == 4) {
		
			var browser_div = document.getElementById(divid);
			var text = obj.responseText;
			
			browser_div.innerHTML = text;
		}
	}
	
	obj.send(null);
}

function loadVideoPlayer(evt,url,divid) {

	if (navigator.appName == "Microsoft Internet Explorer") {
	
		var obj = new ActiveXObject("microsoft.XMLHTTP");
		
	} else {
	
		var obj = new XMLHttpRequest();
	}

	obj.open("GET", url, true);
	
	obj.onreadystatechange = function() {
	
		if (obj.readyState == 4) {

			var browser_div 	= document.getElementById(divid);
			var scrolltop 		= getScrollY() + (getViewportHeight() / 2);
			var text 			= obj.responseText;
			
			setY(browser_div,scrolltop);
			browser_div.innerHTML = text;
		}
	}
	
	obj.send(null);
	
	darkenPage();
	showDiv("video-popup-wrap");
}

function hideVideoPlayer() {

	lightenPage();
	hideDiv("video-popup-wrap");
	$("#video-popup-wrap object").remove();
}

function showFormPopup(divid) {

	var div 		= document.getElementById(divid);
	var scrolltop 	= getScrollY() + (getViewportHeight() / 2);
	
	setY(div,scrolltop);
	show(div);
}

function toggleCheckbox(evt,checkboxid,checker) {

	var toggleImage = document.getElementById(checkboxid);
	var checkbox	= document.getElementById(checker);
	
	if (toggleImage.src.indexOf("off") > -1) {
	
		toggleImage.src = "/images/blog/login/checkbox-on.png";
		check 			= document.getElementById(checkbox.id);
		check.value 	= "forever";
		
	} else {
	
		toggleImage.src = "/images/blog/login/checkbox-off.png";
		check 			= document.getElementById(checkbox.id);
		check.value 	= "";
	}
}

function toggleThumbnails(wrapid,divid,classname) {

	var root 	= document.getElementById(wrapid);
	var showdiv	= document.getElementById(divid);
	
	allDivs 	= getChildrenByTagAndClassName(root,DIV,classname);
	
	for (i = 0; i < allDivs.length; i++) {
		
		hide(allDivs[i]);
	}
	
	show(showdiv);
}

var SURVEY_POSITION = "down";

function loadSurveyInvite(divid) {

	var cookie = readCookie('surveyinvitecookie');
	
	if (!cookie) {

		new Effect.Move(divid,{ x: 0, y: -110 });
	
	} else {
	
		hideDivById(divid);
	}
}

function mouseOverSurvey(divid) {

	if (SURVEY_POSITION == "down") {
	
		SURVEY_POSITION = "moving";
		new Effect.Move(divid,{ x: 0, y: -130 });
		setTimeout('var SURVEY_POSITION = "up"',1100);
	}
	
	return false;
}

function declineSurvey(divid) {

	createCookie('surveyinvitecookie','invitesent',1);

	new Effect.Move(divid,{ x: 0, y: 240 });
	
	return false;
}

function acceptSurvey(divid) {

	createCookie('surveyinvitecookie','invitesent',1);

	new Effect.Move(divid,{ x: 0, y: 240 });
	
	return false;
}

var ANNOUNCEMENT_WRAP_ID			= "block1-announcement-wrap";
var ANNOUNCEMENT_ON_CLASS_NAME 		= "announcement-on-wrap";
var ANNOUNCEMENT_OFF_CLASS_NAME 	= "announcement-off-wrap";

function showAnnouncement() {

	var wrap = document.getElementById(ANNOUNCEMENT_WRAP_ID);

	removeClass(wrap,ANNOUNCEMENT_OFF_CLASS_NAME);
	addClass(wrap,ANNOUNCEMENT_ON_CLASS_NAME);

	Effect.SlideDown(wrap.id,{duration: 1});
}

function hideDivById(divid) {

	var target 				= document.getElementById(divid);
	target.style.display 	= NONE;
}

function initPartnerSearchForm() {

	countryToRegionArr = countryToRegionString.split(";");

	var ddCountry = document.getElementById("pcountry");
	
	if (ddCountry != null) {
	
		displayRegion(ddCountry.value);
	}
	
	categoryToSkillArr = categoryToSkillString.split(";");

	var ddCategory = document.getElementById("pcat");
	
	if (ddCategory != null) {
	
		displaySkill(ddCategory.value);
	}
}

function initNeustarForm() {

	countryToRegionArr = countryToRegionString.split(";");

	var ddCountry 		= document.getElementById("pcountry");
	var ddState			= document.getElementById("pstate");
	
	if (ddCountry.value == "") {
	
		ddCountry.value = "United States";
		displayRegion(ddCountry.value);
	
	} else {
	
		ddCountry.value == "";
		ddState.value	== "";
	}
}

function initCheckoutForm(state) {

	countryToRegionArr = countryToRegionString.split(";");

	var ddCountry = document.getElementById("pcountry");
	
	if (ddCountry != null) {
	
		displayRegion(ddCountry.value,state);
	}
}

function selection_changed(selectbox) {

	var countryName = selectbox.value;
	
	displayRegion(countryName);
}

function selection_category_changed(selectbox) {

	var categoryName = selectbox.value;
	
	displaySkill(categoryName);
}

function displayRegion(countryName,state) {

	var index 	= 1;
	var region 	= new Array();

	var ddState = document.getElementById("pstate");

	if (ddState != null) {
	
		ddState.options.length = 0;
		
		ddState.options[0] = new Option('[select a state]','');

		for (var i = 0; i < countryToRegionArr.length; i++) {
		
			var entry 	= countryToRegionArr[i];
			var data 	= entry.split("~");

			if (countryName == data[0]) {
			
				if (state == data[1]) {

					ddState.options[index] = new Option(data[1],data[1],true,true);
			
				} else {
			
					ddState.options[index] = new Option(data[1],data[1]);
				}
				
				index++;
			}
		}
	}
}

function displaySkill(categoryName) {

	var index 	= 1;
	var skill 	= new Array();

	var ddSkill = document.getElementById("pskills");

	if (ddSkill != null) {
	
		ddSkill.options.length = 0;
		
		ddSkill.options[0] = new Option('[select a skill]','');

		for (var i = 0; i < categoryToSkillArr.length; i++) {
		
			var entry 	= categoryToSkillArr[i];
			var data 	= entry.split("~");

			if (categoryName == data[0]) {
			
				ddSkill.options[index] = new Option(data[1],data[1]);
				index++;
			}
		}
	}
}

var VALIDATION_ALERT_WRAP_ID = "validation-alert-wrap";

function submitForm(form_id) {

	var theForm = document.getElementById(form_id);

	switch (form_id) {

		case 'advisoryservicesform':
			validateAdvisoryServicesForm(form_id);
			break;

		case 'agencyservicespartnerapplication':
		  	
		  	validateAgencyServicesPartnerApplication(form_id);
		  	break;
		  	
		case 'askbobbyform':
		  	
		  	validateAskBobbyForm(form_id);
		  	break;
		  	
		case 'bizsparkapplication':
		  	
		  	validateBizsparkApplication(form_id);
		  	break;
		  	
		case 'cloudbuildersform':
		  	
		  	validateCloudBuildersForm(form_id);
		  	break;
		  	
		case 'cloudenterpriseform':
		  	
		  	validateCloudEnterpriseForm(form_id);
		  	break;
		  	
		case 'contactsalesform':
		  	
		  	validateSalesForm(form_id);
		  	break;
		  	
		case 'cloudcontactsalesform':
		  	
		  	validateCloudSalesForm(form_id);
		  	break;
		  	
		case 'cloudprivateeditionform':
		
			validateCloudPrivateEditionForm(form_id);
			break;
		  	
		case 'cloudUform':
		  	
		  	validateCloudUForm(form_id);
		  	break;	
		  	
		case 'customerbriefingform':
		  	
		  	validateCustomerBriefing(form_id);
		  	break;
		  	
		case 'enterpriseform1':
		
		  	validateEnterpriseForm(form_id);
		  	break;
		  	
		case 'enterpriseform2':
		
		  	validateEnterpriseForm(form_id);
		  	break;
		  	
		case 'enterpriseform3':
		
		  	validateEnterpriseForm(form_id);
		  	break;
		  	
		case 'executivespeakingform':
		
		  	validateExecutiveSpeaking(form_id);
		  	break;
		  	
		case 'industryeventsform':
		  	
		  	validateIndustryEventsForm(form_id);
		  	break;
		
		case 'licensemobilityform':
		  	
		  	validateLicenseMobilityForm(form_id);
		  	break;
		  	
		case 'logorequestform':
		  	
		  	validateLogoRequestForm(form_id);
		  	break;
		  
		case 'magentoform':
		  	
		  	validateMagentoForm(form_id);
		  	break;  
		  	
		case 'mediaservicesform':
		  	
		  	validateMediaServicesForm(form_id);
		  	break;
		  	
		case 'netappstorageform':
		  	
		  	validateNetAppStorageForm(form_id);
		  	break;
		  	
		case 'oracleofferform':
		  	
		  	validateOracleOfferForm(form_id);
		  	break;
		  	
		case 'privatecloudofferform':
		  	
		  	validatePrivateCloudOfferForm(form_id);
		  	break;
		  	
		case 'partnerapplicationform':
		  	
		  	validatePartnerProgramApplicationForm(form_id);
		  	break;
		  	
		case 'hostingknowledgesearch':

			var search1 = document.getElementById('hostingknowledgesearch');
			var search2 = document.getElementById('hostingknowledgesearch-default');
			
			if (search1 && search1.value == "(Search Hosting Knowledge)") {
			
				search1.value = "";
				
			} else if (search2 && search2.value == "(Search Hosting Knowledge)") {
			
				search2.value = "";
			}
			
			var theForm = document.getElementById(form_id);
			theForm.submit();
			
			break;
			
		case 'resellercontactform':
			validateResellerContactForm(form_id);
			break;
			
		case 'sharepointform':
			validateSharePointForm(form_id);
			break;
			
		case 'solutionpartnerform':
			validateSolutionPartnerForm(form_id);
			break;
			
		case 'stbiform':
			validateSTBIForm(form_id);
			break;
			
		case 'thawteofferform':
			validateThawteOfferForm(form_id);
			break;
			
		case 'virtualbridgespartnerform':
		
		  	validateGenericForm(form_id);
		  	break;
		  
		case 'virtualbridgesprospectform':
		
		  	validateGenericForm(form_id);
		  	break;
			
		case 'visualstudioform':
			validateVisualStudioForm(form_id);
			break;

		case 'xenapplicationform':
			validateXenApplicationForm(form_id);
			break;
			
		default:
		
			theForm.submit();
			break;
	}
}

function validateGenericForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmpty(theForm.company);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validateHTML(theForm.Customer_Comments__c);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateBizsparkApplication(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.name);
  	reason 	+= validateEmpty(theForm.title);
  	reason 	+= validateEmpty(theForm.company);
  	reason 	+= validateEmpty(theForm.address1);
  	reason 	+= validateEmpty(theForm.city);
  	reason 	+= validateEmpty(theForm.pstate);
  	reason 	+= validateEmpty(theForm.zip);
  	reason 	+= validateEmpty(theForm.pcountry);
  	reason 	+= validatePhone(theForm.phone1);
  	reason 	+= validateEmail(theForm.emailaddress);
  	reason 	+= validateEmpty(theForm.website);
  	
  	for (i = 0, n = theForm.eligibility1.length; i < n; i++) {
  	
        if (theForm.eligibility1[i].checked) {
        
            var eligibility1 = theForm.eligibility1[i].value;
            break;
        } 
    }
 	
  	for (i = 0, n = theForm.eligibility2.length; i < n; i++) {
  	
        if (theForm.eligibility2[i].checked) {
        
            var eligibility2 = theForm.eligibility2[i].value;
            break;
        } 
    }

  	for (i = 0, n = theForm.eligibility3.length; i < n; i++) {
  	
        if (theForm.eligibility3[i].checked) {
        
            var eligibility3 = theForm.eligibility3[i].value;
            break;
        } 
    }

  	for (i = 0, n = theForm.eligibility4.length; i < n; i++) {
  	
        if (theForm.eligibility4[i].checked) {
        
            var eligibility4 = theForm.eligibility4[i].value;
            break;
        } 
    }
	
  	for (i = 0, n = theForm.eligibility5.length; i < n; i++) {
  	
        if (theForm.eligibility5[i].checked) {
        
            var eligibility5 = theForm.eligibility5[i].value;
            break;
        } 
    }

  	for (i = 0, n = theForm.eligibility6.length; i < n; i++) {
  	
        if (theForm.eligibility6[i].checked) {
        
            var eligibility6 = theForm.eligibility6[i].value;
            break;
        } 
    }
    
    reason 	+= validateRadio(eligibility1);
    reason 	+= validateRadio(eligibility2);
    reason 	+= validateRadio(eligibility3);
    reason 	+= validateRadio(eligibility4);
    reason 	+= validateRadio(eligibility5);
  	reason 	+= validateRadio(eligibility6);
  	reason 	+= validateEmpty(theForm.description);
  	reason 	+= validateEmpty(theForm.captcha);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateSalesForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validateHTML(theForm.description);
  	reason 	+= validateMatch(theForm.captcha,theForm.captcha_answer);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateAskBobbyForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validateHTML(theForm.Customer_Comments__c);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateCloudEnterpriseForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmpty(theForm.company);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validateHTML(theForm.description);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateCloudSalesForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validateHTML(theForm.description);
  	reason 	+= validateMatch(theForm.captcha,theForm.captcha_answer);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateCloudPrivateEditionForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.company);
	reason 	+= validateEmpty(theForm.Legal_Company_Name__c);
	reason 	+= validateEmpty(theForm.URL);
	reason 	+= validateEmpty(theForm.country);
	reason 	+= validateEmpty(theForm.street);
	reason 	+= validateEmpty(theForm.city);
	reason 	+= validateEmpty(theForm.state);
	reason 	+= validateEmpty(theForm.zip);
	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmpty(theForm.title);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validateHTML(theForm.description);
  	reason 	+= validateMatch(theForm.captcha,theForm.captcha_answer);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateCloudUForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validateMatch(theForm.captcha,theForm.captcha_answer);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		if (theForm.jobtitle.value == "Other")
			$('#input-title').val(theForm.jobtitle.value+'-'+theForm.other.value);

		theForm.submit();
  	}
}

function validateCustomerBriefing(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.customername);
	reason 	+= validateEmpty(theForm.companyname);
	reason 	+= validateEmpty(theForm.accountnumber);
	reason 	+= validateEmpty(theForm.accountmanager);
  	reason 	+= validatePhone(theForm.phone1);
  	reason 	+= validateEmail(theForm.emailaddress);
  	reason 	+= validateEmpty(theForm.captcha);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateEnterpriseForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmail(theForm.email);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateExecutiveSpeaking(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.firstname);
	reason 	+= validateEmpty(theForm.lastname);
  	reason 	+= validatePhone(theForm.phonenumber);
  	reason 	+= validateEmail(theForm.emailaddress);
  	reason 	+= validateEmpty(theForm.city);
  	reason 	+= validateEmpty(theForm.event);
  	reason 	+= validateMatch(theForm.captcha,theForm.captcha_answer);
  	
	if ($('select[name=event_speaker]').val() == "Other")
		reason 	+= validateEmpty(theForm.event_speaker_other);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateIndustryEventsForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validateMatch(theForm.captcha,theForm.captcha_answer);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {
  	
		theForm.submit();
  	}
}

function validateLicenseMobilityForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validateEmpty(theForm.company);
  	reason 	+= validateEmpty(theForm.country);
  	reason 	+= validateHTML(theForm.Customer_Comments__c);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateLogoRequestForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.customernumber);
	reason 	+= validateEmpty(theForm.companyname);
  	reason 	+= validateEmpty(theForm.licenseename);
  	reason 	+= validateEmpty(theForm.website);
  	reason 	+= validateEmpty(theForm.firstname);
  	reason 	+= validateEmpty(theForm.lastname);
  	reason 	+= validateEmail(theForm.emailaddress);
  	reason 	+= validatePhone(theForm.phonenumber);
  	reason 	+= validatePhone(theForm.faxnumber);
  	reason 	+= validateEmpty(theForm.captcha);
  	
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateMagentoForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.company);
  	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validateEmail(theForm.email);
  	
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateMediaServicesForm(form_id) {

	var theForm = document.getElementById(form_id);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.firstname);
  	reason 	+= validateEmpty(theForm.lastname);
  	reason 	+= validatePhone(theForm.phonenumber);
  	reason 	+= validateHTML(theForm.comments);
  	reason 	+= validateEmpty(theForm.captcha);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateNetAppStorageForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.company);
  	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validateEmail(theForm.email);
  	
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validatePrivateCloudOfferForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validatePhone(theForm.phone);

  	if (reason != "") {

    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateSolutionPartnerForm(form_id) {

	var theForm = document.getElementById(form_id);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.solution);
	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmpty(theForm.company_name);
  	reason 	+= validateEmpty(theForm.job_title);
  	reason 	+= validatePhone(theForm.phone_number);
  	reason 	+= validateEmail(theForm.email_address);
  	reason 	+= validateHTML(theForm.description);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateResellerContactForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validatePhone(theForm.phone);
	reason 	+= validateEmpty(theForm.email);
  	reason 	+= validateEmpty(theForm.country);
  	reason 	+= validateMatch(theForm.captcha,theForm.captcha_answer);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateSharePointForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validateCheckbox(theForm.Sharepoint_Terms_Agreed__c);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateDedicatedExchangeForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validatePhone(theForm.phone);
      
  	if (reason != "") {
  	
    	return false;
  	}

  	return true;
}

function validateOracleOfferForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validatePhone(theForm.phone);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateThawteOfferForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validatePhone(theForm.phone);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateManagedColocationForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validatePhone(theForm.phone);
      
  	if (reason != "") {
  	
    	return false;
  	}

  	return true;
}

function validatePartnerForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.company);
  	reason 	+= validateEmpty(theForm.firstname);
  	reason 	+= validateEmpty(theForm.lastname);
  	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validateEmail(theForm.email);
      
  	if (reason != "") {
  	
    	return false;
  	}

  	return true;
}

function validateTellMeForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateRadio(theForm.configuration);
	reason 	+= validateEmpty(theForm.company);
	reason 	+= validateEmpty(theForm.title);
  	reason 	+= validateEmpty(theForm.firstname);
  	reason 	+= validateEmpty(theForm.lastname);
  	reason 	+= validatePhone(theForm.phonenumber);
  	reason 	+= validateEmail(theForm.emailaddress);

  	if (reason != "") {
  	
    	return false;
  	}

  	return true;
}

function validateNetAppForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	if (theForm.netapp_type.value == "netapp") {
	
		reason 	+= validateEmpty(theForm.netapp_repname);
		reason 	+= validateEmail(theForm.netapp_emailaddress);
		reason 	+= validatePhone(theForm.netapp_phonenumber);
		reason 	+= validateEmpty(theForm.netapp_referral_company);
		reason 	+= validateEmpty(theForm.netapp_referral_firstname);
		reason 	+= validateEmpty(theForm.netapp_referral_lastname);
		reason 	+= validateEmail(theForm.netapp_referral_emailaddress);
		reason 	+= validatePhone(theForm.netapp_referral_phonenumber);
	
	} else if (theForm.netapp_type.value == "netappreseller") {
	
		reason 	+= validateEmpty(theForm.netappreseller_company);
		reason 	+= validateEmpty(theForm.netappreseller_repname);
		reason 	+= validateEmail(theForm.netappreseller_emailaddress);
		reason 	+= validatePhone(theForm.netappreseller_phonenumber);
		reason 	+= validateEmpty(theForm.netappreseller_salescontact);
		reason 	+= validateEmpty(theForm.netappreseller_referral_company);
		reason 	+= validateEmpty(theForm.netappreseller_referral_firstname);
		reason 	+= validateEmpty(theForm.netappreseller_referral_lastname);
		reason 	+= validateEmail(theForm.netappreseller_referral_emailaddress);
		reason 	+= validatePhone(theForm.netappreseller_referral_phonenumber);
	
	} else {
	
		reason 	+= validateEmpty(theForm.netapp_type);
	}

  	if (reason != "") {
  	
    	return false;
  	}

  	return true;
}

function validateNeustarForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.firstname);
	reason 	+= validateEmpty(theForm.lastname);
  	reason 	+= validateEmpty(theForm.company);
  	reason 	+= validateEmpty(theForm.jobtitle);
  	reason 	+= validateEmail(theForm.emailaddress);
  	reason 	+= validatePhone(theForm.phonenumber);
  	reason 	+= validateEmpty(theForm.pcountry);
  	reason 	+= validateEmpty(theForm.pstate);
  	
  	if (reason != "") {
  	
    	return false;
  	}

  	return true;
}

function validateSTBIForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validatePhone(theForm.phone_number);
  	reason 	+= validateEmail(theForm.email_address);
  	reason 	+= validateEmpty(theForm.zip_code);
  	reason 	+= validateEmpty(theForm.business_name);
  	reason 	+= validateEmpty(theForm.team_members);
  	reason 	+= validateEmpty(theForm.website_url);
  	reason 	+= validateHTML(theForm.description);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateXenApplicationForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";
	
	reason 	+= validateEmpty(theForm.Partner_Contact_Name__c);
	reason 	+= validateEmail(theForm.Partner_Contact_Email__c);
	reason 	+= validatePhone(theForm.Partner_Contact_Phone__c);
	reason 	+= validateEmpty(theForm.company);
	reason 	+= validateEmpty(theForm.first_name);
	reason 	+= validateEmpty(theForm.last_name);
	reason 	+= validateEmail(theForm.email);
	reason 	+= validatePhone(theForm.phone);
	reason  += validateHTML(theForm.Customer_Comments__c);
	
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateCheckout(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";
	
	reason 	+= validateEmpty(theForm.payment_company);
	reason 	+= validateEmpty(theForm.payment_name);
	reason 	+= validateEmail(theForm.payment_emailaddress);
	reason 	+= validatePhone(theForm.payment_phonenumber);
  	reason 	+= validateEmpty(theForm.payment_address1);
  	reason 	+= validateEmpty(theForm.pcountry);
  	reason 	+= validateEmpty(theForm.payment_city);
  	reason 	+= validateEmpty(theForm.pstate);
  	reason 	+= validateEmpty(theForm.payment_zipcode);
  	reason 	+= validateEmpty(theForm.payment_type_id);
 
	if (theForm.payment_type_id.value == 1) {
			
		reason 	+= validateEmptySecure(theForm.payment_cccard);
  		reason 	+= validateEmptySecure(theForm.payment_ccname);
  		reason 	+= validateEmptySecure(theForm.payment_ccnumber);
  		reason 	+= validateEmptySecure(theForm.payment_ccmonth);
  		reason 	+= validateEmptySecure(theForm.payment_ccyear);
	
	} else if (theForm.payment_type_id.value == 2) {

		reason 	+= validateEmptySecure(theForm.payment_bankname);
  		reason 	+= validateEmptySecure(theForm.payment_accountname);
  		reason 	+= validateEmptySecure(theForm.payment_routingnumber);
  		reason 	+= validateEmptySecure(theForm.payment_accountnumber);
  	}
      
  	if (reason != "") {
  	
    	return false;
  	}

  	return true;
}

function validateWebsiteSurvey(theForm) {

	var theAlert 	= document.getElementById(VALIDATION_ALERT_WRAP_ID);
	var theForm 	= document.getElementById(theForm);
	var reason 		= "";
	
	if (theForm.id == "websitesurvey1") {

		for (i = 0, n = theForm.question_1.length; i < n; i++) {
  	
			if (theForm.question_1[i].checked) {
			
				var question_1 = theForm.question_1[i].value;
				break;
			} 
		}
		
		for (i = 0, n = theForm.question_2.length; i < n; i++) {
  	
			if (theForm.question_2[i].checked) {
			
				var question_2 = theForm.question_2[i].value;
				break;
			} 
		}
		
		reason 	+= validateRadio(question_1);
		reason 	+= validateRadio(question_2);
		
		if (question_2 == "Other") {
		
			reason 	+= validateEmpty(theForm.question_2_other);
		}
  		
  	} else if (theForm.id == "websitesurvey2") {
  	
  		for (i = 0, n = theForm.question_3.length; i < n; i++) {
  	
			if (theForm.question_3[i].checked) {
			
				var question_3 = theForm.question_3[i].value;
				break;
			} 
		}

		reason 	+= validateRadio(question_3);	
  	
  	} else if (theForm.id == "websitesurvey3") {
  	
  		for (i = 0, n = theForm.question_4.length; i < n; i++) {
  	
			if (theForm.question_4[i].checked) {
			
				var question_4 = theForm.question_4[i].value;
				break;
			} 
		}
		
		for (i = 0, n = theForm.question_5.length; i < n; i++) {
  	
			if (theForm.question_5[i].checked) {
			
				var question_5 = theForm.question_5[i].value;
				break;
			} 
		}
		
		for (i = 0, n = theForm.question_6.length; i < n; i++) {
  	
			if (theForm.question_6[i].checked) {
			
				var question_6 = theForm.question_6[i].value;
				break;
			} 
		}
		
		for (i = 0, n = theForm.question_7.length; i < n; i++) {
  	
			if (theForm.question_7[i].checked) {
			
				var question_7 = theForm.question_7[i].value;
				break;
			} 
		}
		
		for (i = 0, n = theForm.question_8.length; i < n; i++) {
  	
			if (theForm.question_8[i].checked) {
			
				var question_8 = theForm.question_8[i].value;
				break;
			} 
		}
		
		for (i = 0, n = theForm.question_9.length; i < n; i++) {
  	
			if (theForm.question_9[i].checked) {
			
				var question_9 = theForm.question_9[i].value;
				break;
			} 
		}

		reason 	+= validateRadio(question_4);
		reason 	+= validateRadio(question_5);
		reason 	+= validateRadio(question_6);
		reason 	+= validateRadio(question_7);
		reason 	+= validateRadio(question_8);
		reason 	+= validateRadio(question_9);
		
		if (question_9 == "Other") {
		
			reason 	+= validateEmpty(theForm.question_9_other);
		}
  	}
  
  	if (reason != "") {
  	
  		show(theAlert);
    	return false;
  	}

  	return true;
}

function validatePartnerProgramApplicationForm(form_id) {

	var theForm = document.getElementById(form_id);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.company);
	reason 	+= validateEmpty(theForm.Legal_Company_Name__c);
	reason 	+= validateEmpty(theForm.URL);
	reason 	+= validateEmpty(theForm.country);
	reason 	+= validateEmpty(theForm.street);
	reason 	+= validateEmpty(theForm.city);
	reason 	+= validateEmpty(theForm.state);
	reason 	+= validateEmpty(theForm.zip);
	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmpty(theForm.title);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validateEmpty(theForm.Do_you_offer_Tier_1_Support__c);
  	reason 	+= validateEmpty(theForm.lead_source);
  	reason 	+= validateEmpty(theForm.Company_Size__c);
  	reason 	+= validateEmpty(theForm.Size_of_Current_Customer_Base__c);
  	reason 	+= validateEmpty(theForm.of_client_base_requires_hosting__c);
  	reason 	+= validateEmpty(theForm.targetindustries);
  	reason 	+= validateEmpty(theForm.servicesoffered);
  	
  	if (theForm.lead_source.value == "Other" || theForm.lead_source.value == "Referral") {
  		reason 	+= validateEmpty(theForm.How_heard_about_Partner_Program__c);
  	}
  	
  	if (validateCheckbox(theForm.productmanaged) == "true" && 
  		validateCheckbox(theForm.productcloud) == "true" && 
  		validateCheckbox(theForm.productjungledisk) == "true" && 
  		validateCheckbox(theForm.productemail) == "true") {
  	
  		reason 	+= validateCheckbox(theForm.productmanaged);

  		$('.product').css('backgroundColor','#F9E6E9');
  	
  	} else {
  	
  		$('.product').css('backgroundColor','#EEEEEE');
  	}
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validatePartnerApplication(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.company);
  	reason 	+= validateEmpty(theForm.URL);
  	reason 	+= validateEmpty(theForm.pcountry);
  	reason 	+= validateEmpty(theForm.street);
  	reason 	+= validateEmpty(theForm.city);
  	reason 	+= validateEmpty(theForm.pstate);
  	reason 	+= validateEmpty(theForm.zip);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.title);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validatePhone(theForm.phone);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

  		theForm.submit();
  	}
}

function validateAgencyServicesPartnerApplication(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.company);
	reason 	+= validateEmpty(theForm.Legal_Company_Name__c);
	reason 	+= validateEmpty(theForm.URL);
	reason 	+= validateEmpty(theForm.country);
	reason 	+= validateEmpty(theForm.street);
	reason 	+= validateEmpty(theForm.city);
	reason 	+= validateEmpty(theForm.state);
	reason 	+= validateEmpty(theForm.zip);
	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmpty(theForm.title);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validateEmpty(theForm.Company_Size__c);
  	reason 	+= validateEmpty(theForm.Size_of_Current_Customer_Base__c);
  	reason 	+= validateEmpty(theForm.targetindustries);
  	
   	if (validateCheckbox(theForm.productmanaged) == "true" && 
  		validateCheckbox(theForm.productcloud) == "true" && 
  		validateCheckbox(theForm.productjungledisk) == "true" && 
  		validateCheckbox(theForm.productemail) == "true") {
  	
  		reason 	+= validateCheckbox(theForm.productmanaged);

  		$('.product').css('backgroundColor','#F9E6E9');
  	
  	} else {
  	
  		$('.product').css('backgroundColor','#EEEEEE');
  	}
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

  		theForm.submit();
  	}
}

function validateIngramMicroPartnerApplication(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.company);
  	reason 	+= validateEmpty(theForm.pcountry);
  	reason 	+= validateEmpty(theForm.street);
  	reason 	+= validateEmpty(theForm.city);
  	reason 	+= validateEmpty(theForm.pstate);
  	reason 	+= validateEmpty(theForm.zip);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.title);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validatePhone(theForm.fax);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

  		theForm.submit();
  	}
}

function validateACNPartnerApplication(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.company);
  	reason 	+= validateEmpty(theForm.pcountry);
  	reason 	+= validateEmpty(theForm.street);
  	reason 	+= validateEmpty(theForm.city);
  	reason 	+= validateEmpty(theForm.pstate);
  	reason 	+= validateEmpty(theForm.zip);
  	reason 	+= validateEmpty(theForm.last_name);
  	reason 	+= validateEmpty(theForm.first_name);
  	reason 	+= validateEmpty(theForm.title);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validatePhone(theForm.phone);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

  		theForm.submit();
  	}
}

function validateAdvisoryServicesForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.name);
  	reason 	+= validateEmail(theForm.emailaddress);
  	reason 	+= validateEmpty(theForm.title);
  	reason 	+= validateEmpty(theForm.revenue);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateVisualStudioForm(theForm) {

	var theForm = document.getElementById(theForm);
	var reason 	= "";

	reason 	+= validateEmpty(theForm.first_name);
	reason 	+= validateEmpty(theForm.last_name);
	reason 	+= validatePhone(theForm.phone);
  	reason 	+= validateEmail(theForm.email);
  	reason 	+= validateEmpty(theForm.street);
  	reason 	+= validateEmpty(theForm.city);
  	reason 	+= validateEmpty(theForm.state);
  	reason 	+= validateEmpty(theForm.zip);
  	reason 	+= validateCheckbox(theForm.checkbox_eligibility);
  	reason 	+= validateCheckbox(theForm.checkbox_government);
  	reason 	+= validateCheckbox(theForm.checkbox_microsoft);
  	reason 	+= validateMatch(theForm.captcha,theForm.captcha_answer);
      
  	if (reason != "") {
  	
    	return false;
  	
  	} else {

		theForm.submit();
  	}
}

function validateMatch(field1,field2) {

    var error = "";

    if (field1.value != field2.value) {
    
    	error 					= "true";
    	
		field1.style.borderColor = "#C40022";
		field1.style.background 	= "#F9E6E9";
    
    } else {
    
		field1.style.borderColor = "#CCCCCC";
		field1.style.background 	= "#FFFFFF";
    }
    
    return error;  
}

function validateEmpty(field) {

    var error 			= "";
    var illegalChars	= /[!]/ ;
 
    if (field.value.length == 0 || field.value.match(illegalChars)) {
    
    	error 					= "true";
    	
		field.style.borderColor = "#C40022";
		field.style.background 	= "#F9E6E9";
    
    } else {
    
		field.style.borderColor = "#CCCCCC";
		field.style.background 	= "#FFFFFF";
    }
    
    return error;  
}

function validateEmptySecure(field) {

    var error = "";
 
    if (field.value.length == 0) {
    
    	error 					= "true";
    	
		field.style.borderColor = "#C40022";
		field.style.background 	= "#F9E6E9";
    
    } else {
    
		field.style.borderColor = "#41B63F";
		field.style.background 	= "#D9F0D9";
    }
    
    return error;  
}

function validateRadio(checkvalue) {

	var error = "";
	
   	if (!(checkvalue)) {
   
       	error = "true";
    }
    
	return error;
}

function validateCheckbox(checkvalue) {

	var error = "";
	
   	if (checkvalue.checked == false) {
   
       	error = "true";
       	$(checkvalue).parent().css('background','#F9E6E9');
    
    } else {
    
		$(checkvalue).parent().css('background','#FFF');
    }
    
	return error;    
}

function trim(s) {

	return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(field) {

    var error			= "";
    var tfield 			= trim(field.value);
    var emailFilter 	= /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars	= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (field.value == "") {
    
    	error 					= "true";
    
		field.style.borderColor = "#C40022";
		field.style.background 	= "#F9E6E9";

    } else if (!emailFilter.test(tfield)) {
    
    	error 					= "true";
    
		field.style.borderColor = "#C40022";
		field.style.background 	= "#F9E6E9";
        
    } else if (field.value.match(illegalChars)) {
    
    	error 					= "true";
    
		field.style.borderColor = "#C40022";
		field.style.background 	= "#F9E6E9";

    } else {
    
		field.style.borderColor = "#CCCCCC";
		field.style.background 	= "#FFFFFF";
    }
    
    return error;
}

function validatePhone(field) {

    var error 		= "";
    var stripped 	= field.value.replace(/[\(\)\.\-\ ]/g, '');    

   if (field.value == "") {
   
    	error 					= "true";
    
		field.style.borderColor = "#C40022";
		field.style.background 	= "#F9E6E9";
        
    } else if (isNaN(parseInt(stripped))) {
    
    	error 					= "true";
    
		field.style.borderColor = "#C40022";
		field.style.background 	= "#F9E6E9";
        
    } else {
    
		field.style.borderColor = "#CCCCCC";
		field.style.background 	= "#FFFFFF";
    }
    
    return error;
}

function validateHTML(field) {

    var error			= "";
    var illegalChars	= /[\<\>\]\[]/ ;
    var hrefs			= "a href";
   
    if (field.value.match(illegalChars)) {
    
    	error = "true";
    	
		field.style.borderColor = "#C40022";
		field.style.background 	= "#F9E6E9";
		
	} else if (field.value.match(hrefs)) {
    
    	error = "true";
    	
		field.style.borderColor = "#C40022";
		field.style.background 	= "#F9E6E9";
		
	} else if (field.value == "") {
    
    	error = "true";
    	
		field.style.borderColor = "#C40022";
		field.style.background 	= "#F9E6E9";
    
    } else {
    
		field.style.borderColor = "#CCCCCC";
		field.style.background 	= "#FFFFFF";
    }
    
    return error;
}

function convertSpChars(textstring) {

	var textstringholder 	= document.getElementById(textstring);
	var textstringvalue 	= textstringholder.value;
	
	textstringvalue			= textstringvalue.replace('&','(symbolampersand)');
	textstringvalue			= textstringvalue.replace('#','(symbolpound)');
	textstringholder.value	= textstringvalue;
}

function hoverSolution(node) {

	var title = document.getElementById(node.id);
	
	if (isClass(title,SOLUTION_TITLE_OVER_CLASS_NAME)) {
	
		removeClass(title,SOLUTION_TITLE_OVER_CLASS_NAME);
		addClass(title,SOLUTION_TITLE_OFF_CLASS_NAME);	
	
	} else if (isClass(title,SOLUTION_TITLE_OFF_CLASS_NAME)) {
	
		removeClass(title,SOLUTION_TITLE_OFF_CLASS_NAME);
		addClass(title,SOLUTION_TITLE_OVER_CLASS_NAME);	
	}
}

var SURVEY_OPTION_CLASS_NAME		= "survey"
var SURVEY_OPTION_ON_CLASS_NAME		= "survey-on"
var SURVEY_OPTION_OFF_CLASS_NAME	= "survey-off"

function selectSurveyOption(rootid,optionid,inputid,inputvalue) {

	var root		= document.getElementById(rootid);
	var option		= document.getElementById(optionid);
	var input		= document.getElementById(inputid);
	
	var allOptions 	= getDescendantsByTagAndClassName(root,DIV,SURVEY_OPTION_CLASS_NAME);
	
	for (i = 0; i < allOptions.length; i++) {
	
		if (allOptions[i] == option) {
		
			if (isClass(allOptions[i],SURVEY_OPTION_OFF_CLASS_NAME)) {
	
				removeClass(allOptions[i],SURVEY_OPTION_OFF_CLASS_NAME);
				addClass(allOptions[i],SURVEY_OPTION_ON_CLASS_NAME);
			}
	
		} else {
		
			if (isClass(allOptions[i],SURVEY_OPTION_ON_CLASS_NAME)) {
		
				removeClass(allOptions[i],SURVEY_OPTION_ON_CLASS_NAME);
				addClass(allOptions[i],SURVEY_OPTION_OFF_CLASS_NAME);
			}
		}
	}
	
	input.value = inputvalue;
}

//rackspace.ajax.js

var http_request = false;

function makeRequest(url,parameters,divid) {

  	http_request = false;
  
  	if (window.XMLHttpRequest) {
	 
	 	http_request = new XMLHttpRequest();
	 
	 	if (http_request.overrideMimeType) {
		
			http_request.overrideMimeType('text/html');
	 	}
  	
  	} else if (window.ActiveXObject) {
	 
	 	try {
		
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
	 
	 	} catch (e) {
			
			try {
		   
		   		http_request = new ActiveXObject("Microsoft.XMLHTTP");
			
			} catch (e) {}
	 	}
  	}
  
  	if (!http_request) {
  	
	 	alert('Cannot create XMLHTTP instance');
	 	return false;
  	}
  	
  	if (divid == "cv-player-video-wrap") {
  
  		http_request.onreadystatechange = printVideoPlayer;
  	
  	} else if (divid == "survey-wrap") {
  	
  		http_request.onreadystatechange = printSurveyResults;
  		
  	} else if (divid == "configuration-wrap") {
  	
  		http_request.onreadystatechange = printSpecifications;
  	
  	} else if (divid == "sidebar-livechat-wrap") {
  	
  		http_request.onreadystatechange = printLiveChat;
  	}
  	
  	http_request.open("POST",url + parameters,true);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(parameters);
}

function printVideoPlayer() {

  	if (http_request.readyState == 4) {
  	
	 	if (http_request.status == 200) {
		
			result = http_request.responseText;
			document.getElementById("cv-player-video-wrap").innerHTML = result;
			
	 	} else {
	 	
			alert('There was a problem with the request.');
	 	}
  	}
}

function printSurveyResults() {

  	if (http_request.readyState == 4) {
  	
	 	if (http_request.status == 200) {
		
			result = http_request.responseText;
			
			document.getElementById("survey-wrap").innerHTML = result;
			
			document.getElementById("result-1").style.display = "none";
			document.getElementById("result-2").style.display = "none";
			document.getElementById("result-3").style.display = "none";
			document.getElementById("result-4").style.display = "none";
			document.getElementById("result-5").style.display = "none";
			document.getElementById("result-6").style.display = "none";
			
			Effect.SlideRightIn("result-1",{duration:3});
			Effect.SlideRightIn("result-2",{duration:3});
			Effect.SlideRightIn("result-3",{duration:3});
			Effect.SlideRightIn("result-4",{duration:3});
			Effect.SlideRightIn("result-5",{duration:3});
			Effect.SlideRightIn("result-6",{duration:3});
			
	 	} else {
	 	
			alert('There was a problem with the request.');
	 	}
  	}
}

function printLiveChat() {

  	if (http_request.readyState == 4) {
  	
	 	if (http_request.status == 200) {
		
			result = http_request.responseText;
			
			document.getElementById("sidebar-livechat-wrap").innerHTML = result;
			
	 	} else {
	 	
			alert('There was a problem with the request.');
	 	}
  	}
}

function get(divid) {

  	var getstr 	= "&";
	getstr 		= getstr + '?random=' + Math.random();
  
	makeRequest("/includes/flash/videoplayer.php",getstr,divid);
}

function getSurvey(formid,url,divid) {

  	var getstr 	= "?";
  	
  	var obj = document.getElementById(formid);
  	
  	var inputs 		= obj.getElementsByTagName("input");
  	var selects 	= obj.getElementsByTagName("select");
  	var textareas 	= obj.getElementsByTagName("textarea");
  
  	for (i = 0; i < inputs.length; i++) {
		 
		if (inputs[i].type == "hidden") {
		
			getstr += inputs[i].name + "=" + inputs[i].value + "&";
		}
		
		if (inputs[i].type == "text") {
		
			getstr += inputs[i].name + "=" + inputs[i].value + "&";
			inputs[i].value = "";
		}
		
		if (inputs[i].type == "checkbox") {
		
			if (obj.childNodes[i].checked) {
			
				getstr += inputs[i].name + "=" + inputs[i].value + "&";
				inputs[i].value = "";
				
			} else {
			
				getstr += inputs[i].name + "=&";
				inputs[i].value = "";
			}
		}
		
		if (inputs[i].type == "radio") {
		
			if (inputs[i].checked) {
			
				getstr += inputs[i].name + "=" + inputs[i].value + "&";
				inputs[i].value = "";
			}
		}
		
		if (inputs[i].type == "file") {
			
			alert(inputs[i].value);
			
			getstr += inputs[i].name + "=" + inputs[i].value + "&";
			inputs[i].value = "";
		}
	}   
	 
	for (i = 0; i < selects.length; i++) {
	
		var sel = selects[i];
		getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
		selects[i].value = "";
	}
	 
	for (i = 0; i < textareas.length; i++) {
	 
		getstr += textareas[i].name + "=" + textareas[i].value + "&";
		textareas[i].value = "";
	}
	
	getstr = getstr + '?random=' + Math.random();
  
	makeRequest(url,getstr,divid);
}

function recordLiveChatClick(formid,url,divid) {

  	var getstr = '?random=' + Math.random();
  	
  	var obj = document.getElementById(formid);
  	
  	var inputs 		= obj.getElementsByTagName("input");
  
  	for (i = 0; i < inputs.length; i++) {
		 
		if (inputs[i].type == "hidden") {
		
			getstr += "&" + inputs[i].name + "=" + inputs[i].value;
		}
		
		if (inputs[i].type == "text") {
		
			getstr += "&" + inputs[i].name + "=" + inputs[i].value;
			inputs[i].value = "";
		}
	}

	makeRequest(url,getstr,divid);
}

//rackspace.flash.js

var isIE  	= (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin 	= (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion() {

	var version;
	var axo;
	var e;

	try {

		axo 	= new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
		
	} catch (e) {
	
	}

	if (!version) {
	
		try {

			axo 					= new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			version 				= "WIN 6,0,21,0";	
			axo.AllowScriptAccess 	= "always";
			version 				= axo.GetVariable("$version");

		} catch (e) {
		
		}
	}

	if (!version) {
	
		try {

			axo 	= new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
			
		} catch (e) {
		
		}
	}

	if (!version) {
	
		try {

			axo 	= new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
			
		} catch (e) {
		
		}
	}

	if (!version) {
	
		try {

			axo 	= new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
			
		} catch (e) {
		
			version = -1;
		}
	}
	
	return version;
}


function GetSwfVer() {

	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
	
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
		
			var swVer2 				= navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription 	= navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray 			= flashDescription.split(" ");
			var tempArrayMajor 		= descArray[2].split(".");			
			var versionMajor 		= tempArrayMajor[0];
			var versionMinor 		= tempArrayMajor[1];
			var versionRevision 	= descArray[3];
			
			if (versionRevision == "") {
			
				versionRevision = descArray[4];
			}
			
			if (versionRevision[0] == "d") {
			
				versionRevision = versionRevision.substring(1);
				
			} else if (versionRevision[0] == "r") {
			
				versionRevision = versionRevision.substring(1);
				
				if (versionRevision.indexOf("d") > 0) {
				
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	
	} else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) {
	
		flashVer = 4;

	} else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) {
	
		flashVer = 3;

	} else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) {
	
		flashVer = 2;
	
	} else if ( isIE && isWin && !isOpera ) {
	
		flashVer = ControlVersion();
	}
	
	return flashVer;
}

function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {

	versionStr = GetSwfVer();
	
	if (versionStr == -1 ) {
	
		return false;
		
	} else if (versionStr != 0) {
	
		if(isIE && isWin && !isOpera) {

			tempArray         = versionStr.split(" ");
			tempString        = tempArray[1];
			versionArray      = tempString.split(",");
			
		} else {
		
			versionArray      = versionStr.split(".");
		}
		
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];


		if (versionMajor > parseFloat(reqMajorVer)) {
		
			return true;
			
		} else if (versionMajor == parseFloat(reqMajorVer)) {
		
			if (versionMinor > parseFloat(reqMinorVer)) {
			
				return true;
				
			} else if (versionMinor == parseFloat(reqMinorVer)) {
			
				if (versionRevision >= parseFloat(reqRevision)) {
				
					return true;
				}
			}
		}
		
		return false;
	}
}

function AC_AddExtension(src, ext) {

  	if (src.indexOf('?') != -1) {
  
   		return src.replace(/\?/, ext+'?');
  
  	} else {
  
    	return src + ext;
    }
}

function AC_Generateobj(objAttrs, params, embedAttrs) { 

  	var str = '';
  	
  	if (isIE && isWin && !isOpera) {
  	
    	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 += '</object>';
  	
  	} else {
  	
    	str += '<embed ';
    
    	for (var i in embedAttrs) {
    	
      		str += i + '="' + embedAttrs[i] + '" ';
    	}
    
    	str += '> </embed>';
  	}

  	document.write(str);
}

function AC_FL_RunContent() {

  	var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
    
  	AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent() {
  	var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
    
  	AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, 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":	
				args[i+1] 					= AC_AddExtension(args[i+1], ext);
				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":
			case "id":
				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 "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;
}

var requiredMajorVersion 	= 8;
var requiredMinorVersion 	= 0;
var requiredRevision 		= 24;

function toggleCountrySelect(wrapid) {

	var wrap = document.getElementById(wrapid);

	if (wrap.style.display == "" || wrap.style.display == NONE) {

		show(wrap);
	
	} else {
	
		hide(wrap);
	}
}

function start_slideshow(start_frame, end_frame, delay) {
	id = setTimeout(switch_slides(start_frame,start_frame,end_frame, delay), delay);
}

function switch_slides(frame, start_frame, end_frame, delay) {
	return (function() {
		Effect.Fade('slide' + frame, { duration: 1.0 });
		if (frame == end_frame) { frame = start_frame; } else { frame = frame + 1; }
		Effect.Appear('slide' + frame, { duration: 1.0 });
		if (delay == 1000) { delay = 3000; }
		id = setTimeout(switch_slides(frame, start_frame, end_frame, delay), delay);
	})
}

function stop_slideshow() {
	clearTimeout(id);
}

var PANE_0_CLASS_NAME = "pane0";
var PANE_1_CLASS_NAME = "pane1";
var PANE_2_CLASS_NAME = "pane2";
var PANE_3_CLASS_NAME = "pane3";

function showHomePane(pane,paneclass) {

	var pane = document.getElementById(pane);
	
	removeClass(pane,PANE_0_CLASS_NAME);
	removeClass(pane,PANE_1_CLASS_NAME);
	removeClass(pane,PANE_2_CLASS_NAME);
	removeClass(pane,PANE_3_CLASS_NAME);
	
	addClass(pane,paneclass);
}

var LEFTPANE_ID					= "leftpane-wrap";
var LEFTPANE_CLASS_NAME			= "leftpane";
var LEFTPANE_ON_CLASS_NAME		= "leftpane-on";
var LEFTPANE_OFF_CLASS_NAME		= "leftpane-off";

var RIGHTPANE_ID				= "rightpane-wrap";
var RIGHTPANE_CLASS_NAME		= "rightpane";
var RIGHTPANE_ON_CLASS_NAME		= "rightpane-on";
var RIGHTPANE_OFF_CLASS_NAME	= "rightpane-off";

var CELL_1_WRAP_ID				= "cell1-wrap";
var CELL_2_WRAP_ID				= "cell2-wrap";
var CELL_3_WRAP_ID				= "cell3-wrap";

var BUTTON_WRAP_ID				= "button-wrap";

function selectLeftPane() {

	var leftpane 	= document.getElementById(LEFTPANE_ID);
	var rightpane 	= document.getElementById(RIGHTPANE_ID);
	
	var cell1		= document.getElementById(CELL_1_WRAP_ID);
	var cell2		= document.getElementById(CELL_2_WRAP_ID);
	var cell3		= document.getElementById(CELL_3_WRAP_ID);
	
	var button		= document.getElementById(BUTTON_WRAP_ID);
	
	removeClass(leftpane,LEFTPANE_CLASS_NAME);
	removeClass(leftpane,LEFTPANE_OFF_CLASS_NAME);
	addClass(leftpane,LEFTPANE_ON_CLASS_NAME);
	
	removeClass(rightpane,RIGHTPANE_CLASS_NAME);
	removeClass(rightpane,RIGHTPANE_ON_CLASS_NAME);
	addClass(rightpane,RIGHTPANE_OFF_CLASS_NAME);
	
	show(cell1);
	show(cell2);
	show(cell3);
	
	hide(button);
}

function selectRightPane() {

	var leftpane 	= document.getElementById(LEFTPANE_ID);
	var rightpane 	= document.getElementById(RIGHTPANE_ID);
	
	var cell1		= document.getElementById(CELL_1_WRAP_ID);
	var cell2		= document.getElementById(CELL_2_WRAP_ID);
	var cell3		= document.getElementById(CELL_3_WRAP_ID);
	
	var button		= document.getElementById(BUTTON_WRAP_ID);
	
	removeClass(leftpane,LEFTPANE_CLASS_NAME);
	removeClass(leftpane,LEFTPANE_ON_CLASS_NAME);
	addClass(leftpane,LEFTPANE_OFF_CLASS_NAME);
	
	removeClass(rightpane,RIGHTPANE_CLASS_NAME);
	removeClass(rightpane,RIGHTPANE_OFF_CLASS_NAME);
	addClass(rightpane,RIGHTPANE_ON_CLASS_NAME);
	
	hide(cell1);
	hide(cell2);
	hide(cell3);
	
	show(button);
}

function defaultPanes() {

	var leftpane 	= document.getElementById(LEFTPANE_ID);
	var rightpane 	= document.getElementById(RIGHTPANE_ID);
	
	var cell1		= document.getElementById(CELL_1_WRAP_ID);
	var cell2		= document.getElementById(CELL_2_WRAP_ID);
	var cell3		= document.getElementById(CELL_3_WRAP_ID);
	
	var button		= document.getElementById(BUTTON_WRAP_ID);
	
	removeClass(leftpane,LEFTPANE_ON_CLASS_NAME);
	removeClass(leftpane,LEFTPANE_OFF_CLASS_NAME);
	addClass(leftpane,LEFTPANE_CLASS_NAME);
	
	removeClass(rightpane,RIGHTPANE_ON_CLASS_NAME);
	removeClass(rightpane,RIGHTPANE_OFF_CLASS_NAME);
	addClass(rightpane,RIGHTPANE_CLASS_NAME);
	
	hide(cell1);
	hide(cell2);
	hide(cell3);
	
	hide(button);
}

function selectAll(textarea) {

	formtextarea = document.getElementById(textarea);
	formtextarea.focus();
	formtextarea.select();
}

function darkenPage() {

    var darken 			= document.getElementById('page-darken-wrap');
    darken.style.height = document.body.parentNode.scrollHeight + 'px';
    
    show(darken);
}

function lightenPage() {

    var darken 			= document.getElementById('page-darken-wrap');
    
    hide(darken);
}

SUPPORTTEAM_GRAPHIC_WRAP_ID		= "supportteam-graphic-wrap";
SUPPORTTEAM_TITLE_WRAP_ID		= "supportteam-title-wrap";

SUPPORTTEAM_CELL_1_1_WRAP_ID	= "supportteam-cell-1-1-wrap";
SUPPORTTEAM_CELL_1_2_WRAP_ID	= "supportteam-cell-1-2-wrap";
SUPPORTTEAM_CELL_1_3_WRAP_ID	= "supportteam-cell-1-3-wrap";
SUPPORTTEAM_CELL_1_4_WRAP_ID	= "supportteam-cell-1-4-wrap";
SUPPORTTEAM_CELL_1_5_WRAP_ID	= "supportteam-cell-1-5-wrap";

SUPPORTTEAM_CELL_2_1_WRAP_ID	= "supportteam-cell-2-1-wrap";
SUPPORTTEAM_CELL_2_2_WRAP_ID	= "supportteam-cell-2-2-wrap";
SUPPORTTEAM_CELL_2_3_WRAP_ID	= "supportteam-cell-2-3-wrap";
SUPPORTTEAM_CELL_2_4_WRAP_ID	= "supportteam-cell-2-4-wrap";
SUPPORTTEAM_CELL_2_5_WRAP_ID	= "supportteam-cell-2-5-wrap";

function hoverSupportTeam(team) {

	var graphic		= document.getElementById(SUPPORTTEAM_GRAPHIC_WRAP_ID);
	var title		= document.getElementById(SUPPORTTEAM_TITLE_WRAP_ID);
	
	var cell11		= document.getElementById(SUPPORTTEAM_CELL_1_1_WRAP_ID);
	var cell12		= document.getElementById(SUPPORTTEAM_CELL_1_2_WRAP_ID);
	var cell13		= document.getElementById(SUPPORTTEAM_CELL_1_3_WRAP_ID);
	var cell14		= document.getElementById(SUPPORTTEAM_CELL_1_4_WRAP_ID);
	var cell15		= document.getElementById(SUPPORTTEAM_CELL_1_5_WRAP_ID);
	
	var cell21		= document.getElementById(SUPPORTTEAM_CELL_2_1_WRAP_ID);
	var cell22		= document.getElementById(SUPPORTTEAM_CELL_2_2_WRAP_ID);
	var cell23		= document.getElementById(SUPPORTTEAM_CELL_2_3_WRAP_ID);
	var cell24		= document.getElementById(SUPPORTTEAM_CELL_2_4_WRAP_ID);
	var cell25		= document.getElementById(SUPPORTTEAM_CELL_2_5_WRAP_ID);
	
	hide(cell11);
	hide(cell12);
	hide(cell13);
	hide(cell14);
	hide(cell15);
	
	hide(cell21);
	hide(cell22);
	hide(cell23);
	hide(cell24);
	hide(cell25);

	if (team == 1) {
	
		graphic.style.background 	= "url('/images/managed_hosting/managed_colocation/graphic-accountmanager.png')";
		title.style.background 		= "url('/images/managed_hosting/managed_colocation/title-accountmanager.png')";
		show(cell11);
		show(cell21);
	
	} else if (team == 2) {
	
		graphic.style.background 	= "url('/images/managed_hosting/managed_colocation/graphic-deploymentengineer.png')";
		title.style.background 		= "url('/images/managed_hosting/managed_colocation/title-deploymentengineer.png')";
		show(cell12);
		show(cell22);
	
	} else if (team == 3) {
	
		graphic.style.background 	= "url('/images/managed_hosting/managed_colocation/graphic-accountcoordinator.png')";
		title.style.background 		= "url('/images/managed_hosting/managed_colocation/title-accountcoordinator.png')";
		show(cell13);
		show(cell23);
	
	} else if (team == 4) {
	
		graphic.style.background 	= "url('/images/managed_hosting/managed_colocation/graphic-networkengineer.png')";
		title.style.background 		= "url('/images/managed_hosting/managed_colocation/title-networkengineer.png')";
		show(cell14);
		show(cell24);
	
	} else if (team == 5) {
	
		graphic.style.background 	= "url('/images/managed_hosting/managed_colocation/graphic-supportspecialists.png')";
		title.style.background 		= "url('/images/managed_hosting/managed_colocation/title-supportspecialists.png')";
		show(cell15);
		show(cell25);
	}
}

DEDICATEDTEAM_GRAPHIC_WRAP_ID	= "dedicatedteam-graphic-wrap";
DEDICATEDTEAM_TITLE_WRAP_ID		= "dedicatedteam-title-wrap";

DEDICATEDTEAM_CELL_3_1_WRAP_ID	= "dedicatedteam-cell-3-1-wrap";
DEDICATEDTEAM_CELL_3_2_WRAP_ID	= "dedicatedteam-cell-3-2-wrap";
DEDICATEDTEAM_CELL_3_3_WRAP_ID	= "dedicatedteam-cell-3-3-wrap";
DEDICATEDTEAM_CELL_3_4_WRAP_ID	= "dedicatedteam-cell-3-4-wrap";
DEDICATEDTEAM_CELL_3_5_WRAP_ID	= "dedicatedteam-cell-3-5-wrap";
DEDICATEDTEAM_CELL_3_6_WRAP_ID	= "dedicatedteam-cell-3-6-wrap";
DEDICATEDTEAM_CELL_3_7_WRAP_ID	= "dedicatedteam-cell-3-7-wrap";
DEDICATEDTEAM_CELL_3_8_WRAP_ID	= "dedicatedteam-cell-3-8-wrap";
DEDICATEDTEAM_CELL_3_9_WRAP_ID	= "dedicatedteam-cell-3-9-wrap";

function hoverDedicatedTeam(team) {

	var graphic		= document.getElementById(DEDICATEDTEAM_GRAPHIC_WRAP_ID);
	var title		= document.getElementById(DEDICATEDTEAM_TITLE_WRAP_ID);
	
	var cell31		= document.getElementById(DEDICATEDTEAM_CELL_3_1_WRAP_ID);
	var cell32		= document.getElementById(DEDICATEDTEAM_CELL_3_2_WRAP_ID);
	var cell33		= document.getElementById(DEDICATEDTEAM_CELL_3_3_WRAP_ID);
	var cell34		= document.getElementById(DEDICATEDTEAM_CELL_3_4_WRAP_ID);
	var cell35		= document.getElementById(DEDICATEDTEAM_CELL_3_5_WRAP_ID);
	var cell36		= document.getElementById(DEDICATEDTEAM_CELL_3_6_WRAP_ID);
	var cell37		= document.getElementById(DEDICATEDTEAM_CELL_3_7_WRAP_ID);
	var cell38		= document.getElementById(DEDICATEDTEAM_CELL_3_8_WRAP_ID);
	var cell39		= document.getElementById(DEDICATEDTEAM_CELL_3_9_WRAP_ID);
	
	hide(cell31);
	hide(cell32);
	hide(cell33);
	hide(cell34);
	hide(cell35);
	hide(cell36);
	hide(cell37);
	hide(cell38);
	hide(cell39);

	if (team == 1) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/overview/graphic-accountmanager.png')";
		title.style.background 		= "url('/images/managed_hosting/support/overview/title-accountmanager.png')";
		show(cell31);
	
	} else if (team == 2) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/overview/graphic-businessdevelopmentconsultant.png')";
		title.style.background 		= "url('/images/managed_hosting/support/overview/title-businessdevelopmentconsultant.png')";
		show(cell32);
	
	} else if (team == 3) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/overview/graphic-accountcoordinator.png')";
		title.style.background 		= "url('/images/managed_hosting/support/overview/title-accountcoordinator.png')";
		show(cell33);
	
	} else if (team == 4) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/overview/graphic-billingspecialist.png')";
		title.style.background 		= "url('/images/managed_hosting/support/overview/title-billingspecialist.png')";
		show(cell34);
	
	} else if (team == 5) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/overview/graphic-professionalservices.png')";
		title.style.background 		= "url('/images/managed_hosting/support/overview/title-professionalservices.png')";
		show(cell35);
	
	} else if (team == 6) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/overview/graphic-datacenteroperations.png')";
		title.style.background 		= "url('/images/managed_hosting/support/overview/title-datacenteroperations.png')";
		show(cell36);
	
	} else if (team == 7) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/overview/graphic-supportspecialist.png')";
		title.style.background 		= "url('/images/managed_hosting/support/overview/title-supportspecialist.png')";
		show(cell37);
	
	} else if (team == 8) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/overview/graphic-supporttechnician.png')";
		title.style.background 		= "url('/images/managed_hosting/support/overview/title-supporttechnician.png')";
		show(cell38);
	
	} else if (team == 9) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/overview/graphic-leadtechnician.png')";
		title.style.background 		= "url('/images/managed_hosting/support/overview/title-leadtechnician.png')";
		show(cell39);
	}
}

SUPPORTLAYERS_GRAPHIC_WRAP_ID	= "supportlayers-graphic-wrap";

SUPPORTLAYERS_TEXT_1_1_WRAP_ID	= "supportlayers-text-1-1-wrap";
SUPPORTLAYERS_TEXT_1_2_WRAP_ID	= "supportlayers-text-1-2-wrap";
SUPPORTLAYERS_TEXT_1_3_WRAP_ID	= "supportlayers-text-1-3-wrap";
SUPPORTLAYERS_TEXT_1_4_WRAP_ID	= "supportlayers-text-1-4-wrap";
SUPPORTLAYERS_TEXT_1_5_WRAP_ID	= "supportlayers-text-1-5-wrap";
SUPPORTLAYERS_TEXT_1_6_WRAP_ID	= "supportlayers-text-1-6-wrap";

SUPPORTLAYERS_TEXT_2_1_WRAP_ID	= "supportlayers-text-2-1-wrap";
SUPPORTLAYERS_TEXT_2_2_WRAP_ID	= "supportlayers-text-2-2-wrap";
SUPPORTLAYERS_TEXT_2_3_WRAP_ID	= "supportlayers-text-2-3-wrap";
SUPPORTLAYERS_TEXT_2_4_WRAP_ID	= "supportlayers-text-2-4-wrap";
SUPPORTLAYERS_TEXT_2_5_WRAP_ID	= "supportlayers-text-2-5-wrap";
SUPPORTLAYERS_TEXT_2_6_WRAP_ID	= "supportlayers-text-2-6-wrap";

function hoverSupportLayers(team) {

	var graphic		= document.getElementById(SUPPORTLAYERS_GRAPHIC_WRAP_ID);
	
	var text11		= document.getElementById(SUPPORTLAYERS_TEXT_1_1_WRAP_ID);
	var text12		= document.getElementById(SUPPORTLAYERS_TEXT_1_2_WRAP_ID);
	var text13		= document.getElementById(SUPPORTLAYERS_TEXT_1_3_WRAP_ID);
	var text14		= document.getElementById(SUPPORTLAYERS_TEXT_1_4_WRAP_ID);
	var text15		= document.getElementById(SUPPORTLAYERS_TEXT_1_5_WRAP_ID);
	var text16		= document.getElementById(SUPPORTLAYERS_TEXT_1_6_WRAP_ID);
	
	var text21		= document.getElementById(SUPPORTLAYERS_TEXT_2_1_WRAP_ID);
	var text22		= document.getElementById(SUPPORTLAYERS_TEXT_2_2_WRAP_ID);
	var text23		= document.getElementById(SUPPORTLAYERS_TEXT_2_3_WRAP_ID);
	var text24		= document.getElementById(SUPPORTLAYERS_TEXT_2_4_WRAP_ID);
	var text25		= document.getElementById(SUPPORTLAYERS_TEXT_2_5_WRAP_ID);
	var text26		= document.getElementById(SUPPORTLAYERS_TEXT_2_6_WRAP_ID);
	
	hide(text11);
	hide(text12);
	hide(text13);
	hide(text14);
	hide(text15);
	hide(text16);
	
	hide(text21);
	hide(text22);
	hide(text23);
	hide(text24);
	hide(text25);
	hide(text26);

	if (team == 1) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/layers/layer-1.png')";
		show(text11);
		show(text21);
	
	} else if (team == 2) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/layers/layer-2.png')";
		show(text12);
		show(text22);
	
	} else if (team == 3) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/layers/layer-3.png')";
		show(text13);
		show(text23);
	
	} else if (team == 4) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/layers/layer-4.png')";
		show(text14);
		show(text24);
	
	} else if (team == 5) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/layers/layer-5.png')";
		show(text15);
		show(text25);
	
	} else if (team == 6) {
	
		graphic.style.background 	= "url('/images/managed_hosting/support/layers/layer-6.png')";
		show(text16);
		show(text26);
	}
}

function clickChatInvite(method) {

	var div = document.getElementById('chatinvite-wrap');
	
	Effect.Fade(div);
	
	if (method != "auto") {

		createCookie('chatinvitecookie','invitesent',1);
	}
}

function loadChatInvite() {

	var cookie 	= readCookie('chatinvitecookie');
	
	if (!cookie) {

		s=s_gi('rackspacecom');
		s.events='event12';
		s.tl(this,'o','Chat Invite');
		setTimeout('showChatInvite()',5000);
		s.events='';
	}
}

function showChatInvite() {

	var wrap 	= document.getElementById('chatinvite-wrap');
	
	show(wrap);
	setTimeout('clickChatInvite("auto")',15000);
}

function showBreadcrumbContactForm(wrap,image) {

	var wrap 	= document.getElementById(wrap);
	var image 	= document.getElementById(image);
	
	if (!isShowing(wrap)) {
	
		image.src	= '/images/managed_hosting/breadcrumb/salesform-hover.png';
		Effect.SlideDown(wrap);
		
	} else {
		
		image.src	= '/images/managed_hosting/breadcrumb/salesform.png';
		Effect.SlideUp(wrap);
	}
}

function toggleBreadcrumbButton(wrap,image,mouse) {

	var wrap 	= document.getElementById(wrap);
	var image 	= document.getElementById(image);
	
	if (!isShowing(wrap)) {
	
		if (mouse == "over") {
		
			image.src	= '/images/managed_hosting/breadcrumb/salesform-hover.png';
			
		} else {
		
			image.src	= '/images/managed_hosting/breadcrumb/salesform.png';
		}
	}
}

function toggleNetAppForm(form) {

	var form 					= document.getElementById(form);
	var formelement 			= form.netapp_type;
	
	var netappform_wrap			= document.getElementById('netapp-wrap');
	var netappresellerform_wrap	= document.getElementById('netappreseller-wrap');
	
	if (formelement.value == "netapp") {
	
		show(netappform_wrap);
		hide(netappresellerform_wrap);
	
	} else if (formelement.value == "netappreseller") {
	
		hide(netappform_wrap);
		show(netappresellerform_wrap);	
	
	} else {
	
		hide(netappform_wrap);
		hide(netappresellerform_wrap);
	}
}

var FEATURE_HOME_WRAP_ID		 	= "home-feature-wrap";
var FEATURE_HOME_CLASS_NAME 		= "feature-content-wrap";

var FEATURE_THUMB_WRAP_ID			= "home-feature-thumb-wrap";
var FEATURE_THUMB_CLASS_NAME		= "feature-thumb-wrap";

var FEATURE_THUMB_SELECTED			= "feature-selected";
var FEATURE_THUMB_UNSLECTED			= "feature-unselected";

function changeHomeFeature(feature,thumb) {

	var featureroot	= document.getElementById(FEATURE_HOME_WRAP_ID);
	var thumbroot	= document.getElementById(FEATURE_THUMB_WRAP_ID);
	
	var feature 	= document.getElementById(feature);
	var features 	= getDescendantsByTagAndClassName(featureroot,DIV,FEATURE_HOME_CLASS_NAME);
	
	var thumb 		= document.getElementById(feature);
	var thumbs 		= getDescendantsByTagAndClassName(thumbroot,DIV,FEATURE_THUMB_CLASS_NAME);
	
	for (i = 0; i < features.length; i++) {
	
		removeClass(thumbs[i],FEATURE_THUMB_SELECTED);
		removeClass(thumbs[i],FEATURE_THUMB_UNSLECTED);
	
		if (features[i] == feature) {
		
			show(features[i]);
			addClass(thumbs[i],FEATURE_THUMB_SELECTED);
	
		} else {
		
			hide(features[i]);
			addClass(thumbs[i],FEATURE_THUMB_UNSLECTED);
		}
	}
}

function toggleAccordion(evt,head,wrap) {

	var articleHead 				= document.getElementById('accordion-articles-head');
	var videoHead 					= document.getElementById('accordion-videos-head');
	var webinarHead 				= document.getElementById('accordion-webinars-head');
	var podcastHead 				= document.getElementById('accordion-podcasts-head');
	var whitepaperHead 				= document.getElementById('accordion-whitepapers-head');
	var eventHead	 				= document.getElementById('accordion-events-head');
	
	var articleWrap 				= document.getElementById('accordion-articles-wrap');
	var videoWrap 					= document.getElementById('accordion-videos-wrap');
	var webinarWrap 				= document.getElementById('accordion-webinars-wrap');
	var podcastWrap 				= document.getElementById('accordion-podcasts-wrap');
	var whitepaperWrap 				= document.getElementById('accordion-whitepapers-wrap');
	var eventWrap	 				= document.getElementById('accordion-events-wrap');

	if (articleWrap) hide(articleWrap);
	if (videoWrap) hide(videoWrap);
	if (webinarWrap) hide(webinarWrap);
	if (podcastWrap) hide(podcastWrap);
	if (whitepaperWrap) hide(whitepaperWrap);
	if (eventWrap) hide(eventWrap);
	
	if (articleHead) removeClass(articleHead,"accordion-toggle-active");
	if (videoHead) removeClass(videoHead,"accordion-toggle-active");
	if (webinarHead) removeClass(webinarHead,"accordion-toggle-active");
	if (podcastHead) removeClass(podcastHead,"accordion-toggle-active");
	if (whitepaperHead) removeClass(whitepaperHead,"accordion-toggle-active");
	if (eventHead) removeClass(eventHead,"accordion-toggle-active");

	var head						= document.getElementById(head);
	var wrap						= document.getElementById(wrap);

	show(wrap);
	
	addClass(head,"accordion-toggle-active");
}

$(document).ready(function(){

	var movex 			= $("#newsticker").width();
	var moveduration 	= $("#newsticker").width() / 50;
	
	startNewsTicker();
	
	function startNewsTicker() {
	
		$("#newsticker").hide();
		$("#newsticker").css("left","0px");
	
		$("#newsticker").fadeIn(3000).animate({
			left: -movex
		}, moveduration * 1000, function(){
			startNewsTicker();
		});
	}
});

function compare_products(theElement) {
	$('.comparisonList').removeClass('current');
	var element = $('#' + theElement);
	element.addClass('current');
	$('.usageHiddenList').hide();
	$('#' + theElement + 'Info').show();
}

function compare_performance(theElement) {
	$('.perfList').removeClass('current');
	var element = $('#' + theElement);
	element.addClass('current');
	$('.hiddenList').hide();
	$('#' + theElement + 'Info').show();
}

function compare_usage(theElement) {
	$('.usageList').removeClass('current');
	var element = $('#' + theElement);
	element.addClass('current');
	$('.usageHiddenList').hide();
	$('#' + theElement + 'Info').show();
}

function show_slider(theElement) {
	$('.flipper').hide();
	$('#' + theElement).show();
}

function cartSlider() {

	var cs_animation	= .5;	// Animation Time (seconds)
	var cs_invite		= 10;	// Invite Wait Time (seconds)
	var cs_duration		= 15;	// Invite Hold Time (seconds)
	var cs_move			= 75;

	var cs_start 		= -77;	// Invite Tab Width (pixels)
	var cs_finish		= cs_start + cs_move;

	$('#cartslider').mouseover(function(){
		if ($(this).css("marginLeft").replace('px','') == cs_start){
			$(this).animate({marginLeft:"+=" + cs_move},cs_animation * 1000);
			$(this).resume("mouseover_timer");}
	});
	
	$('#cartslider').mouseleave(function(){
		if ($(this).css("marginLeft").replace('px','') == cs_finish){
			$(this).animate({marginLeft:"-=" + cs_move},cs_animation * 1000);
			$(this).resume("mouseover_timer");
			$(this).resume("mouseleave_timer");}
	});
}

function chatSlider() {

	var cs_animation	= 1;													// Animation Time (seconds)
	var cs_invite		= 10;													// Invite Wait Time (seconds)
	var cs_duration		= 15;													// Invite Hold Time (seconds)
	
	var cs_move			= $('.chatslider-close').width();						// Slider Movement (pixels)
	
	if ($('div').hasClass('chatslider')){
	
		var cs_start 	= $('.chatslider').css("marginLeft").replace('px',''); 	// Invite Tab Width (pixels)
		var cs_finish	= cs_start + cs_move;
	}
	
	$('#chatslider').mouseenter(function(){
	
		if ($(this).css("marginLeft").replace('px','') == cs_start){
			$(this).animate({marginLeft:"+=" + cs_move},cs_animation * 1000,function(){
				cs_finish_A = $(this).css("marginLeft").replace('px','')});
			$(this).resume("mouseover_timer");}
	});
	
	$('#chatslider').click(function(){
	
		if ($(this).css("marginLeft").replace('px','') == cs_finish_A){
			$(this).animate({marginLeft:"-=" + cs_move},cs_animation * 1000,function(){
				cs_start = $(this).css("marginLeft").replace('px','')});
			$(this).resume("mouseover_timer");
			$(this).resume("mouseleave_timer");}
	});
	
	$('#chatslider').mouseleave(function(){
	
		if ($(this).css("marginLeft").replace('px','') == cs_finish_A){
			$(this).suspend(2000,"mouseleave_timer").click();}
	});
}

function initFilesFAQ() {

	$(document).ready(function() {

		var hash = window.location.hash;
	
		if (hash.search(/akamai/) == 1) {
			compare_products('akamaifaqs');
		}
	});
}

function initServersFAQ() {

	$(document).ready(function() {
	
		var hash = window.location.hash;
	
		if (hash.search(/moc/) == 1) {
			compare_products('mslfaqs');
		}
	});
}

function initManagedCloud() {

	$(document).ready(function() {
		MocVidSwitch.init('videoSelect');
	});
}

// TODO: make this more extensible, its a quick hack for a last minute change
var MocVidSwitch = {
	active_id: 'vid1',
	container: null,
	init: function(selectDiv) {
		this.container = $('#'+selectDiv);
		this._bindClicks(this.container);
	},
	switch_vid: function (div) {
		var clicked_id = $(div).attr('id');
		if( clicked_id != this.active_id ) {
			if (this.active_id == 'vid2') {
				$('#vid2').removeClass('active');
				$('#vid1').addClass('active');

				$('#vid2_div').hide();
				$('#vid1_div').show();
			} else {
				$('#vid1').removeClass('active');
				$('#vid2').addClass('active');

				$('#vid1_div').hide();
				$('#vid2_div').show();
			}
		}
		this.active_id = clicked_id;
	},
	_bindClicks: function(container) {
		container.children().each(function() {
			$(this).click(function() {
				MocVidSwitch.switch_vid(this);
			});
		});
	}
};

function changeFeatureTabTo($tabLocation){
	if (!$('#featureTab' + $tabLocation).hasClass('current')){
		$('.featuredItems').removeClass('current');
		$('#featureTab' + $tabLocation).addClass('current');
		$('.featuredItemContents').hide();
		$('#featuredItemContent' + $tabLocation).show();
	}
}

function ajaxFormValidation($formId){
	// Form Validation
	var $formId = '#' + $formId;
	$($formId + ' .required').removeClass('error');
	$($formId + ' .required').each( function(){
		var $this = $(this)
		var $val = $this.val()
		var $type = $this.attr('type')
		
		if($type == 'text'){
			if($val == ''){
				$this.addClass('error');
			}
		}else if($type == 'textarea'){
			if($val == ''){
				$this.addClass('error');
			}
		}
	});
}

function ajaxFormSubmission($formId) {
	//Form Validation
	ajaxFormValidation($formId);
		
	// Get Form Data
	var $formId = '#' + $formId;
	//var $obj = $($formId + ' input:text, ' + $formId + ' select:option:selected, ' + $formId + ' textarea, ' + $formId + ' input:radio:checked, ' + $formId + 'input:checkbox:checked, ' + $formId + ' input:hidden ').serializeArray();
	var $obj = $($formId + ' input:text, ' + $formId + ' textarea, ' + $formId + ' input:radio:checked, ' + $formId + 'input:checkbox:checked, ' + $formId + ' input:hidden ').serializeArray();
	 
	var $postString = $.param($obj);

	// Send form & on Success hide form - show thank you
	var $errors = $($formId + ' .error').length
	if($errors == 0){
		$.ajax({
				type:		"POST", 
				url:		"/script/php/ajaxsubmitformprocess.php",
				data:		$postString,
				traditional: true,
				error: "error", 
				success:	function(){
					$formHeight = $($formId).height();
					$('.ajaxFormSuccess').css({'height':$formHeight});
					$($formId).hide();
					$('.ajaxFormSuccess').show();
					
				}   
			});
	}
	return false;
}

function globalCeiling() {

	$('.pocketitemButton').hover(function(){
		$(this).addClass('pocketitemButtonHover').removeClass('pocketitemButton');
		$(this).find('ul').show();
	},function(){	
		$(this).removeClass('pocketitemButtonHover').addClass('pocketitemButton');
		$(this).find('ul').hide();
	});
}

function globalNav() {

	var timeout			= 50;
	var interval		= 50;
		 					
	var rackspaceMenu 	=  {over: showMenu,
		 					timeout: timeout,
		 					interval: interval,
		 					out: hideMenu};
		 					
	$('div.menuoption').hoverIntent(rackspaceMenu);
	
	function showMenu() {

		var menu = $(this).attr("id").replace(/menuoption/g,"menu");
		
		$(this).find('a.menuoption').addClass('menuoption-on').removeClass('menuoption-off');
		$('#'+menu).show();
	}
	
	function hideMenu() {
	
		var menu = $(this).attr("id").replace(/menuoption/g,"menu");
		
		$(this).find('a.menuoption').addClass('menuoption-off').removeClass('menuoption-on');
		$('#'+menu).hide();
	}
	
	$('.menuoption').find('a.menuoption').each(function(i,menuoptions){
		$(this).append('<div class="arrow"></div>');
	});
}

function basementSnap() {

	// snaps basement to bottom of window when window is shorter than body
	if ($('body').height() < $(window).height()) {
		$('#basement-wrap').addClass('basement-wrap-snap').removeClass('basement-wrap-nosnap');
	} else {
		$('#basement-wrap').addClass('basement-wrap-nosnap').removeClass('basement-wrap-snap');
	}

}

function launchChatWindow(IS_DID) {

	var IS_apitoken = $.ajax({url: "/includes/instantservice/postrequest.php?IS_DID="+IS_DID,async:false}).responseText;

	window.open("/includes/instantservice/chatwindow.php?IS_DID="+IS_DID+"&apitoken="+IS_apitoken,'custclient','width=500,height=320');
}

/******************************************************************************/
/*Start Country Redirect*******************************************************/

function showCountryRedirect() {
	
	var cookie = readCookie('georedirect');
	
	if (!cookie) {
	
		createCookie('georedirect','true',1);
		darkenPage();
		$('.countryRedirect').show();
	}
}

function hideCountryRedirect() {

	lightenPage();
	$('.countryRedirect').hide();
}
		
/******************************************************************************/
/*Start Home Page Carousel*****************************************************/

$carouselTimer 		= 0;	//initialize carousel timer
$carouselStageWidth	= 1580; //pixel width of carousels
$carouselInterval 	= 7; 	//time between carousel changes (seconds)
$carouselSpeed 		= 1; 	//speed of carousel changes (seconds)

function initCarousel() {

	$('.stage').each(function(){
	
		$carouselStageId 	= $(this).attr("id").replace(/stage-/g,"");
		$carouselStageClass = $(this).attr("class").replace(/stage /g,"").replace(/ active/g,"");
		
		$(this).css({'left':($carouselStageWidth * ($carouselStageId - 1))+'px'});
		
		$('#control-wrap .controls').append('<div id="control-'+$carouselStageId+'" class="control"></div>');
		$('#control-wrap .controls div').first().addClass('active');
		
		$('#headline-wrap .headlines').append('<div id="headline-'+$carouselStageId+'" class="headline '+$carouselStageClass+'"><div class="rsButton" url=\''+$(this).attr("url")+'\' target=\''+$(this).attr("target")+'\'>Learn More</div></div>');
		$('#headline-wrap .headlines div').first().addClass('active');
	});	

	$(document).ready(function(){
		enableCarouselControls();
		$carouselTimer = setInterval("swapCarousel()",$carouselInterval * 1000);
	});
}

function controlHandler() {

	disableCarouselControls();

	$nextCarousel = $(this).attr("id").replace(/control-/g,"");

	$('#control-wrap .controls .active').each(function(){
		$activeCarousel = $(this).attr("id").replace(/control-/g,"");
	});

	swapCarousel($nextCarousel,$activeCarousel);
}

function swapCarousel($nextCarousel,$activeCarousel) {

	disableCarouselControls();

	if ($nextCarousel && $activeCarousel) {
	
		clearInterval($carouselTimer);
		
	} else {
	
		$('#control-wrap .controls .active').each(function(){
			$activeCarousel = $(this).attr("id").replace(/control-/g,"");
		});

		$nextCarousel	= parseInt($activeCarousel) + 1;

		if ($nextCarousel == $('.stage').length)
			clearInterval($carouselTimer);
	}

	if ($activeCarousel != $nextCarousel) {
		
		swapCarouselControls($nextCarousel,$activeCarousel);
		swapCarouselStages($nextCarousel,$activeCarousel);
		swapCarouselHeadlines($nextCarousel,$activeCarousel);
		
	} else {
	
		enableCarouselControls();
	}
}

function swapCarouselControls($nextCarousel,$activeCarousel) {

	$('#'+getCarouselControlId($nextCarousel)).addClass('active');
	$('#'+getCarouselControlId($activeCarousel)).removeClass('active');
}

function swapCarouselStages($nextCarousel,$activeCarousel) {

	$('.stage').each(function(){
	
		$carouselStageId 	= $(this).attr("id").replace(/stage-/g,"");
		$carouselLeftPos 	= ($carouselStageWidth * $carouselStageId) - ($carouselStageWidth * $nextCarousel);
		
		$(this).animate({
			left: $carouselLeftPos+'px'
		},$carouselSpeed * 1000,'easeInOutCirc');
	});
}

function swapCarouselHeadlines($nextCarousel,$activeCarousel) {

	$headlineSpeed = ($carouselSpeed * .5) * 1000;

	$('#headline-'+$activeCarousel).animate({
		left: '-1200px'
	},$headlineSpeed);
	
	$('#headline-'+$nextCarousel).delay($headlineSpeed).animate({
		left: '0px'	
	},$headlineSpeed,function(){
		enableCarouselControls()
	});
}

function enableCarouselControls() {

	$('.control').bind('click',controlHandler);
}

function disableCarouselControls() {

	$('.control').unbind('click',controlHandler);
}

function getCarouselStageId(id) {

	return "stage-"+id;
}

function getCarouselControlId(id) {

	return "control-"+id;
}

/*End Home Page Carousel*******************************************************/
/******************************************************************************/

function printDividers() {

	$('.grid_divider_vertical').each(function(i,dividers){
		
		var containerHeight 	= $(this).parent().height();
		
		$(this).append('<div class="top part"></div>');
		$(this).append('<div class="middle part"></div>');
		$(this).append('<div class="bottom part"></div>');
		
		var dividerTopHeight 	= $(this).find('.top').height();
		var dividerBottomHeight = $(this).find('.bottom').height();
		
		$(this).height(containerHeight);
		
		if (containerHeight < (dividerTopHeight + dividerBottomHeight)) {
		
			$(this).find('.top').height(containerHeight / 2);
			$(this).find('.bottom').height(containerHeight / 2);
			$(this).find('.middle').hide();
			
			var dividerBottomPosition = (dividerBottomHeight - (containerHeight / 2)) * -1;
			$(this).find('.bottom').css('backgroundPosition','-48px '+dividerBottomPosition+'px');
			
		} else {
		
			var dividerMiddleHeight = containerHeight - (dividerTopHeight + dividerBottomHeight);
		
			$(this).find('.middle').height(dividerMiddleHeight);
		}
	});
	
	$('div.menu').hide();
	$('div.menu').css('left','-190px');
}

function constructButtons() {
	
	$('.rsOrderButton, .rsChatButton, .rsEmailButton, .rsButton, .rsButtonSmall, .rsButtonTinyGray, .rsOrderButtonTiny, .rsSignupButton').each(function(){
		
		if ($(this).hasClass('rsOrderButton')){
		
			$div = '<div class="shopping-cart"></div>';

			if ($(this).hasClass('square'))
				$html = 'Order';
			else
				$html = 'Order Now';
			
		} else if ($(this).hasClass('rsChatButton')) {
		
			$div	= '<div class="chat-bubble"></div>';
			$html	= 'Chat';
			
		} else if ($(this).hasClass('rsEmailButton')) {
		
			$div	= '<div class="email-envelope"></div>';
			$html	= 'Email';
			
		} else if ($(this).hasClass('rsButton') || $(this).hasClass('rsButtonSmall')){
		
			$div	= '<div class="arrow"></div>';
			$html 	= $(this).html();
			
		} else if ($(this).hasClass('rsButtonTinyGray') || $(this).hasClass('rsOrderButtonTiny')){
		
			$html 	= $(this).html();
			
		} else if ($(this).hasClass('rsSignupButton')) {
		
			$div	= '<div class="shopping-cart"></div>';
			$html	= 'Ready?<br/><span>Signup Now</span>';
		}
		
		$url	= $(this).attr("url");
		$target	= $(this).attr("target");
		
		$(this).html('');
		
		if ($url && $target)
			$(this).append('<a href="'+$url+'" target="'+$target+'"></a>');
		else if ($url)
			$(this).append('<a href="'+$url+'"></a>');
		else
			$(this).append('<a></a>');
		
		$anchor = $(this).find('a');
		
		$($anchor).append('<div class="side left"></div>');
		$($anchor).append('<div class="middle">'+$div+$html+'</div>');
		$($anchor).append('<div class="side right"></div>');
		$($anchor).append('<div class="clear"></div>');
	});
}

$(document).ready(function(){

	globalNav();
	globalCeiling();	
	chatSlider();
	cartSlider();
	basementSnap();
	printDividers();
	constructButtons();
	$(window).bind('scroll resize', function() {
		$(this).unbind('scroll');	// disable subsequent scroll events to not add to browser load
		basementSnap();
	});
});
