function displayService(serviceInfo)
{
    var headerStart = serviceInfo.indexOf('<header>') + 8;
    var headerEnd = serviceInfo.indexOf('</header>');
    var contentStart = serviceInfo.indexOf('<content>') + 9;
    var contentEnd = serviceInfo.indexOf('</content>');
    
    var header = serviceInfo.substring(headerStart, headerEnd);
    var content = serviceInfo.substring(contentStart, contentEnd);
    
    document.getElementById("tagLine").innerHTML = header;
    document.getElementById("contentText").innerHTML = content;
    $("#tagLine").fadeIn("slow");
    $("#contentText").fadeIn("slow");
}

function changeService(serviceID)
{
    $("#contentText").fadeOut(1,getServiceContent(serviceID));
}

function getServiceContent(serviceID)
{ 
    $.ajax({ 
        type: "POST",               
        url: "json.aspx?fid=1&miid=" + serviceID,               
        contentType: "application/x-www-form-urlencoded",              
        data: "",          
        dataType: "text",              
        success: function(msg) { displayService(msg) },               
        error: function() {$.modal("An Ajax error has occurred.")}         
     });
}

function getPageContent(pageID)
{
    $.ajax({ 
        type: "POST",               
        url: "json.aspx?fid=2&lid=" + pageID,               
        contentType: "application/x-www-form-urlencoded",              
        data: "",          
        dataType: "html",              
        success: function(msg) {     $("#content").html(msg) },               
        error: function() {    $.modal("An Ajax error has occurred.")}         
     });
}

function submitContact()
{
    var name = document.getElementById("txtName").value;
    var email = document.getElementById("txtEmail").value;
    var message = document.getElementById("txtMessage").value;
    
    $.ajax({ 
        type: "POST",               
        url: "json.aspx?fid=3&n=" + name + "&e=" + email + "&m=" + message,               
        contentType: "application/x-www-form-urlencoded",              
        data: "",          
        dataType: "text",              
        success: function(msg) { $.modal(msg)  },               
        error: function() {$.modal("An Ajax error has occurred.")}         
     });
}

function appDepth(appid)
{
    var screenShotDivName = "#screenshots";
    
    if(appid == 2)
    {
        screenShotDivName = "#screenshotsHoriz";
    }
    
    $.ajax({
        type: "POST",
        url: "json.aspx?fid=4&aid=" + appid,
        contentType: "application/x-www-form-urlencoded",              
        data: "",          
        dataType: "text",              
        success: function(msg) { $.complexmodal(msg), $(screenShotDivName).easySlider();  },               
        error: function() {$.complexmodal("An Ajax error has occurred.")}     
    })
}

function prev()
{
    animate("prev",true);
}

function next()
{
    animate("next",true);
}

$(document).ready(
    function() {
        var url = window.location.href;
        if(url.indexOf('lid') == -1)
        {
            getPageContent(1);
        }
        else
        {
            getPageContent(url.toString().substring(url.indexOf('lid=')+4));
        }
    }
);

