var phonename='bb';
var linkname='home';
var selectedlink='mainnav-01link';

var myvideoid="1";
var myshellid="1";

function setVideoVariables(v,s)
{
myvideoid=v;
myshellid=s;
}

function setVideoVideo(v)
{
	myvideoid = v;
}

function setVideoShell(s)
{
myshellid=s;
}

function changePhoneName(newname)
{
	phonename = newname;
	changeMainImage();
	changeSmallIcon(newname);
}

function clearRightPanel()
{
document.getElementById("contenthome").style.display="none";
document.getElementById("contentfstatus").style.display="none";
document.getElementById("contenttimetable").style.display="none";
document.getElementById("contentbooking").style.display="none";
document.getElementById("contentcheckin").style.display="none";
document.getElementById("contentmiles").style.display="none";
document.getElementById("contentmybooking").style.display="none";
document.getElementById("contentinfo").style.display="none";
document.getElementById("contententertainment").style.display="none";
document.getElementById("contentmysky").style.display="none";
}

function openRightPanel(panelname)
{
	clearRightPanel();
	document.getElementById("content"+panelname).style.display="block";
}
var lastImage="images/bb_home.png";
var lastImage2="images/bb_home.png";
function changeLinkName(newlink)
{
lastImage = document.getElementById('phonescreen').src;
	linkname = newlink;
	changeMainImage();
	openRightPanel(newlink);
	
	
	
}

function changeMainImage()
{
	document.getElementById('phonescreen').src = "images/"+phonename+"_"+linkname+".png";
}

function clearAll()
{	
	document.getElementById("mainnav-01link").style.backgroundImage='url(images/nav_home.png)';
	document.getElementById("mainnav-02link").style.backgroundImage='url(images/nav_fstatus.png)';
	document.getElementById("mainnav-03link").style.backgroundImage='url(images/nav_timetable.png)';
	document.getElementById("mainnav-04link").style.backgroundImage='url(images/nav_booking.png)';
	document.getElementById("mainnav-05link").style.backgroundImage='url(images/nav_checkin.png)';
	document.getElementById("mainnav-06link").style.backgroundImage='url(images/nav_miles.png)';
	document.getElementById("mainnav-07link").style.backgroundImage='url(images/nav_mybooking.png)';
	document.getElementById("mainnav-08link").style.backgroundImage='url(images/nav_info.png)';
	document.getElementById("mainnav-09link").style.backgroundImage='url(images/nav_ent.png)';
	document.getElementById("mainnav-10link").style.backgroundImage='url(images/nav_mysky.png)';
}

function leftPanelMouseOver(id,imgname)
{
	document.getElementById(id).style.backgroundImage='url(images/nav_'+imgname+'_over.png)';
}

function leftPanelMouseOut(id,imgname)
{
	if(id!=selectedlink){
		document.getElementById(id).style.backgroundImage='url(images/nav_'+imgname+'.png)';
	}
}

function leftPanelMouseClick(id,imgname)
{
	clearAll();
	selectedlink=id;
	document.getElementById(id).style.backgroundImage='url(images/nav_'+imgname+'_over.png)';
}

function clearPhoneImages()
{
document.getElementById("bbimage").src="images/phones_bb.png";
document.getElementById("andrimage").src="images/phones_andr.png";
document.getElementById("iphoneimage").src="images/phones_iphone.png";
document.getElementById("otherimage").src="images/phones_other.png";
}

 function validateEmail(inputvalue){
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){         
		return true;  
    }
	return false;
}
 
var RE_SSN = /^[0-9]{3}[\-]?[0-9]{3}[\- ]?[0-9]{4}$/;
function checkSsn(ssn)
{
	if (RE_SSN.test(ssn)) 
	{
		return true;
	}
	else
	{
		return false;
	}
}
var RE_SSN2 = /^[0-9]{10}$/;
function checkTenNumber(ssn)
{
	if (RE_SSN2.test(ssn)) 
	{
		return true;
	}
	else
	{
		return false;
	}
}

