var currentOperator;
var operatorCount;
var PlatinumNames = new Array();
var operatorNames = new Array();
var operatorRatings = new Array();
var operatorRatingLogos = new Array();
var operatorStatRatings = new Array();
var operatorStatCount = new Array();
var ARGUSFlash = new Array();
var DidYouKnow = new Array();
var currentFlash;
var DYKCount;
var currentDYK;
var j$ = jQuery.noConflict();
ARGUSFlash[0] = "Global Leader in Aviation Safety";
ARGUSFlash[1] = "Data Driven Solutions for Business Aviation";
ARGUSFlash[2] = "Enhancing Your Safety Management System";
//DidYouKnow[0] = "<p class='largeDYK'>DID<br/>YOU<br/>KNOW...</p>";
DidYouKnow[0] = "<p>The average flight length of all corporate jet flights departing from a U.S. airport was 82 minutes in October 2008 compared to 79 minutes in October 2007.</p><p class='DYK'>Did You Know...</p>";
DidYouKnow[1] = "<p>260 different operators, flying 523 different tail numbers, departed PHL 798 times in the month of October 2008.</p><p class='DYK'>Did You Know...</p>";
DidYouKnow[2] = "<p>154 corporate aircraft flew into TPA in October 2008 that had not flown into that airport in October 2007.</p><p class='DYK'>Did You Know...</p>";
DidYouKnow[3] = "<p>The 2008 number 1 U.S. market pair of TEB to IAD has been flown 1968 times by 332 unique operators flying 43 different aircraft types.</p><p class='DYK'>Did You Know...</p>";

function GetARGUSPressReleases() {
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/ARGUSPressReleases.asmx/PressReleases",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            j$('#divPressReleases').html(response.d);
        },
        failure: function(msg) {
            j$('#divErrorMessage').html(msg);
        }
    });
}

function ARGUSPressReleaseDetailLink()
{
    var uniqid = 0;
    var qs = window.location.search.substring(1).split("&");
    for (i = 0; i < qs.length; i++) {
        kvpair = qs[i].split("=");
        if (kvpair[0] == 'id') {
            uniqid = kvpair[1];
        }
    }
	GetARGUSPressReleaseDetail(uniqid);
    return true;
}

function GetARGUSPressReleaseDetail(uniqid) {

    var data = "{'UniqID':'" + uniqid + "'}";
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/ARGUSPressReleases.asmx/PressReleaseDetail",
        data: data,
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            j$('#divPressReleases').html(response.d[0]);
            j$('#divPressReleaseLinks').html(response.d[1]);
        },
        failure: function(msg) {
        j$('#divErrorMessage').html(msg);
        }
    });
}

/*
j$("a.prDetailLink").live("click", function() {
	var uniqid = 0;
    var qs = j$(this).attr("href").split("?");
    for (i = 0; i < qs.length; i++) {
        kvpair = qs[i].split("=");
        if (kvpair[0] == 'id') {
            uniqid = kvpair[1];
        }
    }
	GetARGUSPressReleaseDetail(uniqid);
    return false;
});
*/

function GetARGUSPressReleasesByYear()
{
    var curdate = new Date();
    var year = curdate.getFullYear();
    var data = "{'year':'" + year + "'}";
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/ARGUSPressReleases.asmx/PressReleasesByYear",
        data: data,
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            j$('#divPressReleases').html(response.d[0]);
            j$('#divPressReleaseLinks').html(response.d[1]);
        },
        failure: function(msg) {
            j$('#divErrorMessage').html(msg);
        }
    });
    return true;
}

//function GetARGUSPressReleasesByYear() {
j$("a.pressReleaseLink").live("click", function() {
    var year = 0;
    var qs =  j$(this).attr("href").split("?");
    for (i = 0; i < qs.length; i++) {
        kvpair = qs[i].split("=");
        if (kvpair[0] == 'year') {
            year = kvpair[1];
        }
    }
    if (year == 0) {
        var curdate = new Date();
        year = curdate.getFullYear();
    }
    var data = "{'year':'" + year + "'}";
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/ARGUSPressReleases.asmx/PressReleasesByYear",
        data: data,
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            j$('#divPressReleases').html(response.d[0]);
            j$('#divPressReleaseLinks').html(response.d[1]);
        },
        failure: function(msg) {
            j$('#divErrorMessage').html(msg);
        }
    });
    return false;
});

