var width = 800;
var height = 707;
resizeTo(width,height);
var adjustedWidth = width + width - document.documentElement.offsetWidth;
var adjustedHeight = height + height - document.documentElement.offsetHeight;
resizeTo(adjustedWidth, adjustedHeight);
var introMoviePlaying = 0;
var activeTab = 1;
var ChooseLocalMode;
var LocalPicked = null;
var AniPos;
var timerID;
var pushedBtnTwo = false;
var pushedRecBtn = false;

if (screen.availHeight < 707)
{
	adjustedHeight = screen.availHeight
}

if (screen.availWidth < 800)
{
	adjustedWidth = screen.availWidth
}

resizeTo(adjustedWidth, adjustedHeight);

function chooseLanguage()
{
	document.getElementById("divPopupLayer").style.visibility = "visible";

	document.getElementById("selLanguage").options[0] = new Option("Arabic", "ar");
	document.getElementById("selLanguage").options[1] = new Option("Bulgarian", "bg");
	document.getElementById("selLanguage").options[2] = new Option("Chinese- Simplified", "chs");
	document.getElementById("selLanguage").options[3] = new Option("Chinese- Traditional", "cht");
	document.getElementById("selLanguage").options[4] = new Option("Croatian", "hr");
	document.getElementById("selLanguage").options[5] = new Option("Czech", "cs");
	document.getElementById("selLanguage").options[6] = new Option("Danish", "da");
	document.getElementById("selLanguage").options[7] = new Option("Dutch", "nl");
	document.getElementById("selLanguage").options[8] = new Option("English (United Kingdom)", "en-gb");
	document.getElementById("selLanguage").options[9] = new Option("English (United States)", "en-us");
	document.getElementById("selLanguage").options[10] = new Option("Estonian", "et");
	document.getElementById("selLanguage").options[11] = new Option("Filipino", "fil");
	document.getElementById("selLanguage").options[12] = new Option("Finnish", "fi");
	document.getElementById("selLanguage").options[13] = new Option("French", "fr");
	document.getElementById("selLanguage").options[14] = new Option("German", "de");
	document.getElementById("selLanguage").options[15] = new Option("Greek", "el");
	document.getElementById("selLanguage").options[16] = new Option("Hebrew", "he");
	document.getElementById("selLanguage").options[17] = new Option("Hindi", "hi");
	document.getElementById("selLanguage").options[18] = new Option("Hungarian", "hu");
	document.getElementById("selLanguage").options[19] = new Option("Indonesian", "id");
	document.getElementById("selLanguage").options[20] = new Option("Italian", "it");
	document.getElementById("selLanguage").options[21] = new Option("Japan", "ja");
	document.getElementById("selLanguage").options[22] = new Option("Korean", "ko");
	document.getElementById("selLanguage").options[23] = new Option("Latvian", "lv");
	document.getElementById("selLanguage").options[24] = new Option("Lithuanian", "lt");
	document.getElementById("selLanguage").options[25] = new Option("Macedonian", "mk");
	document.getElementById("selLanguage").options[26] = new Option("Malay", "ms");
	document.getElementById("selLanguage").options[27] = new Option("Norwegian", "no");
	document.getElementById("selLanguage").options[28] = new Option("Polish", "pl");
	document.getElementById("selLanguage").options[29] = new Option("Portuguese", "pt");
	document.getElementById("selLanguage").options[30] = new Option("Portuguese (Brazilian)", "pt-br");
	document.getElementById("selLanguage").options[31] = new Option("Romanian", "ro");
	document.getElementById("selLanguage").options[32] = new Option("Russian", "ru");
	document.getElementById("selLanguage").options[33] = new Option("Slovak", "sk");
	document.getElementById("selLanguage").options[34] = new Option("Slovenian", "sl");
	document.getElementById("selLanguage").options[35] = new Option("Spanish", "es");
	document.getElementById("selLanguage").options[36] = new Option("Swedish", "sv");
	document.getElementById("selLanguage").options[37] = new Option("Thai", "th");
	document.getElementById("selLanguage").options[38] = new Option("Turkish", "tr");
	document.getElementById("selLanguage").options[39] = new Option("Vietnamese", "vi");
}

function startVideo()
{
	document.getElementById("objIntro").url = "shared/OTA_intro_v10_1-1.wmv";
}

var bGray = true;
function body_onload()
{
	ChooseLocalMode = getChooseLocalModeFromConfig();

	if (ChooseLocalMode == 1)
	{
		chooseLanguage();
	}
	else
	{
		//startVideo();
	}
}

