var Dwin = window;
var Ddoc = document;
var Dloc = Dwin.location.toString();
ifresh();
function ge(id) {return document.getElementById(id);}
function ctn(t) {return document.createTextNode(t);}
function ce(t) {return document.createElement(t);}
var queryData = {};
function getQueryData() {
	if (Dloc.indexOf('?')!=-1) {
    	var qs = Dloc.substr(Dloc.indexOf('?')+1);
		params = qs.split('&');
		var key, value;
		for (var i=0;i<params.length;i++) {
			key = params[i].split('=')[0];
			value = params[i].split('=')[1];
			queryData[key] = value;
		}
	}
}
getQueryData();
var phonesData, userData, displayPhoneNum, displayPhoneId, myAOLMobileURL;
var dropdownform1 = 'dropdownform';
var selectedcar1 = 'carid';
var selectedmanu1 = 'mfid';
var selectedphone = 'selectUserPhones';
var displayPhoneIndex = 1;
var nullstring = '';
var agent = navigator.userAgent.toLowerCase();
if (queryData['application']) var applicationPage = queryData['application'];
function ApplicationGroup(title, grouptitle, url, applications, shopURL) {
	this.title = title;
	this.grouptitle = grouptitle;
	this.url = url;
	this.applications = applications;
	this.shopURL = shopURL;
}
function Application(title, url, service_name, imgLink, text, topAppName, topAppURL) {
	this.title = title;
	this.url = url;
	this.status = status;
	this.imgLink = imgLink;
	this.text = text;
	this.service_name = service_name;
	this.topAppName = topAppName;
	this.topAppURL = topAppURL;
}
var applicationGroups = {
'MobileAIM': new ApplicationGroup('Mobile AIM®','Mobile AIM® on this Phone','/mobileaim',[1,10,11,13,70],'Device/DeviceFinder.aspx?AolFeatureId=54778'),
'MobileAIMMail': new ApplicationGroup('Mobile AIM® Mail','Mobile AIM® Mail on this Phone','/mobilemail/aimmail',[81],'/Device/DeviceFinder.aspx?AolFeatureId=55494'),
'MobileAOLMail': new ApplicationGroup('Mobile AOL® Mail','Mobile AOL® Mail on this Phone','/mobilemail',[21,22,24],'Device/DeviceFinder.aspx?AolFeatureId=54779'),
'SmartPhonesPDA': new ApplicationGroup('SmartPhone or PDA','For SmartPhone or PDA','/smartphone_pda',[31,30,32,33]),
'MapquestMobile': new ApplicationGroup('MapQuest® Mobile','MapQuest® on this Phone','/mapquest/mapquestmobile',[18,7,9,19],'Device/devicefinder.aspx?AolFeatureId=54402'),
'MapquestNavigator': new ApplicationGroup('MapQuest® Navigator','MapQuest® Navigator on this Phone','/mapquest/mapquestnavigator',[18,7,9,19]),
'MapquestFindMe': new ApplicationGroup('MapQuest® FindMe','MapQuest® on this Phone','/mapquest/mapquestfindme',[18,7,9,19],'Device/devicefinder.aspx?AolFeatureId=54404'),
'MapquestWAP': new ApplicationGroup('MapQuest® For Small Screens','MapQuest® on this Phone','/mapquest/mapquestwap',[18,7,9,19],'Device/devicefinder.aspx?AolFeatureId=55493'),
'CityGuide': new ApplicationGroup('CityGuide Mobile','CityGuide Mobile on this Phone','/cityguide',[52],'Device/DeviceFinder.aspx?AolFeatureId=54930'),
'Moviefone': new ApplicationGroup('Moviefone® Mobile','Moviefone® Mobile on this Phone','/moviefone',[62],'Device/DeviceFinder.aspx?AolFeatureId=54931'),
'Alerts': new ApplicationGroup('Alerts','Alerts on this Phone','/ar/alerts',[15],'Device/DeviceFinder.aspx?AolFeatureId=54406'),
'Reminders': new ApplicationGroup('Reminders','Reminders on this Phone','/ar/reminders',[16],'Device/DeviceFinder.aspx?AolFeatureId=54401'),
'WAP': new ApplicationGroup('Mobile Web','Mobile Web','/portal',[40,44,45,43,42],'Device/DeviceFinder.aspx?AolFeatureId=54400'),
'Search': new ApplicationGroup('Mobile Web','Mobile Web','/portal/search',[40,44,45,43,42],'Device/DeviceFinder.aspx?AolFeatureId=54405'),
'Pictures': new ApplicationGroup('Mobile Web','Mobile Web','/portal/pictures',[40,44,45,43,42],'Device/DeviceFinder.aspx?AolFeatureId=54932'),
'RSSReader': new ApplicationGroup('Mobile Web','Mobile Web','/portal/mobile-feed-reader',[40,44,45,43,42]),
'AIMPages': new ApplicationGroup('Mobile Web','Mobile Web','/portal/mobile-aim-pages',[40,44,45,43,42])
}
var applicationPages = {
'/mobileaim':'MobileAIM',
'/mobilemail':'MobileAOLMail',
'/aimmail':'MobileAIMMail',
'/smartphone_pda':'SmartPhonesPDA',
'/mapquestnavigator':'MapquestNavigator',
'/mapquestmobile':'MapquestMobile',
'/mapquestfindme':'MapquestFindMe',
'/mapquestwap':'MapquestWAP',
'/alerts':'Alerts',
'/reminders':'Reminders',
'/portal':'WAP',
'/search':'Search',
'/pictures':'Pictures',
'/do_more':'none',
'/domore':'none',
'/cityguide':'CityGuide',
'/moviefone':'Moviefone',
'/mobile-feed-reader':'RSSReader',
'/mobile-aim-pages':'AIMPages'
}
var applications = {
1 : new Application('Software Installed',
	'/mobileaim/installed',
	'AIM® Client', 
	'http://cdn.digitalcity.com/mobile/icon_aim.gif', 
	'Take Instant Messaging with you wherever you go!',
	'Mobile AIM®',
	'/mobileaim'),
70 : new Application('T9: Text Faster, Text Further',
	'/mobileaim/t9','T9'),
10 : new Application('Software Downloadable',
	'/mobileaim/downloadable',
	'AIM® Client Downlodable'),
//51 : new Application('Software Downloadable',
	//'/cityguide/downloadable',
	//'CityGuide Mobile Downlodable'),
//61 : new Application('Software Downloadable',
	//'/moviefone/downloadable',
	//'Moviefone® Mobile Downlodable'),
11 : new Application('Through Web Browser',
	'/mobileaim/browser',
	'AIM® WAP 1'),
13 : new Application('Forward IMs to Cell',
	'/mobileaim/forwardims',
	'1-way text messaging'),
14 : new Application('Through Text Messaging',
	'/mobileaim/textmessaging',
	'2-way text messaging'),
7 : new Application('MapQuest® Mobile',
	'/mapquest/mapquestmobile',
	'Mapquest® Mobile',
	'http://cdn.digitalcity.com/mobile/icon_mapquest.gif',
	'Stay on the go with interactive maps and step-by-step driving directions.',
	'MapQuest®',
	'/mapquest/mapquestmobile'),
8 : new Application('MapQuest® Traffic',
	'/mapquest/mapquesttraffic',
	'Mapquest® Traffic'),
9 : new Application('MapQuest® FindMe',
	'/mapquest/mapquestfindme',
	'Mapquest® Find Me'),
20 : new Application('Software Installed',
	'/mobilemail/installed',
	'Mail Client', 
	'http://cdn.digitalcity.com/mobile/icon_mail.gif',
	'Send and receive your AOL® Mail on your cell phone.',
	'Mobile AOL® Mail',
	'/mobilemail'),
21 : new Application('Software Downloadable',
	'/mobilemail/downloadable',
	'Mail Client Downloadable'),
22 : new Application('Through Web Browser',
	'/mobilemail/browser',
	'Mail WAP 1'),
24 : new Application('Through IMAP',
	'/mobilemail/imap',
	'IMAP Email'),
30 : new Application('Mobile AIM® Software',
	'/smartphone_pda/aimsoftware',
	'AIM® Smartphones'),
31 : new Application('Mobile AOL® Software',
	'/smartphone_pda/aolsoftware',
	'AOL® Client Smartphones'),
32 : new Application('Sync',
	'/smartphone_pda/sync',
	'PDA Sync'),
33 : new Application('Software Store',
	'/smartphone_pda/softwarestore',
	'Smartphone Software'),
40 : new Application('AOL® Mobile Web',
	'/portal',
	'WAP 1 Portal'),
42 : new Application('Mobile Search Services',
	'/portal/search',
	'WAP 2 Mobile Search'),
43 : new Application('AOL® Pictures',
	'/portal/pictures',
	'WAP 2 AOL® Pictures'),
44 : new Application('AOL® Mobile Feed Reader',
	'/portal/mobile-feed-reader',
	'AOL® Mobile Feed Reader'),
45 : new Application('AIM Pages',
	'/portal/mobile-aim-pages',
	'WAP 2 AIM Pages'),
15 : new Application('Alerts',
	'/ar/alerts',
	'1-way text messaging', 
	'http://cdn.digitalcity.com/mobile/wdt_alert', 
	'Get up-to-the-minute news, sports scores, weather and stock quotes.',
	'AOL® Mobile Alerts',
	'/alerts'),
16 : new Application('Reminders',
	'/ar/reminders',
	'1-way text messaging', 
	'http://cdn.digitalcity.com/mobile/wdt_mails',
	'Never forget an important date again!',
	'AOL® Mobile Reminders',
	'/reminders'),
18 : new Application('MapQuest® Navigator',
    	'/mapquest/mapquestnavigator',
	'Mapquest® Navigator'),
19 : new Application('MapQuest® for Small Screens',
    	'/mapquest/mapquestwap',
    	'Mapquest® For Small Screens'),	
81 : new Application('Software Downloadable',
	'/mobilemail/aimmail/downloadable',
	'AIM® Client'),
90 : new Application('Mobile AIM®',
	'/mobileaim/installed',
	'AIM® Client', 
	'http://cdn.digitalcity.com/mobile/icon_aim.gif', 
	'Take Instant Messaging with you wherever you go!',
	'Mobile AIM®',
	'/mobileaim'),
91 : new Application('Mobile AOL® Mail',
	'/mobilemail/installed',
	'Mail Client', 
	'http://cdn.digitalcity.com/mobile/icon_mail.gif',
	'Send and receive your AOL® Mail on your cell phone.',
	'Mobile AOL® Mail',
	'/mobilemail'),
52 : new Application('Through Web Browser',
	'/cityguide/browser',
	'Cityguide WAP 1'),
62 : new Application('Through Web Browser',
	'/moviefone/browser',
	'Moviefone WAP 1')
}
var carrierPageURLs = {
16:'/carriercentral/alltel',
23:'/carriercentral/boostmobile',
26:'/carriercentral/cellularsouth',
2:'/carriercentral/cingularwireless',
18:'/carriercentral/cricket',
19:'/carriercentral/hawaiianwireless',
21:'/carriercentral/libertywireless',
25:'/carriercentral/metropcs',
9:'/carriercentral/nextel',
10:'/carriercentral/sprint',
3:'/carriercentral/tmobile',
17:'/carriercentral/uscellular',
14:'/carriercentral/verizon',
20:'/carriercentral/virginmobile',
22:'/carriercentral/wcom',
24:'/carriercentral/westernwireless',
4:'/carriercentral'
}
var topApplications = new Array();
topApplications[1] = 90;
topApplications[2] = 91;
topApplications[3] = 7;