function SetScrollingDYK() {
	DYKCount = DidYouKnow.length;
	currentDYK = 0;
	j$("#DidYouKnow").html(DidYouKnow[currentDYK]);
	setInterval("ChangeDYK();", 7000);
}

function ChangeDYK() {
    if (currentDYK == (DidYouKnow.length - 1))
    { currentDYK = 0; }
    else
    { currentDYK++; }
    j$('#DidYouKnow').fadeOut(1000, function() {
		j$("#DidYouKnow").html(DidYouKnow[currentDYK]).fadeIn(1000);
    });
	
}

function GetScrollingOperatorList() {
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/OperatorList.asmx/GetARGUSRatedOperators",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            var RatedOperators = response.d.split('|');
            operatorCount = RatedOperators.length;
            if (RatedOperators.length > 0) {
                for (var i = 0; i < RatedOperators.length; i++) {
					var opInfo = RatedOperators[i].split('~');
                    operatorNames[i] = opInfo[0];
                    operatorRatings[i] = opInfo[1];
                }
                currentOperator = 0;
                var ratingHTML;
				j$('#divRatingBox').css("background-repeat", "no-repeat");  
                if (operatorRatings[currentOperator] == 'PLATINUM') {			 
					j$('#divRatingBox').css("background-image", "url(/Portals/0/Images/Platinum_Custom_Logo.png)");    
                }
                else if (operatorRatings[currentOperator] == 'GOLD PLUS') {
					j$('#divRatingBox').css("background-image", "url(/Portals/0/Images/GoldPlus_Custom_Logo.png)");  
                }
                else {
                    //gold
					j$('#divRatingBox').css("background-image", "url(/Portals/0/Images/Gold_Custom_Logo.png)");  
                }
            }
            setTimeout("changeOperator();", 2000);
        },
        failure: function(msg) {
            alert("Failure!");
            //j$('#ErrorMessage').text(msg);
        }
    });
}

function changeOperator() {
    var htmlString;
    if (currentOperator == operatorCount)
    { currentOperator = 0; }
    else
    { currentOperator++; }

    var currentImg = j$('#ratingImg').attr('src');
    if (currentImg == null || currentImg == "") {
        var ratingHTML;
        if (operatorRatings[currentOperator] == 'PLATINUM') {
            //ratingHTML = "<img id='ratingImg' src='/Portals/0/Images/Platinum_Custom_Logo.png'";
			j$('#divRatingBox').css("background-image", "url(/Portals/0/Images/Platinum_Custom_Logo.png)");    
        }
        else if (operatorRatings[currentOperator] == 'GOLD PLUS') {
            //ratingHTML = "<img id='ratingImg' src='/Portals/0/Images/GoldPlus_Custom_Logo.png'";
			j$('#divRatingBox').css("background-image", "url(/Portals/0/Images/GoldPlus_Custom_Logo.png)");  
        }
        else {
            //gold
            //ratingHTML = "<img id='ratingImg' src='/Portals/0/Images/Gold_Custom_Logo.png'";
			j$('#divRatingBox').css("background-image", "url(/Portals/0/Images/Gold_Custom_Logo.png)");
        }
        //ratingHTML += "alt='" + operatorRatings[currentOperator] + "'/><div id='divOperator'>" +
            //operatorNames[currentOperator] + "</div>";
        j$('#divRatingBox').html("<div id='divOperator'>" + operatorNames[currentOperator] + "</div>");
    }
    else if (currentImg.indexOf(operatorRatings[currentOperator]) == -1) {
        if (operatorRatings[currentOperator] == 'PLATINUM') {
			j$('#divRatingBox').css("background-image", "url(/Portals/0/Images/Platinum_Custom_Logo.png)");    
            //j$('#ratingImg').attr('src', '/Portals/0/Images/Platinum Custom Logo.png');
            //j$('#ratingImg').attr('alt', 'Platinum Rated');
        }
        else if (operatorRatings[currentOperator] == 'GOLD PLUS') {
			j$('#divRatingBox').css("background-image", "url(/Portals/0/Images/GoldPlus_Custom_Logo.png)");  
            //j$('#ratingImg').attr('src', '/Portals/0/Images/Gold Plus Custom Logo.png');
            //j$('#ratingImg').attr('alt', 'Gold Plus Rated');
        }
        else {
            //gold
			j$('#divRatingBox').css("background-image", "url(/Portals/0/Images/Gold_Custom_Logo.png)");
            //j$('#ratingImg').attr('src', '/Portals/0/Images/Gold Custom Logo.png');
            //j$('#ratingImg').attr('alt', 'Gold Rated');
        }
		j$('#divRatingBox').html("<div id='divOperator'>" + operatorNames[currentOperator] + "</div>");
        //j$('#divOperator').html(operatorNames[currentOperator]);
    }
    setTimeout("changeOperator();", 2000);
}

