function PhoneIsValid() {
	var phone = document.getElementById( "phone" );
	if ( phone == null ) return false;
	if ( phone.value == null || phone.value == "" ) return false;
	return true;
}

function OnSubmit(e) {
	switch ( CallbackAction ) {
		case 'preview':
			alert( "This button is non-functional in Landing Page preview." );
			return false;
		case 'inactive':
			alert( "This advertisement is inactive." );
			return false;
		default:
		
		if (!PhoneIsValid()) {
			alert( "Please, enter valid phone number." );
			return false;
		}
			
		var form = document.getElementById( "__aspnetForm" );
		var features = "menubar=no,toolbar=no,location=no,directories=no,statusbar=0,copyhistory=no,width=330,height=440";
		wnd = window.open( 'about:blank', form.target, features );
		
		// cleanup ViewState
		var viewstate = document.getElementsByName( "__VIEWSTATE" )[0];
		if ( viewstate )
			viewstate.name = "NOT__VIEWSTATE__ANYMORE";
			
		form.action = CallbackAction;
		form.submit();
	}
}

function SetSrc( id, src ) {
	elt = document.getElementById(id);
	if ( elt ) 
		elt.src = src;
}

function Toggle( id, style ) {
	elt = document.getElementById(id);
	if ( elt && elt.style ) 
		elt.style.display = style;
}

function ShowPanel( id1 ) {
	Toggle( "ContentAdvertizer", "none" );
	Toggle( "ContentPublisher", "none" );
	Toggle( "ContentDefault", "none" );
	Toggle( id1, "block" );
}

function SetAppType( type )
{
	elt = document.getElementById("appType");
	if ( elt ) 
		elt.value = type;
}

function AssignActions() {
	document.getElementById("tabAdv").onclick = function() 	{
		ShowPanel( "ContentAdvertizer" );
		SetAppType("Ad");
	}
	document.getElementById("tabPub"). onclick = function() {
		ShowPanel( "ContentPublisher");
		SetAppType("Pub");
	}
	document.getElementById("tabOvw"). onclick = function() {
		ShowPanel( "ContentDefault");
	}
};

function InitTeleform() {
	DoHighlight = function() {
		window.status = "Click to be connected to ThinkingVOICE Sales";
		SetSrc("SubmitButton1","/ppl/push_to_talk_01_over.gif");
		SetSrc("SubmitButton2","/ppl/push_to_talk_02_over.gif");
	}
	DoNormal = function() {
		window.status = window.defaultStatus;
		SetSrc("SubmitButton1","/ppl/push_to_talk_01.gif");
		SetSrc("SubmitButton2","/ppl/push_to_talk_02.gif");
	}
	DoAssign = function(button) {
		button.onclick = OnSubmit;
		//button.onmouseover = DoHighlight;
		//button.onmouseout  = DoNormal;
	}
	DoAssign( document.getElementById("SubmitButton1") );
	//DoAssign( document.getElementById("SubmitButton2") );
	
	//AssignActions();
}
/*
function BetaSignup()
{
	var form = document.getElementById( "__aspnetForm" );
	form.action = "/PplSignup/advertiser.aspx"
	form.target = "_self"
	form.submit();
}*/