for (url in applicationPages) {
	if (Dloc.indexOf(url)!=-1) {
		applicationPage = applicationPages[url];
	}
}

function listTopApplications(apps,status) {
	var output = ce('table');
	var tbody = ce('tbody');
	output.appendChild(tbody);
	var td, tr, a, statusIcon, app, img;
    for (k in apps) {
	app = applications[apps[k]];
	tr = ce('tr');    
	tbody.appendChild(tr);
	//create image
	td = ce('td');
	td.className = 'dt1';
	a = ce('a');
	a.href=app.topAppURL;
	td.appendChild(a);
	img = ce('img');
	if (app.imgLink!=null){
		img.src=app.imgLink;
		a.appendChild(img);
	}
    tr.appendChild(td);
	//create link
	td = ce('td');
	td.className = 'dt2';
	a = ce('a');
	a.href=app.topAppURL;
	a.className='lnk';
	a.innerHTML=app.topAppName;
	td.appendChild(a);
	lbl = ce('label');
	lbl.appendChild(ctn(app.text));
	td.appendChild(lbl);
    tr.appendChild(td);
	//create check
	td = ce('td');
	td.className = 'dt3';
	if (status[apps[k]]==0) {
		
	} else if (status[apps[k]]==1) {
		statusIcon = ce('img');
		statusIcon.src = 'http://cdn.digitalcity.com/mobile/check';
		td.appendChild(statusIcon);
	} else if (status[apps[k]]==2) {
		statusIcon = ce('img');
		statusIcon.src = 'http://cdn.digitalcity.com/mobile/coming_soon';
		td.appendChild(statusIcon);
	}
	tr.appendChild(td);
	td = ce('td');
	td.className = 'dt4';
		if (status[apps[k]]==1) {
		}
		else if (status[apps[k]]==2) {
			
		} else {
			statusLink = ce('a');
			statusLink.href = "javascript:findPhone('"+apps[k]+"','"+app.title+"','"+app.url+"');";
			td.appendChild(statusLink);
			statusIcon = ce('img');
			statusIcon.src = 'http://cdn.digitalcity.com/mobile/find_phone';
			statusLink.appendChild(statusIcon);
		}
        tr.appendChild(td);
    }
	return output;
}

