window.onload = function() {
	doMSSRedirect();
	doGSCRedirect();
	doiDefenseRedirect();
	popup();
}

function popup() {
	var tld = document.getElementById('tld');
	if (tld) {
		tld.onclick = function() {
			window.open('http://www.verisign.com/security-intelligence-service/current-intelligence/cyber-threat-meter/index.html', 'cyberthreat_win', 'width=640,height=500,top=150,left=150,resizable,scrollbars=no','nodeId=10031');
			return false;
		}
	}
}

/** shows/hides homepage content **/
function showTab(tabid) {
    var services_tab = document.getElementById('Services_body');
    var solutions_tab = document.getElementById('Solutions_body');
    var industries_tab = document.getElementById('Industries_body');
    var this_tab = document.getElementById(tabid+'_body');
    var tab_items = document.getElementById('tab_links').getElementsByTagName("li");
    var this_link = document.getElementById(tabid+'_link');
    
    services_tab.className = 'tab_body invisible';
    solutions_tab.className = 'tab_body invisible';
    industries_tab.className = 'tab_body invisible';
    for (var i=0;tab_items[i];i++) {
        tab_items[i].className = false;
    }
    this_tab.className = 'tab_body';
    this_link.className = 'active';
}

/* Twig additions to Axiom CMS */

	// Taken from http://axiomstack.com/learn/Form_Submission_and_AJAX_Tutorial
	function feedback() {
		 return this.feedback_form();
	}
	function process_feedback() {
		 var fullname = req.data.fullname;
		 var email = req.data.email;
		 var feedback = req.data.feedback;
		 var mail = new Mail();
		 mail.setTo("feedback@mysite.com", "Feedback");
		 mail.setFrom(email, fullname);
		 mail.setSubject("Feedback Submission from " + fullname);
		 mail.addText(fullname + " submitted the following feedback:\n\n" + feedback);
		 mail.send();
		 res.write("Your Feedback was successfully submitted.");
	}

	// JG: MSS redirect hack, activated in onload
	function doMSSRedirect() {
		var re = new RegExp('/managed_security_services/.+','g');
		var url = window.location.href;
		if (url.match(re)) {
			window.location.href = '/managed_security_services';
		};
	}
	// JG: GSC redirect hack, activated in onload
	function doGSCRedirect() {
		var re = new RegExp('/global_security_consulting/.+','g');
		var url = window.location.href;
		if (url.match(re)) {
			window.location.href = '/global_security_consulting';
		};
	}
	// JG: idefense redirect hack, activated in onload
	function doiDefenseRedirect() {
		var re = new RegExp('/security_intelligence_service/?(.*)','g');
		var url = window.location.href;
		if (url.match(re)) {
			// Look for specific redirects: lazy if block :)
			if (RegExp.$1 == 'current_intelligence/') {
				window.location.href = 'http://www.verisign.com/idefense/intelligence-research/current-intelligence/';
			}
			else if (RegExp.$1 == 'information_center/') {
				window.location.href = 'http://www.verisign.com/idefense/information-center/';
				
			}
			else if (RegExp.$1 == 'intelligence_for_patch_management/') {
				window.location.href = 'http://www.verisign.com/idefense/vulnerability-management/';
				
			}
			else {
				// Catch-all
				window.location.href = 'http://www.verisign.com/idefense/';
			};
		};
	}
/* Twig additions to Axiom CMS */