var RE_SSN3 = /^[\(]?[0-9]{3}[\)]?[0-9]{7}$/;
function checkParanthesis(ssn)
{
	if (RE_SSN3.test(ssn)) 
	{
		return true;
	}
	else
	{
		return false;
	}
}

function checkField(controlstring)
{

	var firstcheck = checkSsn(controlstring);
	var secondcheck = validateEmail(controlstring);
	var thirdcheck = checkTenNumber(controlstring);
	var fourthcheck = checkParanthesis(controlstring);
	if(firstcheck || secondcheck || thirdcheck || fourthcheck)
	{
		document.getElementById('thanks').style.display="block";
		document.getElementById('error').style.display="none";
		document.getElementById('yourphone').style.borderTopColor ="#097f00";
	document.getElementById('yourphone').style.borderLeftColor ="#097f00";
	document.getElementById('yourphone').style.borderRightColor ="#097f00";
	document.getElementById('yourphone').style.borderBottomColor ="#097f00";
		return;
	}
	document.getElementById('yourphone').style.borderTopColor ="#d01800";
	document.getElementById('yourphone').style.borderLeftColor ="#d01800";
	document.getElementById('yourphone').style.borderRightColor ="#d01800";
	document.getElementById('yourphone').style.borderBottomColor ="#d01800";
	document.getElementById('error').style.display="block";
	document.getElementById('thanks').style.display="none";
	return;
}

function checkValidation()
{

	var s = document.URL;
	var pos = s.indexOf('=');

	if(pos==-1)
		return;
	document.getElementById('instructions').style.display="none";
	
	while(s.indexOf("+")!=-1)
	{
		s = s.replace("+", "");
	}
	
	while(s.indexOf("-")!=-1)
	{
		s = s.replace("-", "");
	}
	
	while(s.indexOf("%28")!=-1)
	{
		s = s.replace("%28", "");
	}
	
	while(s.indexOf("%29")!=-1)
	{
		s = s.replace("%29", "");
	}
	/*
	while(s.indexOf("%40%C2%A3")!=-1)
	{
		s = s.replace("%40%C2%A3", "")
	}*/
	
	while(s.indexOf("%40")!=-1)
	{
		s = s.replace("%40", "@")
	}
	//document.getElementById('instructions').style.display="none";
	var news = s.substr(pos+1,s.length-pos);
	var pos2 = news.indexOf('&');
	
	var finalstring = news.substr(0,pos2);
	checkField(finalstring);
}

function showContent()
{
if(linkname=='home')
	func13();
if(linkname=='fstatus')
	func12();
if(linkname=='timetable')
	func12();
if(linkname=='booking')
	func12();
if(linkname=='checkin')
	func12();
if(linkname=='miles')
	func12();
if(linkname=='mybooking')
	func12();
if(linkname=='info')
	func13();
if(linkname=='entertainment')
	func13();
if(linkname=='mysky')
	func13();
			
	document.getElementById('phonescreen').src="images/"+phonename+"_"+linkname+"_over.png";
	
}

function showContent2()
{
if(linkname=='home')
	func13();
if(linkname=='fstatus')
	func12();
if(linkname=='timetable')
	func12();
if(linkname=='booking')
	func12();
if(linkname=='checkin')
	func12();
if(linkname=='miles')
	func12();
if(linkname=='mybooking')
	func12();
if(linkname=='info')
	func13();
if(linkname=='entertainment')
	func13();
if(linkname=='mysky')
	func13();
	
	document.getElementById('phonescreen').src="images/"+phonename+"_"+linkname+"_over.png";
	
}

function hideContent2()
{
	var s = document.getElementById('phonescreen').src;
	s = s.replace("_over","");
	document.getElementById('phonescreen').src=s;
}

function hideContent()
{
	var s = document.getElementById('phonescreen').src;
	s = s.replace("_over","");
	document.getElementById('phonescreen').src=s;
}

var smallicon='bb';
function changeSmallIcon(id)
{
lastImage = document.getElementById('phonescreen').src;
	smallicon=id;
	clearPhoneImages();
	document.getElementById(id+"image").src="images/phones_"+id+"_over.png";
}