function listApplications(apps,status) {
	var output = ce('table');
	var tbody = ce('tbody');
	output.appendChild(tbody);
	var td, tr, statusIcon, app, a;
    for (k in apps) {
		app = applications[apps[k]];
		tr = ce('tr');
		tbody.appendChild(tr);
		td = ce('td');
		td.className = 'dt1';//*** adding class name for td
		if (status[apps[k]]==0) {
			
		} else if (status[apps[k]]==1) {
			statusIcon = ce('img');
			statusIcon.src = 'http://cdn.digitalcity.com/mobile/check';
			td.appendChild(statusIcon);
		} else if (status[apps[k]]==2) {
			statusIcon = ce('img');
			statusIcon.src = 'http://cdn.digitalcity.com/mobile/coming_soon';
			td.appendChild(statusIcon);
		}
        tr.appendChild(td);
		td = ce('td');
		td.className = 'dt2';//*** adding class name for td
		a = ce('a');
		a.href = app.url;
		a.appendChild(ctn(app.title));
		td.appendChild(a);
        tr.appendChild(td);
		td = ce('td');
		td.className = 'dt3';//*** adding class name for td
		if (status[apps[k]]==1) {
		} else if (status[apps[k]]==2) {
			
		} else {
			statusLink = ce('a');
			statusLink.href = "javascript:findPhone('"+apps[k]+"','"+app.title+"','"+app.url+"')";
			td.appendChild(statusLink);
			statusIcon = ce('img');
			statusIcon.src = 'http://cdn.digitalcity.com/mobile/find_phone';
			statusLink.appendChild(statusIcon);
		}
        tr.appendChild(td);
    }
	return output;
}

var imonoffDisplay = {
'false':'Off',
'true':'On'
}

var mobprivacyDisplay = {
'false':'Forwarding OFF',
'6':'Mobile Group',
'5':'Buddy List',
'7':'Buddy List+',
'1':'All'
}

function confirmButton() {
	if (displayPhoneId!='9999') window.location = applicationBase+'confirm.do?confirmphone_no='+displayPhoneNum+'&ret_url='+escape(Dloc);
	else window.location = applicationBase+'newregister.do?carid='+userData['selectedPhone'].carrierid+'&mfid='+userData['selectedPhone'].manufid+'&mdid='+userData['selectedPhone'].modelid+'&previewFlag=Y&ret_url=' + escape(Dloc);
}

function findPhone(k,service_name,url) {
	var target = applicationBase + 'findphone.do?serviceid='+k+'&servicename='+service_name+'&ret_url='+escape(bigbowlBase+url);
	window.open(target,'PhoneFinder','dependent=1,modal=1,dialog=1,close=0,left=300,top=75,toolbar=0,directories=0,location=0,menubar=0,fullscreen=0,hotkeys=0,titlebar=0,status=0,height=600,width=585,resizable=0');
}

function openAllDeliverPop(){
	if (typeof userData['settings']!='undefined' && userData['settings'].isselphoneconfirmed!='false') window.open(alertsBase + '/ar/prefs/index.ev?cp=awmrhdp','Settings');
	else {
		if(typeof queryData['fromTriton'] !='undefined' && queryData['fromTriton']=='Y'){
			//triton_confirmPhone();
			toggleLayer('anchorImg','loginLayer',5,10,lu);			
		}
		else{
			//confirmButton();
			toggleLayer('anchorImg','loginLayer',5,10,lu);						
		}
	}
}

function showVacationPop(){
	if (typeof userData['settings']!='undefined' && userData['settings'].isselphoneconfirmed!='false') window.open(alertsBase + '/ar/prefs/edit_schedule.ev','Settings','width=825,height=500,scrollbars=1,screenX=100,screenY=75,left='+((screen.width-825)/2)+',top='+ ((screen.height-500)/2));
	else {
		if(typeof queryData['fromTriton'] !='undefined' && queryData['fromTriton']=='Y'){
			//triton_confirmPhone();
			toggleLayer('anchorImg','loginLayer',5,10,lu);
		}
		else{
			//confirmButton();
			toggleLayer('anchorImg','loginLayer',5,10,lu);
		}
	}
}