function GetRatedOperatorStats() {
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/OperatorList.asmx/GetARGUSRatedOperatorStats",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            j$("#ARGUSOperatorStats").html(response.d);
        },
        failure: function(msg) {
            alert("Failure!");
            //j$('#ErrorMessage').text(msg);
        }
    });
}

function GetCompairDefinitions() {
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/CompairDefinitions.asmx/Definitions",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            j$('#divDefinitions').html(response.d);
        },
        failure: function(msg) {
            j$('#divErrorMessage').html(msg);
        }
    });
}

function GetFuelSurvey() {
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/FuelSurvey.asmx/FuelSurveyTable",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            j$('#divFuelSurvey').html(response.d);
        },
        failure: function(msg) {
            j$('#divErrorMessage').html(msg);
        }
    });
}

function GetACLookupResult() {
    var tailnbr = j$("#tailnbr").val();

    if (tailnbr != null && tailnbr != "") {
        var data = "{'TailNbr':'" + tailnbr + "'}";
        j$.ajax({
            type: "POST",
            timeout: 10000,
            url: "/ws/NewCorporate/AircraftLookup.asmx/ACLookupByTailNbr",
            data: data,
            contentType: "application/json; charset=utf-8",
            dataType: "json",

            success: function(response) {
                j$('#aclookupresults').html(response.d);
            },
            failure: function(msg) {
                j$('#aclookupresults').html(msg);
            }
        });
    }
}


function GetContactSubject() {
    var op;
    var qs = window.location.search.substring(1).split("&");
    for (i = 0; i < qs.length; i++) {
        kvpair = qs[i].split("=");
        if (kvpair[0] == 'op') {
            op = kvpair[1];
        }
    }
    if (j$("[name$='$Default$Form$Subject']") != null) {
        switch (op) {
            case "aoc":
                j$("[name$='$Default$Form$Subject']").val("Aircraft Operating Costs").attr("selected", "selected");
                break;
            case "asos":
                j$("[name$='$Default$Form$Subject']").val("ASOS").attr("selected", "selected");
                break;
            case "audits":
                j$("[name$='$Default$Form$Subject']").val("Audits").attr("selected", "selected");
                break;
            case "odmp":
                j$("[name$='$Default$Form$Subject']").val("ODMP").attr("selected", "selected");
                break;
            case "marketresearch":
                j$("[name$='$Default$Form$Subject']").val("Market Research").attr("selected", "selected");
                break;
            case "sales":
                j$("[name$='$Default$Form$Subject']").val("Sales").attr("selected", "selected");
                break;
            case "sbr":
                j$("[name$='$Default$Form$Subject']").val("Salary Benefit Report").attr("selected", "selected");
                break;
            case "newsletter":
                j$("[name$='$Default$Form$Subject']").val("Quarterly Newsletter").attr("selected", "selected");
                break;
        }
    }
}