function LocalSelected()
{
	LocalPicked = document.getElementById('selLanguage').options[document.getElementById('selLanguage').selectedIndex].value;

	document.getElementById("divPopupLayer").style.visibility = "hidden";

	//startVideo();
}

function bannerIntroAni()
{
	introMoviePlaying = 1;

	document.getElementById("ItsFreeToTry").style.visibility = "hidden";
	document.getElementById("LearnMoreOnline").style.visibility = "hidden";
	document.getElementById("LearnMoreOnlineClick").style.visibility = "hidden";

	changeBannerImg(1);
	setTimeout('changeBannerImg(2);', 4000);
	setTimeout('changeBannerImg(3);', 8000);
	setTimeout('changeBannerImg(4);', 12000);
	//setTimeout('changeBannerImg(5);', 16000);
	setTimeout('changeBannerImg(6);', 16000);
}

function changeBannerImg(index)
{
	switch(index)
	{
		case 1:
			document.getElementById("imgHumans").src = strUserLocale + "/img_bk_1.jpg";
		break;

		case 2:
			document.getElementById("imgHumans").src = strUserLocale + "/img_bk_2.jpg";
		break;

		case 3:
			document.getElementById("imgHumans").src = strUserLocale + "/img_bk_3.jpg";
		break;

		case 4:
			document.getElementById("imgHumans").src = strUserLocale + "/img_bk_4.jpg";
		break;

		case 5:
			document.getElementById("imgHumans").src = strUserLocale + "/img_bk_5.jpg";
		break;

		case 6:
			document.getElementById("imgHumans").src = "shared/img_bk_final.jpg";

			if (activeTab == 1 && (strUserLocale.toLowerCase() == "en-gb" || strUserLocale.toLowerCase() == "en-us"))
			{
				document.getElementById("ItsFreeToTry").style.visibility = "visible";
			}

			document.getElementById("LearnMoreOnline").style.visibility = "visible";
			document.getElementById("LearnMoreOnlineClick").style.visibility = "visible";

            if (strUserLocale.toLowerCase() == "en-gb" || strUserLocale.toLowerCase() == "en-us")
            {
    			document.getElementById("Tab1On").filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = strUserLocale + '/tab_1_on.png';
	    		document.getElementById("Tab1On").filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod='scale';
	    	}

			introMoviePlaying = 0;
		break;
	}
}

function movieOverChange()
{
	document.body.style.backgroundColor = "#FFFFFF";
	document.body.style.scrollbarShadowColor = "";
	document.body.style.scrollbarHighlightColor = "";
	document.body.style.scrollbarFaceColor = "";
	document.body.style.scrollbar3dLightColor = "";
	document.body.style.scrollbarDarkShadowColor = "";
	document.body.style.scrollbarTrackColor = "";
	document.body.style.scrollbarArrowColor = "";
	document.getElementById("imgLogo").style.visibility = "visible";
	document.getElementById("headerBar").style.visibility = "visible";
	document.getElementById("imgHumans").style.visibility = "visible";
	document.getElementById("background").style.visibility = "visible";

	if  (strUserLocale == "en-gb" || strUserLocale == "en-us")
	{
	    document.getElementById("ItsFreeToTry").style.visibility = "visible";
	}

	document.getElementById("LearnMoreOnline").style.visibility = "visible";
	document.getElementById("LearnMoreOnlineClick").style.visibility = "visible";
	document.getElementById("Tab1On").style.visibility = "visible";
	document.getElementById("Tab2Off").style.visibility = "visible";

	document.getElementById("btn_step_1").src = strUserLocale + "/btn_step_1_anim.gif";

	document.getElementById("Step1Bullet").style.visibility = "visible";
	document.getElementById("Step1BulletClick").style.visibility = "visible";
	document.getElementById("Step2BulletGray").style.visibility = "visible";
	document.getElementById("Step1SubHead").style.visibility = "visible";

	if (strUserLocale == "ar" || strUserLocale == "he")
	{
    	document.getElementById("5x5Box").style.left = "326px";
    }

	document.getElementById("5x5Box").style.visibility = "visible";
	document.getElementById("Step1RecommendedGray").style.visibility = "visible";
	document.getElementById("Step1RecommendedSubHeadGray").style.visibility = "visible";
	document.getElementById("Step1RecommendedBulletListGray").style.visibility = "visible";
	document.getElementById("Step2SubHeadGray").style.visibility = "visible";
	document.getElementById("HelpButton").style.visibility = "visible";
	document.getElementById("HelpButtonClick").style.visibility = "visible";
	document.getElementById("HelpButtonLabel").style.visibility = "visible";
	document.getElementById("KeyDisplayedHere").style.visibility = "visible";
	document.getElementById("footer").style.visibility = "visible";
	document.getElementById("objIntro").style.visibility = "hidden";
}