function showPrivacyPop(){
	if (typeof userData['settings']!='undefined' && userData['settings'].isselphoneconfirmed!='false') window.open(applicationBase+'mobprpop.do?mbp='+userData['settings'].mobprivacy+'&action=Edit&FromDashBoard=Y','Settings','width=615,height=250,scrollbars=1,screenX=100,screenY=75,left='+((screen.width-615)/2)+',top='+((screen.height-400)/2));
	else {
		if(typeof queryData['fromTriton'] !='undefined' && queryData['fromTriton']=='Y'){
			//triton_confirmPhone();
			toggleLayer('anchorImg','loginLayer',5,10,lu);
		}
		else{
			//confirmButton();
			toggleLayer('anchorImg','loginLayer',5,10,lu);
		}
	}
}

function showQuietTimePop(){
	if (typeof userData['settings']!='undefined' && userData['settings'].isselphoneconfirmed!='false') window.open(alertsBase + '/ar/prefs/edit_schedule.ev','Settings');
	else {
		if(typeof queryData['fromTriton'] !='undefined' && queryData['fromTriton']=='Y'){
			//triton_confirmPhone();
			toggleLayer('anchorImg','loginLayer',5,10,lu);
		}
		else{
			//confirmButton();
			toggleLayer('anchorImg','loginLayer',5,10,lu);
		}
	}
}

function showAlertPop(){
	if (typeof userData['settings']!='undefined' && userData['settings'].isselphoneconfirmed!='false') window.open(alertsBase + '/ar/alerts/index.ev','Settings');
	else {
		if(typeof queryData['fromTriton'] !='undefined' && queryData['fromTriton']=='Y'){
			//triton_confirmPhone();
			toggleLayer('anchorImg','loginLayer',5,10,lu);
		}
		else{
			//confirmButton();
			toggleLayer('anchorImg','loginLayer',5,10,lu);
		}
	}
}

function showRemindersPop(){
	if (typeof userData['settings']!='undefined' && userData['settings'].isselphoneconfirmed!='false') window.open(alertsBase + '/ar/reminders/index.ev?cp=awmahr','Settings');	
	else {
		if(typeof queryData['fromTriton'] !='undefined' && queryData['fromTriton']=='Y'){
			//triton_confirmPhone();
			toggleLayer('anchorImg','loginLayer',5,10,lu);
		}
		else{
			//confirmButton();
			toggleLayer('anchorImg','loginLayer',5,10,lu);
		}
	}
}

function showIMFPop() {    
	if (typeof userData['settings']!='undefined' && userData['settings'].isselphoneconfirmed!='false') {
		if (userData['settings'].imonoff=='false') { //IM is OFF at this point
		//	if_refresh(pipeURL+'?phone_id='+displayPhoneId+'&selPr=5&imf=false&redirectURL='+pipeURL+'&rc=true');
			window.open(applicationBase+'mobprpop.do?mbp='+userData['settings'].mobprivacy+'&action=Off' + '&FromDashBoard=Y','Privacy','width=500,height=300,screenX=100,screenY=75,left='+((screen.width-590)/2)+',top='+((screen.height-400)/2));
		}
		else { //IM is ON at this point
			//var IMPopupCookie = readCookie('IMFORWARDPOPUP');
			//var settings = userData['settings'];
			if ( userData['selectUserPhones'] == null) window.location = applicationBase + 'newregister.do';
			else {			
			//	if (IMPopupCookie != 'Y'){
					window.open(applicationBase+'mobprpop.do?mbp='+userData['settings'].mobprivacy+'&action=ON' + '&FromDashBoard=Y','Privacy','width=500,height=300,screenX=100,screenY=75,left='+((screen.width-590)/2)+',top='+((screen.height-400)/2));
			//	}
			//	else {
			//		if_refresh(pipeURL+'?phone_id='+displayPhoneId+'&imf=true&redirectURL='+pipeURL+'&rc=true');
			//	}
			}
		}
	} else {
			if(typeof queryData['fromTriton'] !='undefined' && queryData['fromTriton']=='Y'){
				//triton_confirmPhone();
				toggleLayer('anchorImg','loginLayer',5,10,lu);
			}
			else{
				toggleLayer('anchorImg','loginLayer',5,10,lu);				
				//confirmButton();
			}
	}
}
/*
function showIMFPop() {
	if (typeof userData['settings']!='undefined' && userData['settings'].isselphoneconfirmed!='false') {
		if (userData['settings'].imonoff=='false') { //IM is OFF at this point
		//	if_refresh(pipeURL+'?phone_id='+displayPhoneId+'&selPr=5&imf=false&redirectURL='+pipeURL+'&rc=true');
			window.open(applicationBase+'mobprpop.do?mbp='+userData['settings'].mobprivacy+'&action=Off' + '&FromDashBoard=Y','Privacy','width=500,height=300,screenX=100,screenY=75,left='+((screen.width-590)/2)+',top='+((screen.height-400)/2));
		}
		else { //IM is ON at this point
			//var IMPopupCookie = readCookie('IMFORWARDPOPUP');
			//var settings = userData['settings'];
			if ( userData['selectUserPhones'] == null) window.location = applicationBase + 'newregister.do';
			else {			
			//	if (IMPopupCookie != 'Y'){
					window.open(applicationBase+'mobprpop.do?mbp='+userData['settings'].mobprivacy+'&action=ON' + '&FromDashBoard=Y','Privacy','width=500,height=300,screenX=100,screenY=75,left='+((screen.width-590)/2)+',top='+((screen.height-400)/2));
			//	}
			//	else {
			//		if_refresh(pipeURL+'?phone_id='+displayPhoneId+'&imf=true&redirectURL='+pipeURL+'&rc=true');
			//	}
			}
		}
	} else {
			if(typeof queryData['fromTriton'] !='undefined' && queryData['fromTriton']=='Y'){
				//alert("In triton_confirmPhone");
				window.open(applicationBase+'mobprpop.do?mbp=1&action=Off' + '&FromDashBoard=Y','Privacy','width=500,height=300,screenX=100,screenY=75,left='+((screen.width-590)/2)+',top='+((screen.height-400)/2));
				//triton_confirmPhone();
			}
			else{
				//alert("In confirmButton");
				window.open(applicationBase+'mobprpop.do?mbp=1&action=Off' + '&FromDashBoard=Y','Privacy','width=500,height=300,screenX=100,screenY=75,left='+((screen.width-590)/2)+',top='+((screen.height-400)/2));
				//confirmButton();
			}
	}
}
*/
function showIMPop(){
	if (typeof userData['settings']!='undefined' && userData['settings'].isselphoneconfirmed!='false') {
		var imonoff, im2smsonoff;
		if (userData['settings'].imonoff == 'true') imonoff = "ON";
		else imonoff = "OFF";
		if (userData['settings'].im2smsonoff == 'true') im2smsonoff = "ON";
		else im2smsonoff = "OFF";
		window.open(applicationBase + "mobaimmanagerpop.jsp?mbp=" + userData['settings'].mobprivacy + "&imf=" + imonoff + "&im2sms=" + im2smsonoff,'Settings','width=500,height=300,screenX=100,screenY=75,scrolling=1,left='+((screen.width-630)/2)+',top='+((screen.height-260)/2));	
	} else {
			if(typeof queryData['fromTriton'] !='undefined' && queryData['fromTriton']=='Y'){
				//triton_confirmPhone();
				toggleLayer('anchorImg','loginLayer',5,10,lu);
			}
			else{
				//confirmButton();
				toggleLayer('anchorImg','loginLayer',5,10,lu);
			}
	}
}