function AvPanelSignUp() {
    var ea = j$("#ea").val();
    if (ea == null || ea == "") {
        alert("Please enter your e-mail address to continue.");
        return false;
    }
    window.location.href = "http://ccprod.roving.com/roving/d.jsp?ea=" + ea + "&m=1011170310238&p=oi";
    return true;
}

function SwapImage(imgFilePath) {
    j$(document).ready(function() {
        j$("#imgHolder").html("<img alt='Screenshot' src='" + imgFilePath + "' />");
    });
}

function FraxGetPrograms() {
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/FraxService.asmx/GetPrograms",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            j$('#divPrograms').html("<div class='divBack'><a href='/FreeData/FraxUtilityMenu.aspx'>Back to Fractional Lookup Menu</a></div>" + response.d);
        },
        failure: function(msg) {
            j$('#divErrorMessage').html(msg);
        }
    });
}

/*
function FraxPostPrograms() {
    var valArray = j$('input[name=chkProgID]').serializeArray();
    var programs = j$('input[name=chkProgID]:checked').val();
    var data = "{'Programs':'" + programs + "'}";
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/FreeData/FraxUtilityMenu/FraxPrograms.aspx",
        data: data,
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            j$("#divFraxMatrix").html(response);
        },
        failure: function(msg) {
            j$('#divErrorMessage').html(msg);
        }
    });
}
*/

j$("#submitPgmFraxBtn").live("click", function()
{
	//var valArray = j$('input[name=chkProgID]').serializeArray();
    var programs = j$('input[name=chkProgID]:checked');
	var programlist = '';

	for(i=0;i<programs.length;i++)
	{
		if(programlist.length > 0)
			programlist = programlist + ',';
		
		programlist = programlist + programs[i].value;
	}
    var data = "{'Programs':'" + programlist + "','Aircraft':''}";
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/FraxService.asmx/GetFraxProgramMatrix",
        data: data,
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
			j$("#divFraxMatrix").removeClass("hide");
           j$("#divFraxMatrix").html("<div class='divBack'><a href='/FreeData/FraxUtilityMenu.aspx'>Back to Fractional Lookup Menu</a></div>" + response.d);
		   j$("#divPrograms").addClass("hide");
		   j$('#divErrorMessage').html('');
        },
        failure: function(msg) {
            j$('#divErrorMessage').html(msg);
			j$("#divPrograms").removeClass("hide");
			j$("#divFraxMatrix").addClass("hide");
        }
    });
});

j$("#submitACFraxBtn").live("click", function()
{
	var aircraft = j$('input[name=chkAcftID]:checked');
	var aircraftlist = '';

	for(i=0;i<aircraft.length;i++)
	{
		if(aircraftlist.length > 0)
			aircraftlist = aircraftlist + ',';
		
		aircraftlist = aircraftlist + aircraft[i].value;
	}
    var data = "{'Programs':'','Aircraft':'" + aircraftlist + "'}";
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/FraxService.asmx/GetFraxProgramMatrix",
        data: data,
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
			j$("#divFraxMatrix").removeClass("hide");
           j$("#divFraxMatrix").html("<div class='divBack'><a href='/FreeData/FraxUtilityMenu.aspx'>Back to Fractional Lookup Menu</a></div>" + response.d);
		   j$("#divAircraft").addClass("hide");
		   j$('#divErrorMessage').html('');
        },
        failure: function(msg) {
            j$('#divErrorMessage').html(msg);
			j$("#divAircraft").removeClass("hide");
			j$("#divFraxMatrix").addClass("hide");
        }
    });
});

function FraxGetAircraft() {
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/FraxService.asmx/GetAircraft",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
            j$('#divAircraft').html("<div class='divBack'><a href='/FreeData/FraxUtilityMenu.aspx'>Back to Fractional Lookup Menu</a></div>" + response.d);
        },
        failure: function(msg) {
            j$('#divErrorMessage').html(msg);
        }
    });
}
/*
function FraxPostAircraft() {
    var aircraft = j$('input[name=chkAcftID]:checked').val();
    var data = "{'Aircraft':'" + aircraft + "'}";
    $.post("/FreeData/FraxUtilityMenu/FraxPrograms.aspx", data);
}
*/