function getTrialKey()
{
    document.getElementById("btn_step_1").src = strUserLocale + "/btn_step_1.gif";

	var hadError = findOtherInstalls();

	if (hadError == 0)
	{
		findKeyType(1);
	}
}

function gotTrialKey()
{
    secondaryAni();

    timerID = self.setInterval('secondaryAni()', 1000);

	document.getElementById("Step2BulletGray").style.visibility = "hidden";
	document.getElementById("Step2Bullet").style.visibility = "visible";
	document.getElementById("Step2BulletClick").style.visibility = "visible";
	document.getElementById("Step1RecommendedGray").style.visibility = "hidden";
	document.getElementById("Step1Recommended").style.visibility = "visible";
	document.getElementById("Step1RecommendedClick").style.visibility = "visible";
	document.getElementById("Step1RecommendedSubHeadGray").style.visibility = "hidden";
	document.getElementById("Step1RecommendedSubHead").style.visibility = "visible";
	document.getElementById("Step1RecommendedBulletListGray").style.visibility = "hidden";
	document.getElementById("Step1RecommendedBulletList").style.visibility = "visible";
	document.getElementById("Step2SubHeadGray").style.visibility = "hidden";
	document.getElementById("Step2SubHead").style.visibility = "visible";

	bGray = false;
}

function secondaryAni()
{
    if (AniPos == 1)
    {
        document.getElementById("btn_step_2").src = strUserLocale + "/btn_step_2_anim.gif";
        document.getElementById("bul_recommended").src = strUserLocale + "/bul_recommended.gif";

        AniPos = 2;
    }
    else
    {
        document.getElementById("bul_recommended").src = strUserLocale + "/bul_recommended_anim.gif";
        document.getElementById("btn_step_2").src = strUserLocale + "/btn_step_2.gif";

        AniPos = 1;
    }
}

function passportLinkClick()
{
    self.clearInterval(timerID);

    document.getElementById("bul_recommended").src = strUserLocale + "/bul_recommended.gif";

    pushedRecBtn = true;

    if (pushedBtnTwo == false)
    {
        document.getElementById("btn_step_2").src = strUserLocale + "/btn_step_2_anim.gif";
    }
    else
    {
        document.getElementById("btn_step_2").src = strUserLocale + "/btn_step_2.gif";
    }

	loadConfiguration();

	Node = g_axConfigurationXml.selectSingleNode("/configuration/recommendedLink");

	NodeList = Node.childNodes;

	// get URL and replace with trial key id
	var passPortLink = NodeList(0).text;
	passPortLink = passPortLink.replace('{0}',strUserLocale);
	passPortLink = passPortLink.replace('{1}',TrialIDCode);
	window.open(passPortLink);
}