function listSettings(settings) {
	if (ge('IMStatus') && userData['settings']) {
		var IMstatusDisplay;
		if (userData['settings'].isselphoneconfirmed=='false'){
			IMstatusDisplay = "Not Set";
		} else if (userData['settings'].im2smsonoff=='false') {	
			if (userData['settings'].imonoff=='true' && userData['settings'].mobprivacy == '1') {
				IMstatusDisplay = "Screen Name";
			} else if (userData['settings'].imonoff=='true' && (userData['settings'].mobprivacy == '5' || userData['settings'].mobprivacy == '7')) {
				IMstatusDisplay = "Buddy List";
			} else if (userData['settings'].imonoff=='true' && userData['settings'].mobprivacy == '6') {
				IMstatusDisplay = "Mobile Device Group";
			} else {
				IMstatusDisplay = "No one";
			}
		} else {
			if (userData['settings'].imonoff=='true' && userData['settings'].mobprivacy == '1') {
				IMstatusDisplay = "Mobile Number & Screen Name";
			} else if (userData['settings'].imonoff=='true' && (userData['settings'].mobprivacy == '5' || userData['settings'].mobprivacy == '7')) {
				IMstatusDisplay = "Mobile Number & Buddy List";
			} else if (userData['settings'].imonoff=='true' && userData['settings'].mobprivacy == '6') {
				IMstatusDisplay = "Mobile Number & Mobile Device Group";
			} else {
				IMstatusDisplay = "Mobile Number";
			}
		}
		ge('IMStatus').innerHTML = IMstatusDisplay;
	}
	if (ge('IMFstatus')) {
		if ((settings['isselphoneconfirmed']!=null && settings['isselphoneconfirmed']=='false') || userData['selectedPhone'].phoneid == '9999') {
			//ge('IMFoff').style.display='none';
			ge('IMFstatus').innerHTML = 'Not Set';
			//ge('IMFon').style.display='block';
		} else {
			ge('IMFstatus').innerHTML = imonoffDisplay[settings['imonoff']];
			//if (settings['imonoff']=='true') {
			//	ge('IMFon').style.display='none';
			//	ge('IMFoff').style.display='block';
			//} else {
			//	ge('IMFoff').style.display='none';
			//	ge('IMFon').style.display='block';
			//}		
		}
	}
	if (ge('PrivacyStatus')) {
		// possible value: All, Buddy List, Mobile Device GRoup, Buddy List+, IM Forwarding OFF
		if (settings['isselphoneconfirmed']!=null && settings['isselphoneconfirmed']=='false' || userData['selectedPhone'].phoneid == '9999') ge('PrivacyStatus').innerHTML = 'Not Set';
		else if (userData['settings'].imonoff=='false') ge('PrivacyStatus').innerHTML = 'Forwarding Off';
		else ge('PrivacyStatus').innerHTML = mobprivacyDisplay[settings['mobprivacy']];
		ge('PrivacyStatus').className = 'mobilePrivacy'
		ge('MPFedit').style.display='block';
	}
	if (ge('Alerts')) {
		// possible value: integer - number of alerts user has setup
		if (settings['isselphoneconfirmed']!=null && settings['isselphoneconfirmed']=='false' || userData['selectedPhone'].phoneid == '9999') ge('Alerts').innerHTML = 'Not Set';
		else ge('Alerts').innerHTML = settings['alertcount'];
		ge('Alerts').className = 'alerts'
		ge('alertview').style.display='block';
	}
	if (ge('Reminders')) {
		// possible value: integer - number of alerts user has setup
		if (settings['isselphoneconfirmed']!=null && settings['isselphoneconfirmed']=='false' || userData['selectedPhone'].phoneid == '9999') ge('Reminders').innerHTML = 'Not Set';
		else ge('Reminders').innerHTML = settings['remindercount'];
		ge('Reminders').className = 'reminders'
		ge('remindersview').style.display='block';
	}
	if (ge('QuietTime')) {
		// possible value: integer - number of alerts user has setup
		if (settings['isselphoneconfirmed']!=null && settings['isselphoneconfirmed']=='false' || userData['selectedPhone'].phoneid == '9999') ge('QuietTime').innerHTML = 'Not Set';
		else if (settings['qtime']=='false' || settings['qtime']=='') ge('QuietTime').innerHTML = 'Off';
		else ge('QuietTime').innerHTML = settings['qtime'];
		ge('QuietTime').className = 'quiettime'
		ge('quiettimeedit').style.display='block';
	}
}