function GetFraxMatrix()
{
	var data = "{'Programs':'','Aircraft':''}";
    j$.ajax({
        type: "POST",
        timeout: 10000,
        url: "/ws/NewCorporate/FraxService.asmx/GetFraxProgramMatrix",
        data: data,
        contentType: "application/json; charset=utf-8",
        dataType: "json",

        success: function(response) {
           j$("#divFraxMatrix").html("<div class='divBack'><a href='/FreeData/FraxUtilityMenu.aspx'>Back to Fractional Lookup Menu</a></div>" + response.d);
		   j$('#divErrorMessage').html('');
        },
        failure: function(msg) {
            j$('#divErrorMessage').html(msg);
        }
    });
}
/*
function FraxGetMatrix() {
    var programs = '<%= Request("chkProgID") %>';
    var aircraft = '<%= Request("chkAcftID") %>';
    var data;
    if ((programs == null || programs.length == 0) && (aircraft == null || aircraft.length == 0)) {
        data = "{}";
    }
    else {
        if (programs != null && programs.length > 0) {
            data = "{'Programs':'" + programs + "'";
        }
        else {
            data = "{'Programs':''";
        }
        if (aircraft != null && aircraft.length > 0) {
            data = data + ",'Aircraft':'" + aircraft + "'}";
        }
        else {
            data = data + ",'Aircraft':''}";
        }
    }

    j$.ajax({
        async: false,
        type: "POST",
        timeout: 10000,
        mode: "queue",
        url: "/ws/NewCorporate/FraxService.asmx/GetFraxProgramMatrix",
        data: data,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) {
            j$('#divFraxMatrix').html(response.d);
        },
        failure: function(msg) {
            j$('#divErrorMessage').html(msg);
        }
    });
}
*/
function startFlash() {
    currentFlash = 0;
    j$('#divFlashText').html(ARGUSFlash[currentFlash]);
    setInterval('changeFlash()', 5000);
}

function changeFlash() {
    if (currentFlash == (ARGUSFlash.length - 1))
    { currentFlash = 0; }
    else
    { currentFlash++; }
	j$('#divFlashText').fadeOut(1000, function() {
		j$("#divFlashText").html(ARGUSFlash[currentFlash]).fadeIn(1000);
    });
}

function GetPurchasedDoc() {
    var orderid = 0;
    if (window.location.href.indexOf("PayPalExit=RETURN") > -1 && window.location.href.indexOf("stg/5/") > -1) {
        var qs = window.location.href.substring(1).split("/");
        for (i = 0; i < qs.length; i++) {
            if (qs[i] == 'ordID' && qs[i + 1] != null) {
                orderid = qs[i + 1];
                var data = "{'OrderID':'" + orderid + "'}";
                j$.ajax({
                    type: "POST",
                    timeout: 10000,
                    url: "/ws/NewCorporate/OrderFulFillment.asmx/GetPurchasedDocument",
                    data: data,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",

                    success: function(response) {
                        j$('#divPurchasedDoc').html(response.d);
                    },
                    failure: function(msg) {
                        j$('#divPurchasedDoc').html(msg);
                    }
                });
            }
        }
        if (orderid == 0) {
            j$('#divPurchasedDoc').html("Please contact <a href='mailto:sales@argus.aero'>the sales department at ARG/US </a> " +
            "for your purchased item.  We apologize for any inconvenience.");
        }
    }
}

