﻿// JScript File

function DownloadTimed(sParams)
{
	location = "ThanksDownload.aspx?" + sParams;
}

function GetControl(ctrl)
{
	var ix;

	if (document.all != null){
		return document.all[ctrl];
	}

	if (document.getElementById != null){
		return document.getElementById(ctrl);
	}


	for (ix = 0; ix < document.Form1.elements.length;ix++){
		if (document.Form1.elements[ix].name == ctrl)
			return(document.Form1.elements[ix]);

	}

	return null;

}
function GetLocalTime()
{
    var dt = new Date();
    var ctrl;


    var offsetMin =dt.getTimezoneOffset();

    ctrl = GetControl("HiddenField2");
    ctrl.value = offsetMin;
    
//    alert("Your local timezone offset: " + offsetMin + " ");
}


function ToggleTrial()
{
    var ctrl, ctrl2, ctrl3, ctrl4;

    ctrl = GetControl("LabelKey");
    ctrl2 = GetControl("TextBoxKey");
    ctrl3 = GetControl("RBTrial");
    ctrl4 = GetControl("RBTrial2");

  
    if (ctrl3.checked || ctrl4.checked){
        ctrl.disabled = true;
        ctrl2.disabled = true;
    }
    else
    {
        ctrl.disabled = false;
        ctrl2.disabled = false;
    }
}

function ShowButton()
{
    var ctrl, ctrl2, ctrl3;

    ctrl = GetControl("HiddenField1");
    ctrl2 = GetControl("BTNBETA");
    ctrl3 = GetControl("BTNTRIAL");
    
    if (ctrl != null){
        if (ctrl.value == "BETA"){
            if (ctrl2 != null)
                ctrl2.style.visibility = "visible";
            if (ctrl3 != null)
                ctrl3.style.visibility = "hidden";
                
        }
        else{
            if (ctrl2 != null)
                ctrl2.style.visibility = "hidden";
            if (ctrl3 != null)
                ctrl3.style.visibility = "visible";
        }
    }
}

function DownloadPage(sCommand, sParams)
{
    var ctrl, combo;
    var val="";
    var val2="";
	var sFunc;

    ctrl = GetControl("MODEL");
    combo = GetControl("Country");
    
    
    if (ctrl != null)
        val = ctrl.value;

    if (combo  != null)
        val2 = combo.value;
       
    if (val == "" || val2.indexOf(">") == 0){
        alert("Please enter the phone model and country before downloading");
        return;
    }
    
	newWindow = window.open(sCommand+"?"+sParams+ "&model="+val+"$$$"+val2, "", "height=100,width=100,status=no,menubar=no,titlebar=no,toolbar=no");
	
	sFunc = "DownloadTimed(\'" + "page=beta&" + sParams + "\')";
	setTimeout(sFunc,3000)
}

function DownloadTrial(sCommand, sParams)
{
	var sFunc;

    
	newWindow = window.open(sCommand+"?"+sParams, "", "height=100,width=100,status=no,menubar=no,titlebar=no,toolbar=no");
	
	sFunc = "DownloadTimed(\'" + sParams + "\')";
	setTimeout(sFunc,3000)
}

function DownloadMP(sCommand, sParams,ver)
{
	var sFunc;

    
	newWindow = window.open(sCommand+"?"+sParams+"&product=mp&ver="+ver, "", "height=100,width=100,status=no,menubar=no,titlebar=no,toolbar=no");
	
	sFunc = "DownloadTimed(\'" + sParams + "\')";
	setTimeout(sFunc,3000)
}

function NewPageSpec(sCommand, sParams, spec)
{
	var sFunc;

    if (sParams =="")
	    newWindow = window.open(sCommand, "", spec);
	else
	    newWindow = window.open(sCommand+"?"+sParams, "", spec);

}