function FillUpManuf(carriers,formID,carrTag,manuTag,sel_id){
	var manuf_sel = document.forms[formID].elements[manuTag].selectedIndex;
	var pre_manuf = null;
	if (manuf_sel > 0) pre_manuf = document.forms[formID].elements[manuTag].options[manuf_sel].value;
	else if (sel_id != null && sel_id != '') pre_manuf = sel_id;
	var sel = document.forms[formID].elements[carrTag].selectedIndex;
	document.forms[formID].elements[manuTag].length = 1; 
	document.forms[formID].elements[manuTag].options[0].text = 'Select manufacturer';
	document.forms[formID].elements[manuTag].options[0].value = '';
	document.forms[formID].elements[manuTag].selectedIndex = 0;
	if (sel > 0) {	
		document.forms[formID].elements[manuTag].length = carriers[sel - 1].length + 1;
		for (var i = 0; i < carriers[sel - 1].length; i++) {
			document.forms[formID].elements[manuTag].options[i + 1].text = carriers[sel - 1].manuf_name[i];
			document.forms[formID].elements[manuTag].options[i + 1].value = carriers[sel - 1].manuf_id[i];
			if (pre_manuf != null && pre_manuf == carriers[sel - 1].manuf_id[i]) document.forms[formID].elements[manuTag].selectedIndex = i + 1;
		}
	} 		
}

function FillUpCarrier(carriers, formID, carrTag, sel_id){
	document.forms[formID].elements[carrTag].length = carriers.length + 1;	
	document.forms[formID].elements[carrTag].options[0].text = 'Select carrier';
	document.forms[formID].elements[carrTag].options[0].value = '';
	document.forms[formID].elements[carrTag].selectedIndex = 0;
	for (var i = 0; i < carriers.length; i++) {
		document.forms[formID].elements[carrTag].options[i + 1].text = carriers[i].carrier_name;
		document.forms[formID].elements[carrTag].options[i + 1].value = carriers[i].carrier_id;
		if (sel_id != null && sel_id == carriers[i].carrier_id) document.forms[formID].elements[carrTag].selectedIndex = i + 1;
	} 		
}

function if_refresh(target,phoneid) {
	if (ge('dataPipe')) {
	if (ge('selectUserPhones').value=='add'){
		if(typeof queryData['fromTriton'] !='undefined' && queryData['fromTriton']=='Y'){		
			triton_AddPhone();
		}
		else{
			addPhone();
		}		
	}		
	else {
		if (phoneid) target = target + '?phone_id=' + phoneid
		if (queryData['rc']=='true' && target.indexOf('rc=true')==-1) {
			if (target.indexOf('?')==-1) {
				target = target + '?rc=true';
			} else {
				target = target + '&rc=true';
			}
		}
		var f = ge('dataPipe');
		var fDoc;
        if (f.contentDocument) { //NS6
     	   	fDoc = f.contentDocument;
      	   	fDoc.location.replace(target);
    	} else if (f.contentWindow) { //IE 5.5+
           	fDoc = f.contentWindow.document;
           	fDoc.location.replace(target);
    	} else { //NN7
           	var urlStr = target;
	   		f.src = urlStr;
    	}
	}
	}
}