function smallIconMouseOver(img)
{
document.getElementById(img+"image").src="images/phones_"+img+"_over.png";
}

function smallIconMouseOut(img)
{
if(img!=smallicon)
document.getElementById(img+"image").src="images/phones_"+img+".png";
}

function func9()
{
var newlink = linkname;
if(newlink=='home')
	{
		document.getElementById('if1').src="http://mobile.lufthansa.com/hpg/start.jsp;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en_US";
		document.getElementById('if2').src="http://mobile.lufthansa.com/hpg/start.jsp;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en_US";
		document.getElementById('if3').src="http://mobile.lufthansa.com/hpg/start.jsp;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en_US";
		document.getElementById('if4').src="http://mobile.lufthansa.com/hpg/start.jsp;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en_US";
	}
	
	if(newlink=='fstatus')
	{
		//document.getElementById('if1').src="iframe/iframe.html";
		document.getElementById('if1').src="http://mobile.lufthansa.com/arrdep/arrdep.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en_US";
		document.getElementById('if2').src="http://mobile.lufthansa.com/arrdep/arrdep.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en_US";
		document.getElementById('if3').src="http://mobile.lufthansa.com/arrdep/arrdep.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en_US";
		document.getElementById('if4').src="http://mobile.lufthansa.com/arrdep/arrdep.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en_US";
	}
	
	if(newlink=='timetable')
	{
		document.getElementById('if1').src="http://mobile.lufthansa.com/tta/search.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en_US";
		document.getElementById('if2').src="http://mobile.lufthansa.com/tta/search.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en_US";
		document.getElementById('if3').src="http://mobile.lufthansa.com/tta/search.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en_US";
		document.getElementById('if4').src="http://mobile.lufthansa.com/tta/search.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en_US";
	}
	
	if(newlink=='booking')
	{
		document.getElementById('if1').src="https://mobile.lufthansa.com/bkg/login.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?start=1&l=en_US";
		document.getElementById('if2').src="https://mobile.lufthansa.com/bkg/login.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?start=1&l=en_US";
		document.getElementById('if3').src="https://mobile.lufthansa.com/bkg/login.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?start=1&l=en_US";
		document.getElementById('if4').src="https://mobile.lufthansa.com/bkg/login.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?start=1&l=en_US";
	}
	
	if(newlink=='checkin')
	{
		document.getElementById('if1').src="https://mobile.lufthansa.com/cki/ident.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if2').src="https://mobile.lufthansa.com/cki/ident.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if3').src="https://mobile.lufthansa.com/cki/ident.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if4').src="https://mobile.lufthansa.com/cki/ident.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
	}
	
	if(newlink=='miles')
	{
		document.getElementById('if1').src="https://mobile.lufthansa.com/mma/account.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if2').src="https://mobile.lufthansa.com/mma/account.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if3').src="https://mobile.lufthansa.com/mma/account.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if4').src="https://mobile.lufthansa.com/mma/account.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
	}
	
	if(newlink=='mybooking')
	{
		document.getElementById('if1').src="https://mobile.lufthansa.com/mbo/login.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if2').src="https://mobile.lufthansa.com/mbo/login.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if3').src="https://mobile.lufthansa.com/mbo/login.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if4').src="https://mobile.lufthansa.com/mbo/login.do;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
	}
	
	if(newlink=='info')
	{
		document.getElementById('if1').src="https://mobile.lufthansa.com/inf/start.jsp;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if2').src="https://mobile.lufthansa.com/inf/start.jsp;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if3').src="https://mobile.lufthansa.com/inf/start.jsp;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if4').src="https://mobile.lufthansa.com/inf/start.jsp;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
	}
	
	if(newlink=='entertainment')
	{
		document.getElementById('if1').src="https://mobile.lufthansa.com/moc/start.jsp;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if2').src="https://mobile.lufthansa.com/moc/start.jsp;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if3').src="https://mobile.lufthansa.com/moc/start.jsp;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
		document.getElementById('if4').src="https://mobile.lufthansa.com/moc/start.jsp;jsessionid=43110DA86D096269F15E03BB3E959B9F.portal8?l=en";
	}
	
	if(newlink=='mysky')
	{
		document.getElementById('if5').src="http://mobile.myskystatus.com";
		document.getElementById('if6').src="http://mobile.myskystatus.com";
		document.getElementById('if7').src="http://mobile.myskystatus.com";
		document.getElementById('if8').src="http://mobile.myskystatus.com";
		iBox.default_width=380;
		iBox.showURL('#interact'+phonename+"3");
		return;
	}

iBox.default_width=400;
iBox.showURL('#interact'+phonename);
}