function activateTab1()
{
	activeTab = 1;

	// Change the tabs
	document.getElementById("Tab1Off").style.visibility = "hidden";
	document.getElementById("Tab2On").style.visibility = "hidden";
	document.getElementById("Tab1On").style.visibility = "visible";
	document.getElementById("Tab2Off").style.visibility = "visible";

	// Hide Tab 2 Contents
	document.getElementById("BuyBulletOne").style.visibility = "hidden";
	document.getElementById("BuyBulletOneClck").style.visibility = "hidden";
	document.getElementById("BuyBulletOneText").style.visibility = "hidden";
	document.getElementById("BuyBulletTwo").style.visibility = "hidden";
	document.getElementById("BuyBulletTwoClck").style.visibility = "hidden";
	document.getElementById("BuyBulletTwoText").style.visibility = "hidden";
	document.getElementById("GreenBullet").style.visibility = "hidden";
	document.getElementById("SecGreenBullet").style.visibility = "hidden";
	document.getElementById("BuyTextTwo").style.visibility = "hidden";


	// Show Tab 1 Contents
	if (introMoviePlaying == 0 && (strUserLocale == "en-gb" || strUserLocale == "en-us"))
	{
		document.getElementById("ItsFreeToTry").style.visibility = "visible";
	}

	document.getElementById("Step1Bullet").style.visibility = "visible";
	document.getElementById("Step1BulletClick").style.visibility = "visible";
	document.getElementById("Step1SubHead").style.visibility = "visible";
	document.getElementById("5x5Box").style.visibility = "visible";
	document.getElementById("HelpButton").style.visibility = "visible";
	document.getElementById("HelpButtonClick").style.visibility = "visible";
	document.getElementById("HelpButtonLabel").style.visibility = "visible";
	document.getElementById("KeyDisplayedHere").style.visibility = "visible";

	if(bGray == true)
	{
		document.getElementById("Step2BulletGray").style.visibility = "visible";
		document.getElementById("Step1RecommendedGray").style.visibility = "visible";
		document.getElementById("Step1RecommendedSubHeadGray").style.visibility = "visible";
		document.getElementById("Step1RecommendedBulletListGray").style.visibility = "visible";
		document.getElementById("Step2SubHeadGray").style.visibility = "visible";
	}
	else
	{
		document.getElementById("Step2Bullet").style.visibility = "visible";
		document.getElementById("Step2BulletClick").style.visibility = "visible";
		document.getElementById("Step1Recommended").style.visibility = "visible";
		document.getElementById("Step1RecommendedClick").style.visibility = "visible";
		document.getElementById("Step1RecommendedSubHead").style.visibility = "visible";
		document.getElementById("Step1RecommendedBulletList").style.visibility = "visible";
		document.getElementById("Step2SubHead").style.visibility = "visible";
	}
}
function activateTab2()
{
	activeTab = 2;

	// Change the tabs
	document.getElementById("Tab1On").style.visibility = "hidden";
	document.getElementById("Tab2Off").style.visibility = "hidden";
	document.getElementById("Tab1Off").style.visibility = "visible";
	document.getElementById("Tab2On").style.visibility = "visible";

	// Hide Tab 1 Contents
	document.getElementById("ItsFreeToTry").style.visibility = "hidden";
	document.getElementById("Step1Bullet").style.visibility = "hidden";
	document.getElementById("Step1BulletClick").style.visibility = "hidden";
	document.getElementById("Step1SubHead").style.visibility = "hidden";
	document.getElementById("5x5Box").style.visibility = "hidden";
	document.getElementById("KeyDisplayedHere").style.visibility = "hidden";
	document.getElementById("Step2BulletGray").style.visibility = "hidden";
	document.getElementById("Step1RecommendedGray").style.visibility = "hidden";
	document.getElementById("Step1RecommendedSubHeadGray").style.visibility = "hidden";
	document.getElementById("Step1RecommendedBulletListGray").style.visibility = "hidden";
	document.getElementById("Step2SubHeadGray").style.visibility = "hidden";
	document.getElementById("Step2Bullet").style.visibility = "hidden";
	document.getElementById("Step2BulletClick").style.visibility = "hidden";
	document.getElementById("Step1Recommended").style.visibility = "hidden";
	document.getElementById("Step1RecommendedClick").style.visibility = "hidden";
	document.getElementById("Step1RecommendedSubHead").style.visibility = "hidden";
	document.getElementById("Step1RecommendedBulletList").style.visibility = "hidden";
	document.getElementById("Step2SubHead").style.visibility = "hidden";

	// Show Tab 2 Contents
	document.getElementById("BuyBulletOne").style.visibility = "visible";
	document.getElementById("BuyBulletOneClck").style.visibility = "visible";
	document.getElementById("BuyBulletOneText").style.visibility = "visible";
	document.getElementById("BuyBulletTwo").style.visibility = "visible";
	document.getElementById("BuyBulletTwoClck").style.visibility = "visible";
	document.getElementById("BuyBulletTwoText").style.visibility = "visible";
	document.getElementById("GreenBullet").style.visibility = "visible";
	document.getElementById("SecGreenBullet").style.visibility = "visible";
	document.getElementById("BuyTextTwo").style.visibility = "visible";
}

function showHelp()
{
	document.getElementById("HelpBox").style.visibility = "visible";
	document.getElementById("helpClose").style.visibility = "visible";
	document.getElementById("helpText").style.visibility = "visible";
}

function hideHelp()
{
	document.getElementById("HelpBox").style.visibility = "hidden";
	document.getElementById("helpClose").style.visibility = "hidden";
	document.getElementById("helpText").style.visibility = "hidden";
}

function showErrorMessage(id)
{
	hideErrorMessage();

	document.getElementById("ErrorMessageBox").style.visibility = "visible";
	document.getElementById("ErrorMessageClose").style.visibility = "visible";
	document.getElementById("ErrorMessage" + id).style.visibility = "visible";
}

function hideErrorMessage()
{
	document.getElementById("ErrorMessageBox").style.visibility = "hidden";
	document.getElementById("ErrorMessageClose").style.visibility = "hidden";
	document.getElementById("ErrorMessage1").style.visibility = "hidden";
	document.getElementById("ErrorMessage2").style.visibility = "hidden";
	document.getElementById("ErrorMessage3").style.visibility = "hidden";
	document.getElementById("ErrorMessage4").style.visibility = "hidden";
	document.getElementById("ErrorMessage5").style.visibility = "hidden";
}