function if_callback(data) {	
	if_loaded = true;
	userData = data;		
	loadAppStatus();
	if (ge('doMoreTitle') && data['selectedPhone']) {
		if (data['selectedPhone'].manufname && data['selectedPhone'].modelname) ge('doMoreTitle').innerHTML = "AOL Applications for the <span>" + data['selectedPhone'].manufname + " " + data['selectedPhone'].modelname + "</span>";
		else ge('doMoreTitle').innerHTML = "AOL Applications";
	}	
	if (data['authStatus']=='none') {
	//	ge('authDefault').style.display = 'none';
	//	ge('authNone').style.display = 'block';
	//	if (!applicationPage) ge('authNoneApps').style.display = 'block';
	//  phonesData = data['carrierList'];
	//  FillUpCarrier(phonesData, 'dropdownform', selectedcar1, '');
	} else if (data['authStatus']=='cookie' || data['authStatus']=='registered') {
	//	ge('authNone').style.display = 'none';
	//	ge('authNoneApps').style.display = 'none';
		//ge('authDefault').style.display = 'block';
		if (ge('phoneLink1') && data['selectedPhone'].phoneid) ge('phoneLink1').href=data['selectedPhone'].phoneid;
		//if (ge('phoneImage') && data['selectedPhone'].phoneimgurl) ge('phoneImage').src=phoneImageURL + data['selectedPhone'].phoneimgurl;
		//else if (typeof data['selectedPhone'].phoneimgurl=='undefined') ge('phoneImage').src='http://cdn.digitalcity.com/mobile/default_phone2';
		if (data['selectedPhone'].manufname && ge('phoneLink2') && data['selectedPhone'].modelname) {			
			//ge('manfLink2').innerHTML= data['selectedPhone'].manufname;
			//ge('phoneLink2').innerHTML= data['selectedPhone'].modelname;
			//ge('manfLink2').style.display='block';
			//ge('phoneLink2').style.display='block';
		} else if((typeof data['fromTriton'] !='undefined' && data['fromTriton']=='Y') || (typeof queryData['fromTriton'] !='undefined' && queryData['fromTriton']=='Y')){
			//ge('manfLink2').innerHTML= "<a class='model' href='javascript:triton_modifyPhone();'>Select your <br>phone model</a>";
			//ge('phoneLink2').style.display='none';
		}
		else{
			//ge('manfLink2').innerHTML= "Select your <br>phone number";
			//ge('phoneLink2').style.display='none';
		}
		if (ge('carrierLink') && data['selectedPhone'].carriername) {
			//ge('carrierLink').innerHTML=data['selectedPhone'].carriername;
			//ge('carrierLink').style.display='block';
		} else //ge('carrierLink').style.display='none';
		if (ge('carrierLink') && data['selectedPhone'].carrierid) ge('carrierLink').href=carrierPageURLs[data['selectedPhone'].carrierid];
		//if (ge('confirmphone') && data['settings'] && data['settings'].isselphoneconfirmed=='false') //ge('confirmphone').style.display='block';
		//else ge('confirmphone').style.display='none';
		// Render Phone number selectbox
		var preview=-1;
		var selected=-1;
		if (ge('selectUserPhones') && data['selectUserPhones']) {
			//ge('selectUserPhones').length = data['selectUserPhones'].length;
			//ge('selectUserPhones').options[0].text = 'Add a phone';
			//ge('selectUserPhones').options[0].value = 'add';
			/*
			for (var i = 0; i < data['selectUserPhones'].length; i++) {
				ge('selectUserPhones').options[i].text = data['selectUserPhones'][i]['phonenumber'];
				ge('selectUserPhones').options[i].value = data['selectUserPhones'][i]['phoneid'];
				if (data['selectedPhone']['phoneid']==data['selectUserPhones'][i]['phoneid']){
					displayPhoneIndex = i;
					displayPhoneId = data['selectUserPhones'][i]['phoneid'];
					if (displayPhoneId!='9999') displayPhoneNum = data['selectUserPhones'][i]['phonenumber'];
					else displayPhoneNum = -1;
				}
			}
			*/
			//ge('selectUserPhones').selectedIndex = displayPhoneIndex;
		}
		/*
		if (displayPhoneNum == -1) {
			//ge('registerphone').style.display='block';
			//ge('registerphonetext').style.display='block';
		}
		else {
			//ge('registerphone').style.display='none';
			//ge('registerphonetext').style.display='none';
		}
		*/
		// Applications Legend
		if (ge('phoneLegen') && typeof ApplicationPage=='undefined') ge('myaolmobile').src = 'http://cdn.digitalcity.com/mobile/legend_wide_3';
		// Render Settings Block
		if (data['authStatus']=='registered' || data['authStatus']=='cookie' && ge('regSettings')) {			
   	 		var settings;
			typeof data['settings']!='undefined' ? settings = data['settings'] : settings = '';
			listSettings(settings);
			ge('regSettings').style.display = 'block';
		} else {			
			ge('regSettings').style.display = 'block';
		}
		// Render Applications List Block (for applications pages).  Note that the applicationPage variable should match an applicationsGroup key.
		if (applicationPage && applicationPage!='none' && applicationGroups[applicationPage]) {
	    		var appTable = ge('appTable');
			appTable.innerHTML = '';
   	 		appTable.appendChild(listApplications(applicationGroups[applicationPage].applications,data['status']));
			if (ge('appGroupTitle') && applicationGroups[applicationPage].grouptitle) {
				ge('appGroupTitle').innerHTML = applicationGroups[applicationPage].grouptitle;
				ge('appGroup').style.display='block';
			}
			// See All Applications Link
			if (ge('myaolmobilelink') && typeof applicationGroups[applicationPage].shopURL!='undefined') {
				ge('shopTitle').innerHTML=applicationGroups[applicationPage].title;
				ge('myaolmobilelink').href=storeBase + applicationGroups[applicationPage].shopURL;
				ge('myaolmobile').style.display='none';
				ge('myaolmobilelink').style.display='none';
				ge('see_all').style.display='none';
			} else {
				ge('myaolmobile').style.display='none';
				ge('myaolmobilelink').style.display='none';
				ge('see_all').style.display='none';
			}
		} else if (applicationPage!='none') {
			// Top Applications
			//var appTopTable = ge('topAppTable');
			//appTopTable.innerHTML = '';
			//appTopTable.appendChild(listTopApplications(topApplications,data['status']));
			//ge('topApplications').style.display='block';
		}
	}
}
function submitCarriers(form) {
	form.ret_url.value = escape(Dloc);
	if (form.carid.selectedIndex==0 || form.mfid.selectedIndex==0) {
		window.location = applicationBase + 'newregister.do?ret_url=' + form.ret_url.value;
		return false;
	} else form.action = applicationBase + 'newregister.do';
}
function addPhone() {
	window.location = applicationBase + 'newregister.do?ret_url=' + escape(Dloc);
}
function modifyPhone() {
	if (userData['selectedPhone'].carrierid!=null) window.location = applicationBase + 'newregister.do?carid='+userData['selectedPhone'].carrierid+'&mfid='+userData['selectedPhone'].manufid+'&mdid='+userData['selectedPhone'].modelid+'&editphone_no='+displayPhoneNum+'&ret_url=' + escape(Dloc);
	else window.location = applicationBase + 'newregister.do?editphone_no='+displayPhoneNum+'&ret_url=' + escape(Dloc);
}
function deletePhone() {
	if (displayPhoneNum==-1) displayPhoneNum='Preview Phone';
	if (confirm('Are you sure you want to remove this phone ' + displayPhoneNum + ' from the My Mobile Dashboard?')) {		
		if_refresh(pipeURL + '?deletephone_no=' + displayPhoneNum + '&rc=true');
	}
}

function confirmPhone() {
	window.location = applicationBase+'confirm.do?confirmphone_no='+displayPhoneNum+'&ret_url='+escape(Dloc);
}

function signIn() {
	window.location = loginURL + Dloc +'&lang=en&locale=us&seamless=y';
}

function autoTabKeyPress( currentEvent ) {
    if ( isCarriageReturnKey( currentEvent ) ) return loadform();

    if ( ! isControlKey( currentEvent ) && ! isNumericChar( currentEvent, false ) ) {
        alert('Phone numbers must contain numeric characters only.');
        return false;
    }
    return true;
}

function autoTab( currentElement, length, nextElement, currentEvent) {
    if ( ! isNumericChar( currentEvent, true ) ) return;

    if ( currentElement.value.length > 0 ) {
        if ( !isNumeric( currentElement.value ) ) {
            alert('Phone numbers must contain numeric characters only.');
        } else {
            if ( currentElement.value.length == length ) {
                if ( nextElement != null ) {
                nextElement.focus();
                }
            }
        }
    }
}

function isCarriageReturnKey( currentEvent ) {
    currentEvent = ( currentEvent ) ? currentEvent : event;
    return ( currentEvent.keyCode == 13 );
}

function isControlKey( currentEvent ) {
    currentEvent = ( currentEvent ) ? currentEvent : event;
    var isNN = ( navigator.appName.indexOf("Netscape") != -1 );
    return ( isNN && ( currentEvent.keyCode > 0 ) );
}

