function goNext(the_val, field_name, form_name) {
	if (the_val.length == 3) {
			document.forms[form_name].elements[field_name].focus();
	}
}

function trackMediaplex(url, event) {
	if (event != undefined) {
		delaySubmitForMediaplex(event);
	}

	$('iframe#mpxFrame').attr({ 'src': url });
}

function delaySubmitForMediaplex(e) {
	var tagName = e.currentTarget.tagName;
	var tagID = e.currentTarget.id;
	var tag = $(tagName + '#' + tagID);

	if (tag) {
		if (tagName == 'A') {
			var href = tag[0].href
			e.preventDefault();
			$('iframe#mpxFrame').load(function() {
				document.location.href = href;
			});
		} else if (tagName == 'FORM') {
			e.preventDefault();
			tag.unbind('submit');
			$('iframe#mpxFrame').load(function() {
				tag.submit();
			});
		}
	}
}

$(document).ready(function() {
	// CE transition tag for links
	$("a[href*=comcast.com]").click(function(event) {
		CQtracker.linkClick(this, true);
	});

	$('.blink')
    .focus(function() {
    	if ($(this).attr('value') == $(this).attr('title')) {
    		$(this).attr({ 'value': '' });
    	}
    })
    .blur(function() {
    	if ($(this).attr('value') == '') {
    		$(this).attr({ 'value': $(this).attr('title') })
    	}
    });

    //Call Now Buttons
	/*
    $("a[id^=callNowCta]").click(function(event) {
    	if ($(this).hasClass('buttonSmall')) {
    		$(this).addClass('button-active-small');
    	}
    	else {
    		$(this).addClass('button-active');
    	}

    	//Omniture
    	var s = s_gi(s_account);
    	s.linkTrackVars = 'events';
    	s.linkTrackEvents = 'event4';
    	s.events = 'event4';
    	s.tl(this, 'o', '800# - Get Info');

    	logCleqConversion('3'); //CLEQ Type 3

    	trackMediaplex('http://img-cdn.mediaplex.com/0/9700/universal.html?page_name=800v1&800v1=1&mpuid=');

    	return false;
    });
	*/

	//Check Availability Form
	$('form#check-form').submit(function(event) {
		logCleqConversion('6'); //CLEQ Type 6

		trackMediaplex('http://img-cdn.mediaplex.com/0/9700/universal.html?page_name=compare_internet_page&Check_Availability=1&mpuid=', event);
	});

	//Request Consultation Button
	$('.requestConsultationLinkForLP1').click(function(event) {
		logCleqConversion('1'); //CLEQ Type 1
	
		trackMediaplex('http://img-cdn.mediaplex.com/0/9700/universal.html?page_name=jetson_landing_page&Started_Lead_Form=1&mpuid=');

		return true;
	});

	//Check Speed
	$("a[id^=checkSpeed]").click(function(event) {
		trackMediaplex('http://img-cdn.mediaplex.com/0/9700/universal.html?page_name=compare_internet_page&Used_Feature_Tool=1&mpuid=', event);
	});

	//Start Order
	$('.startOrderLink').click(function(event) {
		trackMediaplex('http://img-cdn.mediaplex.com/0/9700/universal.html?page_name=compare_internet_page&Started_Order_Form=1&mpuid=', event);

		logCleqConversion('2'); //CLEQ Type 2

		return true;
	});

	/*
	$('form#check-form').submit(function(e) {
	delaySubmitForMediaplex(e);

	trackMediaplex('http://img-cdn.mediaplex.com/0/9700/universal.html?page_name=compare_internet_page&Check_Availability=1&mpuid=');
	});
	*/

	//Check Availability Button
	/*
	$("a[id^=checkAvailablityButton]").click(function(event) {
	trackMediaplex('http://img-cdn.mediaplex.com/0/9700/universal.html?page_name=compare_internet_page&Check_Availability=1&mpuid=');

	logCleqConversion('6'); //CLEQ Type 6

	document.location.href = "http://business.comcast.com/service-availability/available-plans_possible.aspx";
	});
	*/

	//Switch to Phone
	/*
	$('.switchToPhone').click(function(event) {
	$(this).attr({ 'innerHTML': 'Please Call ' + $(this).attr('title') });

	//Omniture
	var s = s_gi(s_account);
	s.linkTrackVars = 'events';
	s.linkTrackEvents = 'event4';
	s.events = 'event4';
	s.tl(this, 'o', '800# - Get Info');

	trackMediaplex('http://img-cdn.mediaplex.com/0/9700/universal.html?page_name=800v2&800v2=1&mpuid=');

	logCleqConversion('4');  //CLEQ Type 4

	return false;
	});
	*/
});