function GetOrderDetails() {
    var orderid = 0;
    var orderguid = "";
    var qs = window.location.href.split("?");
    for (i = 0; i < qs.length; i++) {
        var kv = qs[i].split("=");
        if (kv[0] == 'ordID') {
            orderid = kv[1];
        }
        else {
            if (kv[0] == 'ordGuid') {
                orderguid = kv[1];
            }
        }
    }
    if ((orderid == null || orderid == 0 || orderid == '0') && (orderguid == null || orderguid == "")) {
        j$('#divPurchasedDoc').html("Please contact <a href='mailto:sales@argus.aero'>the sales department at ARG/US </a> " +
            "for your purchased item.  We apologize for any inconvenience.");
    }
    else {
        //var data = "{'OrderID':'" + orderid + "','OrderGuid':'" + orderguid + "'}";
		var data = "{'OrderID':'" + orderid + "'}";
        j$.ajax({
            type: "POST",
            timeout: 10000,
            url: "/ws/NewCorporate/OrderFulFillment.asmx/GetPurchasedOrder",
            data: data,
            contentType: "application/json; charset=utf-8",
            dataType: "json",

            success: function(response) {
                j$('#divPurchasedDoc').html(response.d);
            },
            failure: function(msg) {
                j$('#divPurchasedDoc').html(msg);
            }
        });
    }
    //}
}