function isNumericChar( currentEvent, isOnKeyUpEvent ) {
    var charCode = ( currentEvent.charCode ) ? currentEvent.charCode : ( ( currentEvent.keyCode ) ? currentEvent.keyCode : ( ( currentEvent.which ) ? currentEvent.which : 0 ) );

    if ( isOnKeyUpEvent && ( charCode >= 96 ) && ( charCode <= 105 ) ) charCode -= 48;
    var charAsChar = String.fromCharCode( charCode );
    return isNumeric( charAsChar );
}

function isNumeric( value ) {
    for ( var i = 0; i < value.length; i++ ) {
        var c = value.charAt( i );
        if ( ( c < '0' ) || ( c > '9' ) ) return false;
    }
    return true;
}


function loadform(){
	var errors=0;
	var pnum1 = document.getElementById('phno1').value
	var pnum2 = document.getElementById('phno2').value
	var pnum3 = document.getElementById('phno3').value 
	
	var pnum = pnum1+pnum2+pnum3;

	if(pnum==""){
		alert("Please enter phone number");
		errors = 1;
	}
	else if(isNaN(pnum)){
		alert("Please enter a valid 10 digit phone number");
		errors = 1;
	}
	else if(pnum1.length!=3||pnum2.length!=3||pnum3.length!=4){
			alert("Please enter a valid 10 digit phone number");
			errors = 1;
		}
	if (errors == 0) {
		var sTargetURL;
		sTargetURL = applicationBase+"confirm.do?carid=0&mfid=0&mdid=0&addphone_no="+pnum+"&ret_url="+escape(Dloc);
		document.location = sTargetURL;
		return false;
	} 
	return false;
}

function loadform2(){
	var errors=0;
	var pnum1 = document.getElementById('phnum1').value
	var pnum2 = document.getElementById('phnum2').value
	var pnum3 = document.getElementById('phnum3').value 
	
	var pnum = pnum1+pnum2+pnum3;

	if(pnum==""){
		alert("Please enter phone number");
		errors = 1;
	}
	else if(isNaN(pnum)){
		alert("Please enter a valid 10 digit phone number");
		errors = 1;
	}
	else if(pnum1.length!=3||pnum2.length!=3||pnum3.length!=4){
			alert("Please enter a valid 10 digit phone number");
			errors = 1;
		}
	if (errors == 0) {
		var sTargetURL;
		sTargetURL = applicationBase+"confirm.do?carid=" + userData['selectedPhone'].carrierid + "&mfid=" + userData['selectedPhone'].manufid + "&mdid="+userData['selectedPhone'].modelid+"&addphone_no="+pnum+"&previewFlag=Y&ret_url="+escape(Dloc);
		document.location = sTargetURL;
		return false;
	} 
	return false;
}

function getURLParam(strParamName){
	var strReturn = "";
	var strHref = window.location.href;
	
	if ( strHref.indexOf("?") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
			if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
			}
		}
	}
	return strReturn;
}

function setGoBtnURL(){
	var url = getURLParam("returnURL");
	window.location.href = url;
}

function triton_AddPhone() {	
	//window.close();
	url = applicationBase + 'newregister.do?ret_url=' + escape(bigbowlBase);
	//var newwin = window.open(url,"addphone","left=0,top=0,resizable=1,scrollbars=1,status=1,location=1,width=1000,height=700");
	window.resizeTo('900', '800');
	window.location = url;
	
}

function triton_modifyPhone() {
	if (userData['selectedPhone'].carrierid!=null) {
		url = applicationBase + 'newregister.do?carid='+userData['selectedPhone'].carrierid+'&mfid='+userData['selectedPhone'].manufid+'&mdid='+userData['selectedPhone'].modelid+'&editphone_no='+displayPhoneNum+'&ret_url=' + escape(bigbowlBase);
	}
	else {
		url = applicationBase + 'newregister.do?editphone_no='+displayPhoneNum+'&ret_url=' + escape(bigbowlBase);
	}	
	//window.close();
	//var newwin = window.open(url,"addphone","left=0,top=0,resizable=1,scrollbars=1,status=1,location=1,width=1000,height=700");	
	window.resizeTo('900', '800');
	window.location = url;
	
}

function triton_deletePhone() {
	if (confirm('Are you sure you want to remove this phone from the My Mobile Dashboard?')) {
		if (displayPhoneNum==-1) displayPhoneNum='Preview Phone';
		if_refresh(pipeURL + '?deletephone_no=' + displayPhoneNum + '&rc=true&fromTriton=Y');
	}
}

function triton_confirmPhone() {
	url = applicationBase+'confirm.do?confirmphone_no='+displayPhoneNum+'&ret_url='+escape(bigbowlBase);
	//window.close();
	//var newwin = window.open(url,"confirmphone","left=0,top=0,resizable=1,scrollbars=1,status=1,location=1,width=1000,height=700");		
	window.resizeTo('900', '800');
	window.location = url;
}


function triton_loadform3(){
	var errors=0;
	var pnum1 = document.getElementById('phnum1').value
	var pnum2 = document.getElementById('phnum2').value
	var pnum3 = document.getElementById('phnum3').value 
	
	var pnum = pnum1+pnum2+pnum3;

	if(pnum==""){
		alert("Please enter phone number");
		errors = 1;
	}
	else if(isNaN(pnum)){
		alert("Please enter a valid 10 digit phone number");
		errors = 1;
	}
	else if(pnum1.length!=3||pnum2.length!=3||pnum3.length!=4){
			alert("Please enter a valid 10 digit phone number");
			errors = 1;
		}
	if (errors == 0) {
		var sTargetURL;
		sTargetURL = applicationBase+"confirm.do?carid=" + userData['selectedPhone'].carrierid + "&mfid=" + userData['selectedPhone'].manufid + "&mdid="+userData['selectedPhone'].modelid+"&addphone_no="+pnum+"&previewFlag=Y&ret_url="+escape(bigbowlBase);
		//window.close();
		//var newwin = window.open(sTargetURL,"regphone","left=0,top=0,resizable=1,scrollbars=1,status=1,location=1,width=1000,height=700");						
		window.resizeTo('900', '800');
		window.location = sTargetURL;
		
	} 
	return false;
}