function func10()
{
iBox.default_width=500;
	var flashvars = {
	videoId: myvideoid,
	shellId: myshellid
};

var params = {
	menu: "false",
	scale: "noscale",
	allowScriptAccess: "sameDomain",
	wmode: "transparent",
	quality: "best",
	allowFullScreen: "false"
};

var attributes = {};
 
	
	swfobject.embedSWF("videoPlayer.swf", "video", "400", "650", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
	
	iBox.showURL('#watchdemobb');
}

function clearInstructions()
{
	document.getElementById('instructions').style.display="none";
	document.getElementById('yourphone').value='';
}



var slidertop=0;
var sliderspeed=10;
function dummyup()
{
	if(slidertop-sliderspeed>0)
	{
		slidertop = slidertop-sliderspeed;
		var myIframe = document.getElementById('if1');
		myIframe.contentWindow.scrollTo(0,slidertop);
	}
}

function dummydown()
{
var myIframe = document.getElementById('if1');
//alert(myIframe.contentDocument.height-parseInt(myIframe.height));

	if(slidertop+sliderspeed<myIframe.contentDocument.height-parseInt(myIframe.height))
	{
		slidertop = slidertop+sliderspeed;
		myIframe.contentWindow.scrollTo(0,slidertop);	
	}
	/*
	slidertop = slidertop+sliderspeed;
var myIframe = document.getElementById('if1');
//alert(myIframe.contentDocument.height);
   myIframe.contentWindow.scrollTo(0,slidertop);*/
}


function submitMouseOver()
{
	document.getElementById("mc-embedded-subscribe").src="images/btn_submit_over.png";
}

function submitMouseOut()
{
	document.getElementById("mc-embedded-subscribe").src="images/btn_submit.png";
}

function func12()
{
	if(navigator.appName=="Microsoft Internet Explorer")
	{
		if(phonename=='other')
		{
			phonescreen.useMap="#planetmap4";
		}
		else if(phonename=='andr')
		{
			phonescreen.useMap="#planetmap3";
		}
		else
		{
			phonescreen.useMap="#planetmap";
		}
	}
	else
	{
		if(phonename=='other')
		{
			var s = document.getElementById("phonescreen");
			s.setAttribute("usemap", "#planetmap4");
		}
		else if(phonename=='andr')
		{
			var s = document.getElementById("phonescreen");
			s.setAttribute("usemap", "#planetmap3");
		}
		else
		{
			var s = document.getElementById("phonescreen");
			s.setAttribute("usemap", "#planetmap");
		}
	}
}

function func13()
{
	if(navigator.appName=="Microsoft Internet Explorer")
	{
		if(phonename=='other')
		{
			phonescreen.useMap="#planetmap6";
		}
		else if(phonename=='andr')
		{
			phonescreen.useMap="#planetmap5";
		}
		else
		{
			phonescreen.useMap="#planetmap2";
		}		
	}
	else
	{
		if(phonename=='other')
		{
			var s = document.getElementById("phonescreen");
			s.setAttribute("usemap", "#planetmap6");
		}
		else if(phonename=='andr')
		{
			var s = document.getElementById("phonescreen");
			s.setAttribute("usemap", "#planetmap5");
		}
		else
		{
			var s = document.getElementById("phonescreen");
			s.setAttribute("usemap", "#planetmap2");
		}
		
	}
}