j$(document).ready(function () {
//creates the popups on various pages
    j$("a#lnkSalesTeam").colorbox({ href: "#divSalesTeamPopup", inline: true, width: 450, height: 450, close: ''})
    j$("a#lnkAboutARGUS").colorbox({ href: "#divAboutARGUSPopup", inline: true, width: 450, height: 450, close: '' })
    j$("a#lnkPRISM").colorbox({ href: "#divAboutPRISMPopup", inline: true, width: 450, height: 450, close: '' })
    j$("a#lnkExecTeam").colorbox({ href: "#divExecutiveTeamPopup", inline: true, width: 450, height: 450, close: '' })
    j$("a#lnkPROS").colorbox({ href: "#divAboutPROSPopup", inline: true, width: 450, height: 450, close: '' })
    j$("a#lnkMktIntell").colorbox({ href: "#divMktIntellTeamPopup", inline: true, width: 450, height: 450, close: '' })
    j$("a#lnkTechnology").colorbox({ href: "#divTechnologyTeamPopup", inline: true, width: 450, height: 450, close: '' })
    j$("a#lnkCHEQ").colorbox({ href: "#divCHEQTeamPopup", inline: true, width: 450, height: 450, close: '' })
    j$("a#lnkMarketing").colorbox({ href: "#divMarketingTeamPopup", inline: true, width: 450, height: 450, close: '' })
    j$("a#lnkHR").colorbox({ href: "#divHRTeamPopup", inline: true, width: 450, height: 450, close: '' })
	j$("a#lnkIATA").colorbox({ href: "#divIATAPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkIBAC").colorbox({ href: "#divIBACPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkNBAA").colorbox({ href: "#divNBAAPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkFlightSafety").colorbox({ href: "#divFSFPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkFlightSafetyFoundation").colorbox({ href: "#divFSFPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkFlightSafetyInternational").colorbox({ href: "#divFSIPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkSagem").colorbox({ href: "#divSagemPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkAirCharterGuide").colorbox({ href: "#divAirCharterGuidePopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkCharterly").colorbox({ href: "#divCharterlyPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkJetCharters").colorbox({ href: "#divJetChartersPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkJetVizors").colorbox({ href: "#divJetVizorsPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkAvinode").colorbox({ href: "#divAvinodePopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkflyRubycom").colorbox({ href: "#divflyRubycomPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkMissionmode").colorbox({ href: "#divMissionmodePopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkUSAIG").colorbox({ href: "#divUSAIGPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkNexus").colorbox({ href: "#divNexusPopup", inline: true, width: 400, height: 400, close: '' })
	j$("a#lnkContactARGUS").colorbox({ href: "#divContactARGUSPopup", inline: true, width: 400, height: 450, close: '' })
	j$("a#lnkProdSupport").colorbox({ href: "#divContactProdSupportPopup", inline: true, width: 400, height: 450, close: '' })
	j$("a#lnkGenInfo").colorbox({ href: "#divContactGenInfoPopup", inline: true, width: 400, height: 450, close: '' })
	j$("a#lnkContactSales").colorbox({ href: "#divContactSalesPopup", inline: true, width: 400, height: 450, close: '' })
    j$("a.lnkAboutPopup").live("click", function () {
        return false;
    });
});

j$(document).ready(function () {
	j$("#btnAvmosysContactUs").click(function() {
		var bValid = true;
		var regex = /^[0-9a-zA-Zs' ']+$/;
		if (j$("#name").val() == "" || !regex.test(j$("#name").val())) {
			j$("#nameError").html("&nbsp;&nbsp;Please include your name");
			bValid = false;
			j$("#name").addClass("errorStyle");
		}
		else {
			j$("#name").removeClass("errorStyle");
			j$("#nameError").html("");
		}

		if (j$("#company").val() == "" || !regex.test(j$("#company").val())) {
			j$("#companyError").html("&nbsp;&nbsp;Please include your company name");
			bValid = false;
			j$("#company").addClass("errorStyle");
		}
		else {
			j$("#company").removeClass("errorStyle");
			j$("#companyError").html("");
		}

		if (j$("#Message").val() == null || j$("#Message").val() == "") {
			j$("#messageError").html("Please include your message<br/>");
			bValid = false;
			j$("#Message").addClass("errorStyle");
		}
		else {
			j$("#Message").removeClass("errorStyle");
			j$("#messageError").html("");
		}

		if (j$("#phone").val() == "") {
			j$("#phoneError").html("&nbsp;&nbsp;Please include your phone number");
			bValid = false;
			j$("#phone").addClass("errorStyle");
		}
		else {
			j$("#phone").removeClass("errorStyle");
			j$("#phoneError").html("");
		}
				
		if (j$("#email").val() == "") {
			j$("#emailError").html("&nbsp;&nbsp;Please include your e-mail address");
			bValid = false;
			j$("#email").addClass("errorStyle");
		}
		else {
			j$("#email").removeClass("errorStyle");
			j$("#emailError").html("");
		}

		if(bValid)
		{
		//send e-mail
		var address = "";
		var address2 = "";
		var city = "";
		var state = "";
		var zip = "";
		var country = "";
		var message = "";
		if(j$("#address").val() != null)
			address = j$("#address").val();
		if(j$("#address2").val() != null)
			address2 = j$("#address2").val();
		if(j$("#city").val() != null)
			city = j$("#city").val();			
		if(j$("#state").val() != null)
			state = j$("#state").val();	
		if(j$("#zip").val() != null)
			zip = j$("#zip").val();		
		if(j$("#country").val() != null)
			country = j$("#country").val();		
			
		message = j$("#Message").val().replace(/\'/g,"&quot;"); ;	
		
		 var data = "{'Name':'" + j$("#name").val() + "','Company':'" + j$("#company").val() + "','Address1':'" + address;
			data = data + "','Address2':'" + address2 + "','City':'" + city; 
			data = data + "','State':'" + state + "','Zip':'" + zip;
			data = data + "','Country':'" + country + "','PhoneNumber':'" + j$("#phone").val(); 
			data = data + "','EmailAddress':'" + j$("#email").val() + "','Subject':'Avmosys Product Advisory Board'";
			data = data + ",'Message':'" + message + "','MailTo':'amy.hofmeister@argus.aero','BCC':'amy.hofmeister@argus.aero'}";					
		    j$.ajax({
				type: "POST",
				timeout: 10000,
				url: "/ws/NewCorporate/SendEmail.asmx/SendAvmosysEmail",
				data: data,
				contentType: "application/json; charset=utf-8",
				dataType: "json",

				success: function(response) {
					j$('#divMsg').html(response.d);
					j$("#name").val("");
					j$("#company").val("");
					j$("#address").val("");
					j$("#address2").val("");
					j$("#city").val("");
					j$("#state").val("");
					j$("#zip").val("");
					j$("#country").val("");
					j$("#phone").val("");
					j$("#email").val("");
					j$("#Message").val("");
				},
				failure: function(msg) {
					j$('#divMsg').html(msg);
				}
			});
		}
		return false;
	});
});
