﻿
// General Variables
//////////////////////////////////////////
var Action = "";
var MaxStep = 1;
var ChatLog = "";
var ChatID = "";
var StateLog = "";
var UserInformationLog = "";
var ReceivedResponsesArray = new Array();
var MissingResponsesArray = new Array();
var LastReceivedContextIndexArray = new Array();
var CurrentUnrecognizedSentence = "";
var CurrentStringData = "";
var CurrentContextIndexData = -1;
var NickName = "";
var Email = "";
var MessageArray = new Array();
var Commas = '"';
var RowCount = 0;
var Score = 0;
var CurrentFeedbackData = "";




// Main Timer
//////////////////////////////////////////
var cycles = 0;
var timerID = null;
var timerRunning = false;
var delay = 1000; // equals to one second


// User Information
//////////////////////////////////////////
var UserInformation_Name = "User";
var UserInformation_Age  = 0;
var UserInformation_Location = "";
var UserInformation_Occupation = "";
var UserInformation_AcademicLevel = "";


// Output Parameters
//////////////////////////////////////////
var Security = 0;
var Attraction = 0;
var Interest = 0;

var Anger = 0;
var Sadness = 0;
var Fear = 0;
var Enjoyment = 0;
var Love = "P0";
var Surprise = "P0";
var Disgust = 0;
var Shame = 0;


// Yes/No Flags
//////////////////////////////////////////
var IsConversationStarted = false;
var IsConversationOver = false;
var ShowedChatPromoVideo = false;
var ShowedFillingExample = false;
var IsEmotionsDisplayed = true;
var IsPhoneGiven = false;


// Symbols
//////////////////////////////////////////
var SymbolMark = "#";
var UserInformationSymbol = "UI";
var OutputSymbol = "OP";
var MissingResponseSymbol = "MR";
var ConversationOverSymbol = "CO";

var UserInformation_Name_Symbol = "N";
var UserInformation_Age_Symbol  = "A";
var UserInformation_Location_Symbol = "L";
var UserInformation_Occupation_Symbol = "O";
var UserInformation_AcademicLevel_Symbol = "C";

var Phone_Symbol = "P";
var BrainObject_Symbol = "BO";
var Security_Symbol = "S";
var Attraction_Symbol = "A";
var Interest_Symbol = "I";
var Emotions_Symbol = "E";

var SubjectSeparator = "^";
var TalkBackSeparator = "%";


// Steps
//////////////////////////////////////////

var Str_Step1 = "Talk to Jenny";
var Str_Step2 = "Get Score";
var Str_Step3 = "Get Feedback";


function GetIEVersion()
{
    var version = 0;
    
    if (navigator.appVersion.indexOf("MSIE") != -1) // IE
    {
        version = parseFloat(navigator.appVersion.split("MSIE")[1]);
    }
        
    return version;  
}

var IEVersion = GetIEVersion();


function WebForm_CallbackComplete_SyncFixed() 
{
    for (var i = 0; i < __pendingCallbacks.length; i++)
    {
        callbackObject = __pendingCallbacks[ i ];
        if (callbackObject && callbackObject.xmlRequest && (callbackObject.xmlRequest.readyState == 4)) 
        {
            if (!__pendingCallbacks[ i ].async) 
            {
                __synchronousCallBackIndex = -1;
            }
    
            __pendingCallbacks[i] = null;

            var callbackFrameID = "__CALLBACKFRAME" + i;
            var xmlRequestFrame = document.getElementById(callbackFrameID);
            if (xmlRequestFrame) 
            {
                xmlRequestFrame.parentNode.removeChild(xmlRequestFrame);
            }

            // SyncFix: the following statement has been moved down from above;
            WebForm_ExecuteCallback(callbackObject);
        }
    }
}


function ClearArray(obj)
{
    while(obj.length)
    {
        obj.shift();
    }
}

function ReplaceSymbols(str)
{
    var tmp = str;
                
    while(tmp.indexOf('<') != -1)
    {
        var first = tmp.substr(0, tmp.indexOf('<'));
        var second = tmp.substr(tmp.indexOf('<') + 1, tmp.length - tmp.indexOf('<') - 1);
        tmp = first + "&#60;" + second;
    }
                
    while(tmp.indexOf('>') != -1)
    {
        var first = tmp.substr(0, tmp.indexOf('>'));
        var second = tmp.substr(tmp.indexOf('>') + 1, tmp.length - tmp.indexOf('>') - 1);
        tmp = first + "&#62;" + second;
    }
                
    while(tmp.indexOf("'") != -1)
    {
        var first = tmp.substr(0, tmp.indexOf("'"));
        var second = tmp.substr(tmp.indexOf("'") + 1, tmp.length - tmp.indexOf("'") - 1);
        tmp = first + "&#39;" + second;
    }

    while(tmp.indexOf('"') != -1)
    {
        var first = tmp.substr(0, tmp.indexOf('"'));
        var second = tmp.substr(tmp.indexOf('"') + 1, tmp.length - tmp.indexOf('"') - 1);
        tmp = first + "&#148;" + second;
    }

    return tmp;
}

function ReplaceSymbolsToBlank(str)
{
    var tmp = str;
                
    while(tmp.indexOf('<') != -1)
    {
        var first = tmp.substr(0, tmp.indexOf('<'));
        var second = tmp.substr(tmp.indexOf('<') + 1, tmp.length - tmp.indexOf('<') - 1);
        tmp = first + second;
    }
                
    while(tmp.indexOf('>') != -1)
    {
        var first = tmp.substr(0, tmp.indexOf('>'));
        var second = tmp.substr(tmp.indexOf('>') + 1, tmp.length - tmp.indexOf('>') - 1);
        tmp = first + second;
    }
                
    while(tmp.indexOf("'") != -1)
    {
        var first = tmp.substr(0, tmp.indexOf("'"));
        var second = tmp.substr(tmp.indexOf("'") + 1, tmp.length - tmp.indexOf("'") - 1);
        tmp = first + second;
    }

    while(tmp.indexOf('"') != -1)
    {
        var first = tmp.substr(0, tmp.indexOf('"'));
        var second = tmp.substr(tmp.indexOf('"') + 1, tmp.length - tmp.indexOf('"') - 1);
        tmp = first + second;
    }

    return tmp;
}

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    cycles = 0;
    StopTimer();
}

function StopTimer()
{
    if(timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}

function StartTimer()
{
    timerRunning = true;
    RunTimer();
}

function RunTimer()
{
    GetSentence();
    cycles++;
    timerID = self.setTimeout("RunTimer()", delay);
}

function makeOptional(object)
{
    object.style.color ="#9f0013";
	object.style.cursor = "pointer";
	object.style.textDecorationUnderline = true;
}

// Make text normal with auto sign
function makeNormal(object)
{
	object.style.color ="black";
	object.style.cursor = "auto";
	object.style.textDecorationUnderline = false;
}

function makeNotAvailable(object)
{
	object.style.cursor = "not-allowed";
}

function makeStepOptional(object)
{
    object.style.color ="blue";
	object.style.cursor = "pointer";
	object.style.textDecorationUnderline = true;
}
			
function makeStepNormal(object)
{
    object.style.color ="#6f6f6f";
	object.style.cursor = "auto";
	object.style.textDecorationUnderline = false;
}

function makePromoStepOptional(object)
{
    makeStepOptional(object);
}

function makePromoStepNormal(object)
{
    object.style.color ="#08036c";
	object.style.cursor = "auto";
	object.style.textDecorationUnderline = false;
}

function makeTDOptional(object, sentence)
{
    object.style.color ="#9f0013";
    object.style.background ="#eeeeee";
	object.style.cursor = "pointer";

    DisplayChatLog(sentence,true);
    
    var chat_log_window = document.getElementById('MainWindow_ChatLog');
    
    if(chat_log_window != null)
    {
        chat_log_window.style.border = "1px solid #bbb";
        //chat_log_window.scrollTop = 14*4;
    }    
}

function makeTDNormal(object,for_response)
{
    object.style.color ="black";
    object.style.background ="white";
	object.style.cursor = "auto";
    DisplayChatLog("",for_response);

    var chat_log_window = document.getElementById('MainWindow_ChatLog');
    
    if(chat_log_window != null)
    {
        chat_log_window.style.border = "";
    }    
}

function StopFlash(obj)
{
    if(obj != null)
    {
        
        obj.GotoFrame(1500);
    }    
}

function GenerateNewUserID()
{
    var temp_array = new Array();
    temp_array = UserID.split('_');
    temp_array[2]++;
    
    var i;
    var tmp = "";
    
    for(i=0; i < temp_array.length; i++)
    {
        tmp += temp_array[i];
        
        if(i != (temp_array.length - 1) )
        {
            tmp += "_";
        }
    }
    
    UserID = tmp;

    delete temp_array;
}

function SetChatID(response)
{
    if (response == null)
    {
       return;
    }

    if(response != "")
    {
        ChatID = response;
    }
}

function GetSymbol(sentence)
{
    if (sentence.charAt(0) == SymbolMark)
    {
        var i=0;
        
        for(i=1; i < sentence.length; i++)
        {
            if(sentence.charAt(i) == SymbolMark)
            {
                return sentence.substr(1,--i);
            }
        }
    }
    
    else
    {
        return "";
    }
}

function UpdateUserInformation(str)
{
    var temp = new Array();
    temp = str.split(' ');

    var i=0;
    
    for(i=1; i < temp.length; i++)
    {
        var symbol = temp[i].charAt(0);
        var first_index = temp[i].indexOf("|");
        var last_index = temp[i].lastIndexOf("|");
        var value = temp[i].substring(++first_index, last_index);
        
        switch (symbol)
        {
        
        case UserInformation_Name_Symbol:
            UserInformation_Name = value;
            break;
        
        case UserInformation_Age_Symbol:
            UserInformation_Age = value;
            break;
        
        case UserInformation_Location_Symbol:
            UserInformation_Location = value;
            break;
        
        case UserInformation_Occupation_Symbol:
            UserInformation_Occupation = value;
            break;
        
        case UserInformation_AcademicLevel_Symbol:
            UserInformation_AcademicLevel = value;
            break;
        
        }
        
    }
    
    delete temp;
}

function UpdateOutput(str)
{
    var temp = new Array();
    temp = str.split(' ');

    var i=0;
    
    for(i=1; i < temp.length; i++)
    {
        var symbol = temp[i].charAt(0);
        var first_index = temp[i].indexOf("|");
        var last_index = temp[i].lastIndexOf("|");
        
        var value = "";
        
        if(first_index >= 0 && last_index >= 0)
        { 
            value = temp[i].substring(++first_index, last_index);
        
            switch (symbol)
            {
        
            case Security_Symbol:
                Security = value;
                break;
        
            case Attraction_Symbol:
                Attraction = value;
                break;
        
            case Interest_Symbol:
                Interest = value;
                break;
        
            case Emotions_Symbol:
                var emotions = new Array();
                emotions = value.split('-');
                Anger = emotions[0];
                Sadness = emotions[1];
                Fear = emotions[2];
                Enjoyment = emotions[3];
                Love = emotions[4];
                Surprise = emotions[5];
                Disgust = emotions[6];
                Shame = emotions[7];
                break;
                
            case Phone_Symbol:
                if(value == "Y")
                {
                    IsPhoneGiven = true;
                }
                
                break;
            }
        }        
    }
    
    delete temp;
}

function UpdateMissingResponse(str)
{
    var first_index = str.indexOf("|");
    var last_index = str.indexOf("|",first_index + 1);
    var last_received_index = str.substring(++first_index, last_index);
        
    first_index = str.indexOf("|",last_index + 1);
    last_index = str.indexOf("|",first_index + 1);
    var sentence = str.substring(++first_index, last_index);
        
    sentence = ReplaceSymbols(sentence);
                        
    var valid = true;
    var i=0;
                        
    for(i=0; i < MissingResponsesArray.length; i++)
    {
        if(sentence == MissingResponsesArray[i])
        {
            valid = false;
        }
    }
                        
    if(valid)
    {
        LastReceivedContextIndexArray[LastReceivedContextIndexArray.length] = last_received_index;
        MissingResponsesArray[MissingResponsesArray.length] = sentence;
        AddNewChatMissingResponses(sentence, last_received_index);                        
    }
}

function UpdateConversationOver()
{
    IsConversationOver=true;
    //PageMethods.ASPReleaseWaitEvent(UserID);
    StopTimer();
    CalculateScore();
    PageMethods.AddNewChatLog(GetChatData(), GetAnswer, GetError, GetTimeout);
    Step2();
}

function UpdateAds()
{
    var str = "Google Ads (search words): ";
    str += UserInformation_Age;
    str += " ";
    str += UserInformation_Location;
    str += " ";
    str += UserInformation_Occupation;
    str += " ";
    str += UserInformation_AcademicLevel;

    /*var ad = document.getElementById('Advertisement_Top');
    
    if(ad != null)
    {
        if(document.all) // If Explorer
        {
            ad.innerText = str;
        } 
     
        
        else // If FireFox
        {
            ad.textContent = str;
        }
    }*/        
}

function UpdateImage()
{
    var str = "<img border=0 src='images/img_";
    var security_state = 0;
    var attarction_state = 0;
    var interest_state = 0;
    var description = "";
    
    if(Security >= 0)
    {
        security_state = "1";
        description += "Jenny feels secure. ";
    }
    
    else
    {
        security_state = "0";
        description += "Jenny is concerned for her safety. ";
    }
    
    if(Attraction >= 0)
    {
        attraction_state = "1";
        description += "She is attracted to you, ";
    }
    
    else
    {
        attraction_state = "0";
        description += "She doesn&#39;t find you attractive, ";
    }
    
    if(Interest >= 0)
    {
        interest_state = "1";
        description += "and she thinks you&#39;re interesting.";
    }
    
    else
    {
        interest_state = "0";
        description += "and she doesn&#39;t think you&#39;re interesting.";
    }
    
    str += security_state + attraction_state + interest_state;
    str += ".jpg' ";
    str += "title='"
    str += description;
    str += "'>"
    
    var photo = document.getElementById('MainWindow_ChatWindow_Photo');
    
    if(photo != null)
    {
        photo.innerHTML = str;
    }
}

function UpdateEmotions()
{
    if(IsEmotionsDisplayed)
    {
    
        var tmp = document.getElementById('Amygdala_Anger');
    
        if(tmp != null)
        {
            tmp.innerHTML = GetVisualScale(Anger, false, true);
        }
            
        tmp = document.getElementById('Amygdala_Sadness');

        if(tmp != null)
        {
            tmp.innerHTML = GetVisualScale(Sadness, false, true);
        }
    
        tmp = document.getElementById('Amygdala_Fear');

        if(tmp != null)
        {
            tmp.innerHTML = GetVisualScale(Fear, false, true);
        }
            
        tmp = document.getElementById('Amygdala_Enjoyment');

        if(tmp != null)
        {
            tmp.innerHTML = GetVisualScale(Enjoyment, false, false);
        }        

        tmp = document.getElementById('Amygdala_Love');

        if(tmp != null)
        {
            var use_red_indicators = false;
        
            if(Love.charAt(0) == 'N')
            {
                use_red_indicators = true;
            }
        
            var love_value = Love.substr(1,Love.length-1);

            tmp.innerHTML = GetVisualScale(love_value, false, use_red_indicators);
        }        

        tmp = document.getElementById('Amygdala_Surprise');

        if(tmp != null)
        {
            var use_red_indicators = false;
            
            if(Surprise.charAt(0) == 'N')
            {
                use_red_indicators = true;
            }
        
            var surprise_value = Surprise.substr(1,Surprise.length-1);

            tmp.innerHTML = GetVisualScale(surprise_value, false, use_red_indicators);
        }
            
        tmp = document.getElementById('Amygdala_Disgust');

        if(tmp != null)
        {
            tmp.innerHTML = GetVisualScale(Disgust, false, true);
        }
            
        tmp = document.getElementById('Amygdala_Shame');

        if(tmp != null)
        {
            tmp.innerHTML = GetVisualScale(Shame, false, true);
        }        
    }
}

// Scroll text edit box to the bottom
function cursorEOT(obj)
{
    obj.scrollTop = obj.scrollHeight;
}

function GetStepTopSection(current_step, max_step)
{
    var str = "<div id='MainWindow_StepDescription'>";
    str += "<div id='MainWindow_StepDescription_Steps'>";
    str += "<span style='font-size:13pt; font-family:Courier New;'><b>";
        
    switch(current_step)
    {
    
    case 1:
        str += "Step 1/3 - " + Str_Step1;
        str += "</b></span><br/><br/>";
        str += "<span style='color:#3366cc; cursor:not-allowed;' title='Current step'><b>" + Str_Step1 + "</b></span>&nbsp;&nbsp;&#62;&nbsp;&nbsp;";

        str += "<span style='color: #6f6f6f;'";

        if(max_step > 1)
        {
            str += " title='Back to step 2' onmouseover='makeStepOptional(this)' onmouseout='makeStepNormal(this)' onclick='Step2()' ";
        }
        
        else
        {
            str += " title='First complete step 1 before moving to this one' style='cursor:not-allowed;' ";
        }
        
        str += ">" + Str_Step2 + "</span>&nbsp;&nbsp;&#62;&nbsp;&nbsp;";


        str += "<span style='color: #6f6f6f;'";

        if(max_step > 2)
        {
            str += " title='Back to step 3' onmouseover='makeStepOptional(this)' onmouseout='makeStepNormal(this)' onclick='Step3()' ";
        }
        
        else
        {
            str += " title='First complete steps 1-2 before moving to this one' style='cursor:not-allowed;' ";
        }
        
        str += ">" + Str_Step3 + "</span>";
        
        break;
        
    case 2:
        str += "Step 2/3 - " + Str_Step2;
        str += "</b></span><br/><br/>";
        str += "<span style='color:#6f6f6f;' title='Back to step 1'  onmouseover='makeStepOptional(this)' onmouseout='makeStepNormal(this)' onclick='Step1()'>" + Str_Step1 + "</span>&nbsp;&nbsp;&#62;&nbsp;&nbsp;";

        str += "<span style='color:#3366cc; cursor:not-allowed;' title='Current step' ";
        str += "><b>" + Str_Step2 + "</b></span>&nbsp;&nbsp;&#62;&nbsp;&nbsp;";


        str += "<span style='color: #6f6f6f;'";

        if(max_step > 2)
        {
            str += " title='Back to step 3' onmouseover='makeStepOptional(this)' onmouseout='makeStepNormal(this)' onclick='Step3()' ";
        }
        
        else
        {
            str += " title='First complete step 2 before moving to this one' style='cursor:not-allowed;' ";
        }
        
        str += ">" + Str_Step3 + "</span>";

        break;
        
    case 3:
        str += "Step 3/3 - " + Str_Step3;
        str += "</b></span><br/><br/>";
        str += "<span style='color:#6f6f6f;' title='Back to step 1'  onmouseover='makeStepOptional(this)' onmouseout='makeStepNormal(this)' onclick='Step1()'>" + Str_Step1 + "</span>&nbsp;&nbsp;&#62;&nbsp;&nbsp;";
        str += "<span style='color:#6f6f6f;' title='Back to step 2'  onmouseover='makeStepOptional(this)' onmouseout='makeStepNormal(this)' onclick='Step2()'>" + Str_Step2 + "</span>&nbsp;&nbsp;&#62;&nbsp;&nbsp;";

        str += "<span style='color:#3366cc; cursor:not-allowed;' title='Current step' ";
        str += "><b>" + Str_Step3 + "</b></span>";

        break;
        
    default:
        break;
    }
    
    str += "</div>";
    str += "<div id='MainWindow_StepDescription_Controls'>";
    str += "<button id='MainWindow_StepDescription_Controls_Restart' style='width: 120px' onclick='Restart()' title='Restart the entire process and return to step 1'>Restart Process</button>";
    str += "</div>";
    str += "</div>";
    
    return str;
}

function GetStepBottomSection(current_step)
{
    var str = "<div id='MainWindow_StepControls'>";
    
    if (current_step > 1)
    {
        str += "<button title='Back to previous step'";
        
        switch(current_step)
        {
        
        case 2:
            str += " onclick='Step1()' ";
            break;
        
        case 3:
            str += " onclick='Step2()' ";
            break;
        
        }
        
        str += ">&#60;&#60; Back</button>&nbsp;&nbsp;";
    }

    if (current_step < 3)
    {
        
        str += "<button title='Continue to next step'";
        
        switch(current_step)
        {
        
        case 1:
            str += " onclick='Step2()' ";
            break;
        
        case 2:
            str += " onclick='Step3()' ";
            break;

        }

        str += ">Continue &#62;&#62;</button>&nbsp;&nbsp;";
        
    }
    
    if (current_step == 3)
    {
        str += "<button onclick='Finish()' title='Continue to next step'>Finish</button>";
    }

    str += "</div>";
    
    return str;
}

function Restart()
{
    if(IsConversationStarted && !IsConversationOver)
    {
        IsConversationOver=true;
         //PageMethods.ASPReleaseWaitEvent(UserID);
        StopTimer();
        CalculateScore();
        PageMethods.AddNewChatLog(GetChatData(), GetAnswer, GetError, GetTimeout);
    }        

    InitializeTimer();
    
    GenerateNewUserID();
    
    MaxStep = 1;
    RowCount = 0;
    Score = 0;
    ChatID = "";
    ChatLog = "";
    StateLog = "";
    UserInformationLog = "";
    UserInformation_Name = "";
    UserInformation_Age = "";
    UserInformation_Location = "";
    UserInformation_Occupation = "";
    UserInformation_AcademicLevel = "";
    CurrentUnrecognizedSentence = "";
    CurrentStringData = "";
    CurrentContextIndexData = "";
    CurrentFeedbackData = "";
    IsPhoneGiven = false;
    ClearArray(ReceivedResponsesArray);
    ClearArray(MissingResponsesArray);
    ClearArray(LastReceivedContextIndexArray);

    Security = 0;
    Attraction = 0;
    Interest = 0;
    
    Anger = 0;
    Sadness = 0;
    Fear = 0;
    Enjoyment = 0;
    Love = "P0";
    Surprise = "P0";
    Disgust = 0;
    Shame = 0;

    var chat_log_window = document.getElementById('MainWindow_ChatWindow_ChatLog');
            
    if (chat_log_window != null)
    {
        chat_log_window.innerHTML = ChatLog;
    }    

    IsConversationStarted = false;
    IsConversationOver = false;

    var text_box = document.getElementById('MainWindow_TextBox_User');

    if(text_box != null)
    {
        text_box.value = "";
        text_box.focus();
    }
    
    else
    {
        Step1();
    }

    //urchinTracker('/mainpage/Restart');
}

function SendSentence()
{
    var text_box = document.getElementById('MainWindow_TextBox_User');

    if(text_box != null)
    {
    
        if(text_box.value == "")
        {
            return;
        }
    
        if(IsConversationOver)
        {
            text_box.value = "";
            text_box.focus();
            return;
        }
    
        else
        {
            var sentence = "<span style='color:blue; font-family:Rockwell;' id='Row_" + ++RowCount + "'><b>User: </b></span>";
            var current_value = "";
        
            current_value = text_box.value;
            sentence += ReplaceSymbols(current_value);
            text_box.value = "";
            text_box.focus();
        }
    }        
    
    else
    {
        return;
    }
    
    if(ChatLog != "")
    {
       ChatLog += "<br>";
    }    
    
    ChatLog += sentence;

    var chat_log_window = document.getElementById('MainWindow_ChatWindow_ChatLog');
            
    if (chat_log_window != null)
    {
        chat_log_window.innerHTML = ChatLog;
        cursorEOT(chat_log_window);
    }
    
    if(!IsConversationStarted && !IsConversationOver) // If conversation hasn't started yet
    {
        var right_part = document.getElementById('MainWindow_ChatWindow_Right');
        
        if(right_part != null)
        {
            right_part.style.backgroundImage="";                
        }
        
    
        var photo = document.getElementById('MainWindow_ChatWindow_Photo');
    
        if(photo != null)
        {
            photo.innerHTML = "<br/><br/><br/><p style='color:#333333; text-align:left;'>Connecting to server...<br/><br/><br/><span style='font-size:8pt;'>If page appears frozen please refresh and try again.</span></p>";
        }
    
        if(IsEmotionsDisplayed)
        {
            ShowFeelings();
        }
        
        else
        {   
           	HideFeelings();
        }

        IsConversationStarted = true;
        StartTimer();   // start the timer
        PageMethods.GetNewChatID(SetChatID, GetError, GetTimeout);
    }

    PageMethods.ASPSendSentence(GetUserData(false, current_value), GetAnswer, GetError, GetTimeout);
}

function GetSentence()
{
    PageMethods.ASPGetSentence(GetUserData(true, ""), AddServerChatHistory, GetError, GetTimeout);
}

function AddServerChatHistory(response)
{
    if (response == null)
    {
       return;
    }

    if(response != "")
    {

        if(IEVersion >= 8)
        {
            var restart_button = document.getElementById('MainWindow_StepDescription_Controls_Restart');

            if(restart_button != null)
            {
                restart_button.style.display = "block";
            }
        }

        var result = response;
        var new_ad = false;
        var new_photo = false;
        var new_sentence = false;
       
        MessageArray = result.split('\n');
        
        while(MessageArray.length > 0)
        {
            var tmp_msg = "";
            
            while( (tmp_msg == "") && MessageArray.length)
            {
                tmp_msg = MessageArray.shift();
            }
            
            if(tmp_msg != "")
            {
                var symbol = GetSymbol(tmp_msg);
        
                switch(symbol)
                {
        
                    case UserInformationSymbol:
                        UserInformationLog = tmp_msg;
                        UpdateUserInformation(tmp_msg);
                        new_ad = true;
                        break;
            
                    case OutputSymbol:
                        var tmp_array = new Array();
                        tmp_array = tmp_msg.split(BrainObject_Symbol);
                        StateLog += tmp_array[0];
                        UpdateOutput(tmp_msg);
                        new_photo = true;
                        break;
            
                    case MissingResponseSymbol:
                        UpdateMissingResponse(tmp_msg);
                        ChatLog += "<br><br style='font-size:1pt;'><span style='font-family:Arial; color:gray; font-size:9pt;' id='Row_" + ++RowCount + "'><b>Jenny couldn&#39;t understand the last sentence</b>. It has been added to our <b>Creation Forums</b>.<br>People from all around the world can now fill in her missing response.</span>";
                        new_sentence = true;
                        break;
                        
                    case ConversationOverSymbol:
                        UpdateConversationOver();
                        break;    
                
                    default:
                        tmp_msg = ReplaceSymbols(tmp_msg);
                        ReceivedResponsesArray[ReceivedResponsesArray.length] = tmp_msg;
                        ChatLog += "<br><span style='color:red; font-family:Rockwell;' id='Row_" + ++RowCount + "'><b>Jenny: </b></span>";
                        ChatLog += tmp_msg;
                        new_sentence = true;
                        break;
                }
            }                    
        }

        
        if(new_ad)
        {
            UpdateAds();
        }
        
        if(new_photo)
        {
            UpdateImage();

            var emotions_display = document.getElementById('Amygdala_Emotions');
            
            if (emotions_display != null)
            {
                UpdateEmotions();
            }
        }
        
        if(new_sentence)
        {
            var chat_log_window = document.getElementById('MainWindow_ChatWindow_ChatLog');
            
            if (chat_log_window != null)
            {
                chat_log_window.innerHTML = ChatLog;
                cursorEOT(chat_log_window);
            }  
        }
        
        var text_box = document.getElementById('MainWindow_TextBox_User');

        if(text_box != null)
        {
            text_box.focus();
        }


    }       
}   

function DisplayTalkBacksData(response)
{

  	document.body.style.cursor = "auto";

    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        var result = response;
        var str = "<table border=1 width='97%' style='background-color:#e6e6e3; border-color:#d0d1c6; border-style:ridge;'>";
        str += "<tr><td style='padding:5px;'>";
        str += "<p style='color:#992222;'>";
        str += "Usually, we have no policy of censorship; we will publish just about anything. ";
        str += "However, comments containing incitement, slander, racist slurs and inappropriate language deemed to violate our terms of use won't be published.";
        str += "</p>";
        str += "</td></tr>";
        str += "</table><br/><br/><br/>";
        

        str += "<span><img title='Add new topic' src='images/newtopic.jpg' onclick='NewTalkBack(" + Commas + Commas + ")' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'></span>&nbsp;&nbsp;";
        str += "<span style='vertical-align:top; font-size:14pt;' onclick='NewTalkBack(" + Commas + Commas + ")' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>New Topic</span>";
        str += "<br/><br/><br/>";
        
        str += "<div id = 'TopicDivider'>";

        var talk_back_data = result;
        
        if(talk_back_data)
        {
        
            var talk_back_array = new Array();
            talk_back_array = talk_back_data.split(TalkBackSeparator);

            str += "<table border=0>";
        
            var i;

            for(i=0; i < (talk_back_array.length - 1); i++)
            {
                var field = talk_back_array[i];
                var field_array = new Array();
            
                field_array = field.split(SubjectSeparator);

                var tmp_id = Commas + "TB_" + i + Commas;
                var tmp_subject = Commas + field_array[0] + Commas;
                var tmp_comment = Commas + field_array[3] + Commas;
            
                // subject
                str += "<tr>";
                str += "<td align='center' style='width:0px;'><img src='images/tack.jpg' title='Topic " + (talk_back_array.length - i - 1) + "'></td>";
                str += "<td align='left'><br style='font-size:4pt;'><span style='font-size:11pt;' ";
 
                str += " onclick='ShowTalkBack(" + tmp_id + "," + tmp_comment + "," + tmp_subject + ")' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'";
                str += ">" + field_array[0] + "</span>";
                
                str += "</td>";
                str += "</tr>";
                
                // name + date
                str += "<tr>";
                str += "<td></td>";
                str += "<td align='left'>";
                str += "<p style='color:#777777; font-size:10pt;'>" + field_array[1] + ", (" + field_array[2] + ")</p>";
                str += "</td>";
                str += "</tr>";

                str += "<tr><td></td><td align='left' id = '" + "TB_" + i + "'></td></tr>";
                
                delete field_array;
            }
                
            str += "</table>";
            str += "</div>";
        
            delete talk_back_array;
        }
        
        main_window.innerHTML = str;
    }    
}

function ShowTalkBack(id, comment, subject)
{
    comment = ReplaceSymbolsToBlank(comment);
    subject = ReplaceSymbolsToBlank(subject);
    
    var str = "<span><hr>";
    str += comment;
    str += "<hr></span>"; 
    str += "<img src='images/redx.jpg' title='Close topic' onclick=CloseTalkBack('" + id + "') onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>";
    str += "&nbsp;";
    str += "<span onclick=CloseTalkBack('" + id + "') onmouseover='makeOptional(this)' onmouseout='makeNormal(this)' style='vertical-align:top;'>";
    str += "Close";
    str += "</span>"; 
    str += "&nbsp;&nbsp;&nbsp;";
    str += "<img src='images/redarrow.jpg' title='Reply to this topic' onclick='NewTalkBack(" + Commas + subject + Commas + ");' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>";
    str += "<span onclick='NewTalkBack(" + Commas + subject + Commas + ");' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)' style='vertical-align:top;'>";
    str += " Reply";
    str += "</span><br/><br/>"; 
    
    var comment_box = document.getElementById(id);
    
    if(comment_box != null)
    {        
        comment_box.innerHTML = str;
    }
}

function CloseTalkBack(id)
{
    var comment_box = document.getElementById(id);
    
    if(comment_box != null)
    {        
        comment_box.innerHTML = "";
    }
}

function NewTalkBack(subject)
{
    var topic_divider = document.getElementById('TopicDivider');
    
    if(topic_divider != null)
    {
        if(subject != "")
        {
            subject = "Re:" + subject;
        }
        
        var str = "<table style='padding:10px;'>";

        str += "<tr>";
        str += "<td style='vertical-align:top;'>";
        str += "<span>Name:</span>";
        str += "</td>";
        str += "<td>";
        str += "<input type='text' id='TextBox_NewTopic_Name' style='width:250px;'>";
        str += "</td>";
        str += "</tr>";

        str += "<tr>";
        str += "<td style='vertical-align:top;'>";
        str += "<span>Subject:</span>";
        str += "</td>";
        str += "<td>";
        str += "<input type='text' id='TextBox_NewTopic_Subject' style='width:250px;' value='" + subject + "'>";
        str += "<br/><br/></td>";
        str += "</tr>";

        str += "<tr>";
        str += "<td style='vertical-align:top;'>";
        str += "<span>Comment:</span>";
        str += "</td>";
        str += "<td>";
        str += "<textarea id='TextArea_NewTopic_Comment' style='height:80px; width:250px;'></textarea>";
        str += "</td>";
        str += "</tr>";

        str += "<tr>";
        str += "<td></td>";
        str += "<td>";
        str += "<br/><hr>";
        str += "</td>";
        str += "</tr>";

        str += "<tr>";
        str += "<td></td>";
        str += "<td>";
        str += "<img src='images/submittopic.jpg' title='Submit topic' onclick='AddNewTalkBackToServer()' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>";
        str += "<span style='font-size:11pt; vertical-align:top;' onclick='AddNewTalkBackToServer()' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>Submit</span>";
        str += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        str += "<img src='images/canceltopic.jpg' title='Cancel' onclick='Comments()' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>";
        str += "<span style='font-size:11pt; vertical-align:top;' onclick='Comments()' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>Cancel</span>";
        str += "</td>";
        str += "</tr>";

        str += "</table>";
        
        topic_divider.innerHTML = str;
        
        var text_box_name = document.getElementById("TextBox_NewTopic_Name");
        
        if(text_box_name != null)
        {
            text_box_name.focus();
        }
    }
}

function AddNewTalkBackToServer()
{
    
    var text_box_subject = document.getElementById("TextBox_NewTopic_Subject");
    
    if(text_box_subject != null)
    {
        if (text_box_subject.value == "")
        {
            alert("Subject is required");
            return;
        }
    }
    
    else
    {
        return;
    }
    

    var text_box_name = document.getElementById("TextBox_NewTopic_Name");
    
    if(text_box_name != null)
    {
        if (text_box_name.value == "")
        {
            alert("Name is required");
            return;
        }
    }
    
    else
    {
        return;
    }
    
  	document.body.style.cursor = "wait";

  	PageMethods.SaveTalkBacksData(GetNewTalkBackData(), DisplayTalkBacksData, GetError, GetTimeout);
}

function GetNewTalkBackData()
{
    var str = "";
    
    var text_box_subject = document.getElementById("TextBox_NewTopic_Subject");
    
    if(text_box_subject != null)
    {
        str += text_box_subject.value + "\n";
    }
    
    else
    {
        return "";
    }
    
    var text_box_name = document.getElementById("TextBox_NewTopic_Name");
    
    if(text_box_name != null)
    {
        str += text_box_name.value + "\n";
    }
    
    else
    {
        return "";
    }
    
    
    var text_area_comment = document.getElementById("TextArea_NewTopic_Comment");
    
    if(text_area_comment != null)
    {
        str += text_area_comment.value;
    }
    
    else
    {
        return "";
    }
    
    return str;
}

function GetUserData(only_user_name, message)
{
    var str = "%";
    str += UserID;
    str += "%";
    
    if(!only_user_name)
    {
        str += message;
    }
    
    return str;
}

function GetActualChatLog()
{
    var start_symbol = "<!--Start-->";
    var i = ChatLog.indexOf(start_symbol);
            
    var chat_log;
            
    if(i != -1)
    {
        chat_log = ChatLog.substr(i + start_symbol.length, ChatLog.length - (i + start_symbol.length) );
    }
            
    else
    {
        chat_log = ChatLog;
    }
    
    return chat_log;
}

function ScrollToMiddle(containerID, elID)
{
	// If element does not Exist then return
	var el = document.getElementById(elID);
	if (el == null) return;
	
	// If container does not Exist then return
	var container = document.getElementById(containerID);
	
	if (container == null)
	{
	    return;
    }
	
    var scroll_pos = document.documentElement.scrollTop;

	// Position container at the top line then scroll el into view
	container.scrollTop = 0;
	el.scrollIntoView(false);

    document.documentElement.scrollTop = scroll_pos;

	// Scroll forward nothing if element is at the beginning of container else do it
	// for half the height of the containers display area
	var scrollForward = (container.scrollTop > 0) ? container.clientHeight/2 : 0;
    container.scrollTop = container.scrollTop + scrollForward;
}

function DisplayChatLog(message, for_response)
{
    var chat_log_window = document.getElementById('MainWindow_ChatLog');
            
    if (chat_log_window != null)
    {
        if(message != "")
        {
            message = ReplaceSymbols(message);
            
            var chat_log = GetActualChatLog();            

            var i=0;
            var tmp_index=0;
            
            while(i != -1)
            {
                i = chat_log.indexOf(message,tmp_index);
                                
                if(i != -1)
                {
                    var first = chat_log.substr(0, i);
                    var second = chat_log.substr(i + message.length, chat_log.length - i - message.length);
                    var open_span = "<span style='color:green' id='SelectedRow'><b>";
                    var close_span = "</b></span>";
                    chat_log = first + open_span + message + close_span + second;
                    tmp_index = i + open_span.length + message.length + close_span.length;
                }
            }
            
            var str = "<p><b>Context:<b></p>";
            str += chat_log;
            
            chat_log_window.innerHTML = str;
            
            ScrollToMiddle("MainWindow_ChatLog","SelectedRow");
            
        }
        
        else
        {
            var str = "";
            var array_length = 0;
            
            if(for_response)
            {
               array_length = ReceivedResponsesArray.length / 2;
            }
            
            else
            {
               array_length = MissingResponsesArray.length / 2;
            }
        
            if(array_length > 6)
            {
                array_length = 6;
            }
        
            for(i=0; i < array_length; i++)
            {
                str += "<br/>";
            }
        
            str += "<table><tr>";
            str += "<td valign=middle><span style=''><img src='images/leftbluearrow.jpg'></span></td>";
            str += "<td><span style='color:#2a3131;'>";
            
            if(for_response == true) // Jenny's response
            {
                str += "Click on one of the responses to see Jenny&#39;s state of mind at any point during the conversation";
            }
            
            else // Missing response
            {
                str += "Click on one of the unrecognizable sentences to to fill in Jenny&#39;s missing response";
            }
                
            str += "</span></td>";
            str += "</tr></table>";
            
            chat_log_window.innerHTML = str;
        }
        
    }
}

function AddNickName()
{
    
    if(NickName == "")
    {
        var main_window = document.getElementById('MainWindow');
    
        if(main_window != null)
        {    
            //var str = GetStepTopSection(3,MaxStep);

            var str = "<div id ='MainWindow_MainSection'>";    
            str += "<div style='padding:20px;'>";    
        
            str += "<br><br><span style='font-size:15pt;'><b>Would you like to add your nickname?</b></span><br><br><br style='font-size:8pt;'>";
            str += "<br/><span style='color:#313881'>Adding your nickname will allow you receiving credit for your score and chat logs.</span>";
            str += "<br/><br/><br style='font-size:4pt;'>Nickname:&nbsp;&nbsp;&nbsp;<input id='TextBox_NickName' type='text' style='' /><br><br><br/><br/>";
            str += "<input type='checkbox' id='CheckBox_NewsLetter' onclick='DisableOrEnableNewsLetter()' CHECKED><span style='color:#313881'> Also subscribe me to our Free Newsletter!</span><br/><br/><br style='font-size:4pt;'>";
            str += "<span id='NewsLetter'>Your email: &nbsp;<input type='text' id='TextBox_Email'></span><br/><br/><br/><br/>";
            //str += "<hr style='width:265px;'>";
            str += "<hr/>";
    
            str += "<img src='images/submittopic.jpg' title='Use nickname' onclick='UpdateNickName(true)' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>";
            str += "<span style='font-size:11pt; vertical-align:top;' onclick='UpdateNickName(true)' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>Yes</span>";
            str += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            str += "<img src='images/canceltopic.jpg' title='Don&#39;t use nickname' onclick='UpdateNickName(false)' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>";
            str += "<span style='font-size:11pt; vertical-align:top;' onclick='UpdateNickName(false)' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>No thanks</span>";
            str += "</div>";    
            str += "</div>";    

            //str += "<div id='MainWindow_StepControls'>";
            //str += "</div>";
        
            main_window.innerHTML = str;
        }
            
        var textbox_nickname = document.getElementById('TextBox_NickName');
    
        if(textbox_nickname != null)
        {
            textbox_nickname.focus();
            textbox_nickname.focus();
        }
    }
    
    else
    {
      	document.body.style.cursor = "wait";
      	PageMethods.AddNickNameData(GetNickNameData(), ThankYou, GetError, GetTimeout);
    }
}

function EmailCheck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		
		if (str.indexOf(at)==-1){
		   alert("Invalid email");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid email");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid email");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid email");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid email");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid email");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid email");
		    return false;
		 }

 		 return true;
	}

function DisableOrEnableNewsLetter()
{
    var checkbox_newsletter = document.getElementById('CheckBox_NewsLetter');
    
    if(checkbox_newsletter != null)
    {
        if(checkbox_newsletter.checked)
        {
            var news_letter = document.getElementById('NewsLetter');

            if(news_letter != null)
            {
                news_letter.innerHTML = "Your email: <input type='text' id='TextBox_Email'>";
            }

            var textbox_email = document.getElementById('TextBox_Email');
    
            if(textbox_email != null)
            {
                textbox_email.focus();
                textbox_email.focus();
            }
        }

        else
        {
            var news_letter = document.getElementById('NewsLetter');

            if(news_letter != null)
            {
                news_letter.innerHTML = "";
            }
        }
    }            
}

function UpdateNickName(/*use_nickname*/)
{
    /*if(use_nickname)
    {*/
        var textbox_nickname = document.getElementById('TextBox_NickName');
    
        if(textbox_nickname != null)
        {
            if(textbox_nickname.value == "")
            {
                alert("Please fill in your nickname");
                textbox_nickname.focus();
                textbox_nickname.focus();
                return;
            }
            
            else
            {
                NickName = textbox_nickname.value;

                var textbox_email = document.getElementById('TextBox_Email');
    
                if(textbox_email != null)
                {
                    if( !EmailCheck(textbox_email.value) )
                    {
                        textbox_email.focus();
                        textbox_email.focus();
                        return;
                    }
                    
                    else
                    {
                        Email = textbox_email.value;
                        DisplayWaitNotification();
                      	document.body.style.cursor = "wait";
                      	PageMethods.AddNewsLetterData(GetNewsLetterData(), GetAnswer, GetError, GetTimeout);
                        GetScore();
                    }
                }
                
                else
                {
                    DisplayWaitNotification();
                  	document.body.style.cursor = "wait";
                  	PageMethods.AddNickNameData(GetNickNameData(), GetAnswer, GetError, GetTimeout);
                    GetScore();
                }
                
            }                
        }    
    /*}
    
    else
    {
        NickName = "Anonymous";
        DisplayWaitNotification();
      	document.body.style.cursor = "wait";
        PageMethods.AddNickNameData(GetNickNameData(),ThankYou);
        GetScore();
    }*/
}

function DisplayWaitNotification()
{
    var main_window = document.getElementById('MainWindow');

    if(main_window != null)
    {
        main_window.style.backgroundImage="";
        
        var str = "<p style='font-size:12pt;'>Processing request... Please wait</p><br/>";
        str += "<p style='font-size:12pt;'>If page appears frozen please refresh and try again</p>";
        
        main_window.innerHTML = str;
    }        
}

function GetNickNameData()
{
    var str = ChatID;
    str += "%FS%";
    str += NickName;
    
    return str;
}

function GetNewsLetterData()
{
    var str = ChatID;
    str += "%FS%";
    str += NickName;
    str += "%FS%";
    str += Email;
    
    return str;
}

function ThankYou()
{
    document.body.style.cursor = "wait";
    PageMethods.GetThankYouData(DisplayThankYou, GetError, GetTimeout);
}

function DisplayThankYou(response)
{
  	document.body.style.cursor = "auto";

    if (response == null)
    {
       return;
    }

    var result = response;
  	
    var main_section = document.getElementById('MainWindow');
    
    if(main_section != null)
    {
        var data_array = new Array();
        data_array = result.split("|");
        
        var str = "";
        str += "<table border=0>";
        str += "<tr>";
        str += "<td style='width:610px; height:240px;' valign=top>";
        str += "<span style='font-size:22pt;'>Thank you for your help!</span><br><br><br><br>";
        str += "<span style='font-size:12pt; color:#313881;'>You are an important and unique part in the creation of the first<br>Artificial Emotional Intelligence (AEI).</span><br><br><br>";
            

        var i;
        
        if(MissingResponsesArray.length)
        {
            str += "<span style='font-size:10pt; color:#313881;'>Thanks to you, the following sentences have been added to our <span style='color:blue;' onmouseover='body.style.cursor = " + Commas + "pointer" + Commas + "' onmouseout='body.style.cursor = " + Commas + "auto" + Commas + "' onclick='CreationForums()' title='Join the collaborative effort to create Jenny!'><u>Creation Forums</u></span>:</span><br><br>";
            
            str += "<div id='MissingSentencesList'><table style='width:450px;'>";
                
            for(i=0; i < MissingResponsesArray.length; i++)
            {
                if(MissingResponsesArray[i] != "")
                {
                    str += "<tr><td";
                    str += ">" + (i+1) + ". ";
                    str += MissingResponsesArray[i];
                    str += "</td></tr>";
                }    
            }

            str += "</table></div>";
        }

        str += "<br/>";
        str += "</td>";
        str += "<td valign=bottom align=right>";
        
        str += "<img src='images/ThankYou2.jpg'/>";
        
        /*str += "<span style='font-size:14pt;'><b>Top 10 Scores:</b></span><br><br>";
        str += "<table style='width:100%; border:2px solid #bbb;'>";
        str += "<tr style='background-color:#bbb;'><td style='width:120px;'><b>Name</b></td><td style='width:120px;'><b>Score</b></td></tr>";
        
        var top_ten_data = data_array[0];
        var top_ten_array = new Array();
        top_ten_array = top_ten_data.split("~");
        
        for(i=0; i < top_ten_array.length; i++)
        {
            str += "<tr style='background-color:#ffeeee;'><td style='border-top:1px solid #bbb;'><span style='font-family:Courier New; font-size:10pt; color:#cb1616'>";
            
            var tmp_array = new Array();
            var tmp_str = top_ten_array[i];
            tmp_array = tmp_str.split("%");
            
            if(tmp_array[1] == "")
            {
                str += "Anonymous";
            }
            
            else
            {
                str += tmp_array[1];
            }
                            
            str += "</span></td><td style='border-top:1px solid #bbb;'><span style='font-family:Courier New; font-size:10pt; color:#cb1616'>";
            str += tmp_array[0];
            str += "</span>";*/
            str += "</td></tr>";
        //}
                    
        //str += "</table>";
        //str += "<img src='images/ThankYou2.jpg'/>";
        //str += "</td>";
        //str += "</tr>";
        /*str += "<tr>";
        str += "<td>";
        str += "<button onclick='Final()' style='width:75px;'>OK</button><br>";
        str += "</td>";
        str += "</tr>";*/
        str += "<tr>";
        str += "<td colspan=2 valign=top>";
        str += "<hr>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";

        str += "<table border=0>";




        str += "<tr>";
        str += "<td colspan=2>";
        str += "<span style='font-size:16pt;'>";
        str += "<b>What would you like to do now?</b>";
        str += "<br/><br/>";
        str += "</td>";
        str += "</tr>";

        if(MissingResponsesArray.length)
        {
            str += "<tr>";
            str += "<td style='width:30px;'>";
            str += "<img src='images/play_arrow.jpg'>";
            str += "</td>";
            str += "<td>";
            str += "<span style='font-family:Arial Rounded MT Bold; color:#08036c; font-size:12pt;' onmouseover='makePromoStepOptional(this)' onmouseout='makePromoStepNormal(this)' onclick='CreationForums()' title='Teach Jenny all the things she couldn&#39;t understand'>";
            str += "Join our Creation Forums and fill in Jenny&#39;s missing responses";
            str += "</span>";
            str += "</td>";
            str += "</tr>";
        }

        str += "<tr>";
        str += "<td style='width:30px;'>";
        str += "<img src='images/play_arrow.jpg'>";
        str += "</td>";
        str += "<td>";
        str += "<span style='font-family:Arial Rounded MT Bold; color:#08036c; font-size:12pt;' onmouseover='makePromoStepOptional(this)' onmouseout='makePromoStepNormal(this)' onclick='window.open(\"" + data_array[0] + "\")' title='Improve your skills now!'>";
        str += "Learn more about improving your skills with women";
        str += "</span>";
        str += "</td>";
        str += "</tr>";

        str += "<tr>";
        str += "<td style='width:30px;'>";
        str += "<img src='images/play_arrow.jpg'>";
        str += "</td>";
        str += "<td>";
        str += "<span style='font-family:Arial Rounded MT Bold; color:#08036c; font-size:12pt;' onmouseover='makePromoStepOptional(this)' onmouseout='makePromoStepNormal(this)' onclick='window.open(\"" + data_array[1] + "\")' title='Use you skills to meet real women'>";
        str += "Find hot women online";
        str += "</span>";
        str += "</td>";
        str += "</tr>";

        str += "<tr>";
        str += "<td style='width:30px;'>";
        str += "<img src='images/play_arrow.jpg'>";
        str += "</td>";
        str += "<td>";
        str += "<span style='font-family:Arial Rounded MT Bold; color:#08036c; font-size:12pt;' onmouseover='makePromoStepOptional(this)' onmouseout='makePromoStepNormal(this)' onclick='Restart()' title='Talk to Jenny again'>";
        str += "Restart the conversation and talk to Jenny again";
        str += "</span>";
        str += "</td>";
        str += "</tr>";

        //str += "<td>";
        //str += "<img src='images/ThankYou2.jpg' style='height:170px;'/>";
        //str += "</td>";

        //str += "</tr>";
        str += "</table>";
        
        main_section.innerHTML = str;
    }
    
    //urchinTracker('/mainpage/ThankYou');
}

function AddNewChatMissingResponses(unrecognized_sentence, context_index)
{
    CurrentStringData = ChatID + "%FS%";
    CurrentStringData += unrecognized_sentence + "%FS%";

    var i=0;
    
    for(i=0; i < 8; i++)
    {
        CurrentStringData += "ToDo: Fill responses";
            
           if(i < 7)
           {
               CurrentStringData += "%FS%";
           }
    }
    
    CurrentContextIndexData = context_index;

    if(NickName == "")
    {
        NickName = "Server";
    }

    PageMethods.AddNewMissingResponse(GetMissingResponsesData(), GetAnswer, GetError, GetTimeout);
}

function GetMissingResponsesData()
{
    var str = CurrentStringData;
    str += "%FS%";
    str += CurrentContextIndexData;
    str += "%FS%";
    str += NickName;
    
    if(NickName == "Server")
    {
        NickName = "";
    }
    
    return str;        
}

function GetChatData()
{
    var str = ChatID;
    str += "%FS%";
    str += GetActualChatLog();
    str += "%FS%";
    str += StateLog;
    str += "%FS%";
    str += "Name: ";
    str += UserInformation_Name;
    str += "<br>";
    str += "Age: ";
    str += UserInformation_Age;
    str += "<br>";
    str += "Location: ";
    str += UserInformation_Location;
    str += "<br>";
    str += "Occupation: ";
    str += UserInformation_Occupation;
    str += "<br>";
    str += "Academic Level: ";
    str += UserInformation_AcademicLevel;
    str += "%FS%";
    str += Score;
    str += "%FS%";
    str += NickName;
    
    return str;
}

function AboutJenny()
{
    /*if(IsConversationStarted)
    {
        PageMethods.ASPReleaseWaitEvent(UserID);
        StopTimer();
    }*/
    
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        main_window.style.backgroundImage="";
        
        var str = "<h1 class='PageHeader'>About Jenny</h1>";

        str += "<p>Jenny is a virtual woman who behaves just as an actual human would. She can chat with you online, share her thoughts and dreams. Jenny is the only virtual woman who can actually feel! Her actions mirror authentic human behavior patterns.</p>";

        str += "<table border=0>";
        str += "<tr>";
        str += "<td>";
        str += "<h2 class='TextHeader'>Artificial Emotional Intelligence</h2>";
        str += "<p>You have heard of Artificial Intelligence (AI) and you have heard of Emotional Intelligence (EQ). With the introduction of entire virtual worlds such as Second Life, Artificial Emotional Intelligence (AEI) is the next step in Virtual Reality. It is the combination of pure Artificial Intelligence, affected by emotions and feelings. AEI is the only form of Artificial Intelligence that can accurately imitate authentic human behavior.<br>Jenny is the embodiment of AEI; in contrast to existing computerized chat simulations, Jenny takes technology a step further. TA Vision's innovative <span style='font-family: Times New Roman;'>InsightI™</span> engine implements scientific theories to create mathematical models that enable Jenny's actions and reactions to mirror authentic human behavior patterns.</p>";
        str += "<br><h2 class='TextHeader'>Worldwide collaborative effort to create Jenny</h2>";
        str += "<p>Web 2.0 offers the opportunity for anyone to contribute to content on the Internet. The popularity of websites such as YouTube and Wikipedia are just two examples of how people want to contribute to knowledge. Internet users around the world now have the opportunity to contribute to the creation of Jenny. Her potential reactions are created and revised by people around the globe; together they form one single virtual personality. You too, can participate by talking to her; at the end of the conversation you will be given the opportunity to teach Jenny all the things she didn't understand.</p>";
        str += "</td>";
        str += "<td>";
        str += "<img src='images/AboutJenny.jpg'>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";

        str += "<h2 class='TextHeader'><span style='font-family: Times New Roman;'>InsightI™</span> Simulation Engine</h2>";
        str += "<p>TA Vision's innovative <span style='font-family: Times New Roman;'>InsightI™</span> engine is an Artificial Emotional Intelligence (AEI) simulation that generates virtual conversations. In the core of the system’s decision making process, exist five different mathematical models. These models operate fully synchronized with one another to simulate the five major regions of the human brain and the interactions between them. To do so, the simulation receives verbal messages or sensory signals from a user and analyzes them. The resulting output is a reaction (verbal or emotional) which is transferred to the user.</p>";
        str += "<p>When the system receives a signal, a variety of actions take place simultaneously. Some factors taken into consideration are the simulation's active emotions and the impressions that the user has made. One such factor that influences the system’s possible reactions, is the information that the simulation collects from the user. Data such as the user’s age, socio-economic level, and measure of seriousness is tested while the simulation composes a response. The simulation displays this data constantly and consequently, anyone can review the user’s decisions and level of success (relative to the goal that was selected) in real time.</p>";
        str += "<p>The simulation’s engine can serve as a platform for various business ideas that are based on human interactions and conversations. Its databases can be programmed in ways that can simulate a wide range of conversations. Because the simulation is separated from the program’s interface, it can be implemented by all the computer languages that support COM Components (C, C++, MFC, VB, Java, .NET) and can be applied in many different ways. For instance: interactive movies, internet chatting, 3D applications. Other simplistic applications can also be used through it.</p>";

        main_window.innerHTML = str;
    }    

    //urchinTracker('/mainpage/AboutJenny');
}

function TheModel()
{
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        main_window.style.backgroundImage="";
        
        var str = "<h1 class='PageHeader'>The Model Behind Jenny</h1>";
        str += "<br/><table border=0>";
        str += "<tr><td valign=top>";
        str += "<h2 class='TextHeader'>The face behind Jenny belongs to 21 year-old UK glamour model Amy Reddish.</h2>";
        str += "<br><p>Amy is a lingerie and swimwear model from Manchester, England. Since 2007, she has appeared in many";
        str += " <span style='color:blue;' onmouseover='body.style.cursor = " + Commas + "pointer" + Commas + "' onmouseout='body.style.cursor = " + Commas + "auto" + Commas + "' onclick='window.open(" + Commas + "http://www.amyreddish.com/Amy-Reddish-UK-Model-Gallery/amy-reddish-uk-model-gallery.html" + Commas + ")' title='See Amy modeling in various magazines'><u>UK magazines</u></span> ";
        str += "and excelled in numerous beauty competitions. Her upcoming international modeling career is on the move!</p>";
        str += "<p>We selected Amy out of many other candidates to be the next Face of Jenny because she best expresses what Jenny is all about: sexy yet classy, striking yet approachable.</p>";
        str += "<p><br/><br/>Please visit Amy's official website at:</p>";
        str += "<p><span style='color:blue;' onmouseover='body.style.cursor = " + Commas + "pointer" + Commas + "' onmouseout='body.style.cursor = " + Commas + "auto" + Commas + "' onclick='window.open(" + Commas + "http://www.amyreddish.com/" + Commas + ")'  title='Check out her website'><u>www.AmyReddish.com</u></span></p>";
        str += "</td>";

        str += "<td valign=top>";
        str += "&nbsp;&nbsp;&nbsp;</td>";

        str += "<td valign=top>";
        str += "<img src='images/amyreddish.jpg'>";
        str += "</td>";

        str += "<td valign=top>";
        str += "&nbsp;&nbsp;</td></tr>";

        str += "</table>";
        main_window.innerHTML = str;
    }
    
    //urchinTracker('/mainpage/TheModel');
}

function FAQ()
{
    /*if(IsConversationStarted)
    {
        PageMethods.ASPReleaseWaitEvent(UserID);
        StopTimer();
    }*/
    
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        main_window.style.backgroundImage="";
        
        var str = "<h1 class='PageHeader'>Frequently Asked Questions </h1>";

        str += "<table border=0>";
        str += "<tr>";
        str += "<td>";
        str += "<h2 class='TextHeader'>Who exactly is Jenny?</h2>";
        str += "<p>Jenny is a virtual woman who behaves just as an actual human would. In other words, Jenny is a computerized Artificial Intelligence who can chat with you, think and feel.</p>";
        str += "<br style='font-size:8pt;'>";
        str += "<h2 class='TextHeader'>Who created Jenny?</h2>";
        str += "<p>Jenny's responses and reactions are created by people from all around the world. Internet users chat with her online and teach her all the things she doesn't understand. It is the first worldwide collaborative effort to create an Artificial Emotional Intelligence (AEI).</p>";
        str += "<br style='font-size:8pt;'>";
        str += "<h2 class='TextHeader'>How can Jenny think and feel?</h2>";
        str += "<p>TA Vision's innovative <span style='font-family: Times New Roman;'>InsightI™</span> engine implements scientific theories to create mathematical models that enable Jenny's actions and reactions to mirror authentic human behavior patterns. Thanks to this new technology, Jenny can think and feel just like the rest of us.</p>";
        str += "</td>";
        str += "<td>";
        str += "<img src='images/questionmark.jpg'>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";

        str += "<h2 class='TextHeader'>What makes Jenny unique?</h2>";
        str += "<p>In contrast to existing computerized chat simulations, Jenny takes technology a step further. She is the only virtual woman who can actually feel! Human emotions affect us all, and without them, it's impossible to simulate any authentic behavior patterns. Jenny is capable of feeling, and therefore represents the first real attempt to create a humanized virtual character.</p>";
        str += "<br style='font-size:8pt;'>";
        str += "<h2 class='TextHeader'>How can I participate?</h2>";
        str += "<p>You too can participate by talking to Jenny; during the conversation, the sentences she doesn't understand are automatically logged to our separate Creation Forums. People from around the world attend these forums to teach Jenny all the things she couldn't understand and fill in her missing responses. Gradually, with your help, we believe we can create the smartest Artificial Intelligence ever to exist!</p>";
        str += "<br style='font-size:8pt;'>";
        str += "<h2 class='TextHeader'>How else can I help?</h2>";
        str += "<p>We would greatly appreciate any feedback you send to us.<br><br> Please contact us at&nbsp;&nbsp;<a href='mailto:Feedback@CreateJenny.com'>Feedback@CreateJenny.com</a>.</p>";
        str += "<br style='font-size:8pt;'>";
        str += "<h2 class='TextHeader'>What do I get in return?</h2>";
        str += "<p>Besides the satisfaction of being an important part of the creation of the first Artificial Emotional Intelligence (AEI), you can also receive a score based on your performance during the conversation. This way, you can enhance your social skills with women (if you're a guy), or learn new ways of how to succeed with guys (if you're a girl).</p>";
        str += "<br style='font-size:8pt;'>";
        str += "<h2 class='TextHeader'>Am I expected to pay?</h2>";
        str += "<p>Not at all. Jenny symbolizes a worldwide collaborative effort to create the first Artificial Emotional Intelligence (AEI), and belongs to all of us.</p>";
        str += "<br style='font-size:8pt;'>";
        str += "<h2 class='TextHeader'>What is Artificial Emotional Intelligence (AEI) and what does it have to do with Jenny?</h2>";
        str += "<p>You have heard of Artificial Intelligence (AI) and you have heard of Emotional Intelligence (EQ). With the introduction of entire virtual worlds such as Second Life, Artificial Emotional Intelligence (AEI) is the next step in Virtual Reality. It is the combination of pure Artificial Intelligence, affected by emotions and feelings. AEI is the only form of Artificial Intelligence that can accurately imitate authentic human behavior.<br>Jenny is the embodiment of AEI; in contrast to existing computerized chat simulations, Jenny takes technology a step further. TA Vision's innovative <span style='font-family: Times New Roman;'>InsightI™</span> engine implements scientific theories to create mathematical models that enable Jenny's actions and reactions to mirror authentic human behavior patterns.</p>";
        str += "<br style='font-size:8pt;'>";
        str += "<h2 class='TextHeader'>When is the official opening?</h2>";
        str += "<p>Currently we are working on Jenny's Alpha testing. We expect to finalize this website around June 2008.</p>";
        str += "<br style='font-size:8pt;'>";
        str += "<h2 class='TextHeader'>What else is planned?</h2>";
        str += "<p>In order to facilitate the creation process, we are developing separate creation forums. These forums will focus on all the missing data that wasn't completed by the users themselves. This will allow other internet users to fill in Jenny's reactions without actually talking to Jenny.<br>In addition, a link platform to Linden's Second Life is now being tested. Once completed, it will give Jenny a whole new access to the Second Life virtual world, with virtual body and appearance.</p>";
        str += "<br style='font-size:8pt;'>";
        str += "<h2 class='TextHeader'>Who's behind this initiative?</h2>";
        str += "<p>T.A. Vision Ltd. is the startup company behind CreateJenny.com.<br>This software development company was founded in 2006. It is dedicated to the development of sophisticated online AI applications for various needs.</p>";
        str += "<p>For more information about TA Vision, please visit our website at&nbsp;&nbsp;<a href='http://www.TA-Vision.com'>www.TA-Vision.com</a>.</p>";
        str += "<br style='font-size:8pt;'>";
        str += "<h2 class='TextHeader'>Who's the model behind the character?</h2>";
        str += "<p>The face behind Jenny belongs to 21 year-old UK glamour model Amy Reddish.</p>";
        str += "<p>Please visit her official website at&nbsp;&nbsp;<a href='http://www.AmyReddish.com'>www.AmyReddish.com</a>.</p>";
        
        main_window.innerHTML = str;
    }    

    //urchinTracker('/mainpage/FAQ');
}

function Home()
{
    /*if(IsConversationStarted)
    {
        PageMethods.ASPReleaseWaitEvent(UserID);
        StopTimer();
    }*/
    
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        main_window.style.backgroundImage="url(images/homebg.jpg)";
        
        var str = "<div id='MainWindow_PromoText'>";
        str += "<table border=0><tr><td valign=top>";
        str += "<span style='font-family:Arial Rounded MT Bold; color:#08036c; font-size:14pt;'>Welcome to CreateJenny.com!</span>";
        str += "&nbsp;&nbsp;&nbsp;";
        str += "<span style='font-family:Courier New; font-size:10pt; color:#cb1616'>Alpha version</span><br/>";
        str += "<br/><br/>";
        str += "<span style='font-size:13pt;'>Jenny is a <b>virtual woman</b> who behaves just as an actual human would.<br>Her responses and reactions are created by people from all around the world.<br><br>You too can <span style='color:blue;' onmouseover='body.style.cursor = " + Commas + "pointer" + Commas + "' onmouseout='body.style.cursor = " + Commas + "auto" + Commas + "' onclick='Step1()' title='Start the conversation'><u>talk to Jenny</u></span> and help create her.</span>";
        str += "</td><td style='width:70px;'>&nbsp;</td>"
        str += "</td><td valign=top>";
        str += "&nbsp;&nbsp;<img src='images/facebook.jpg' title='Try our new Facebook application!' onclick='window.open(" + Commas + "http://apps.facebook.com/createjenny/" + Commas + ")' onmouseover='body.style.cursor = " + Commas + "pointer" + Commas + "' onmouseout='body.style.cursor = " + Commas + "auto" + Commas + "' onclick='CreationForums()'/>"
        str += "</td></tr></table>";
        
        str += "<br style='font-size:4pt;'/>";
        str += "<br/>";
        str += "<br/>";
        str += "<span style='font-family:Arial Rounded MT Bold; color:#08036c; font-size:13pt;'>To create Jenny follow the next steps:</span>";
        str += "<br/>";
        str += "<br/>";
        str += "<br/>";
        //str += "</div>";
        
        
        /*str += "<div id='MainWindow_PromoMovie'><br>"


        if(document.all) // If Explorer
        {
            str += "<OBJECT style='border:2px outset #bbb9ba;' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
        } 
        
        else // If FireFox (outset feature doesn't work well in firefox)
        {
            str += "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
        }

        str += "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'";
        str += "WIDTH='176' HEIGHT='213' id='WebsitePromo_IE'>";
        str += "<PARAM NAME=movie VALUE='flash/CreateJenny - WebsitePromo.swf'>";
        str += "<PARAM NAME=quality VALUE=best>";
        str += "<PARAM NAME=bgcolor VALUE=#FFFFFF>";
        str += "<EMBED play=false id='WebsitePromo_FF' src='flash/CreateJenny - WebsitePromo.swf' quality=best bgcolor=#FFFFFF WIDTH='176' HEIGHT='213'";
        str += "NAME='CreateJenny - WebsitePromo' ALIGN='' TYPE='application/x-shockwave-flash'";
        str += "PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED>";
        str += "</OBJECT>";
        
        str += "</div>";*/

        //str += "<div>";

        str += "<span style='font-family:Arial Rounded MT Bold; color:#08036c; font-size:11pt;' onmouseover='makePromoStepOptional(this)' onmouseout='makePromoStepNormal(this)' onclick='Step1()' title='Start the conversation'>1. " + Str_Step1 + "</span>";
        str += "<br><br>";
        str += "&nbsp;&nbsp;&nbsp;<img src='images/bluearrow.jpg'>&nbsp;&nbsp;Meet Jenny in a cafe and start a conversation with her.";
        str += "<br><br>";
        str += "<span style='font-family:Arial Rounded MT Bold; color:#08036c; font-size:11pt;";

        if(MaxStep > 1)
        {       
            str += "' onmouseover='makePromoStepOptional(this)' onmouseout='makePromoStepNormal(this)' onclick='Step2()' title='Get a score for your performance'"
        }
        
        else
        {
            str += " cursor:not-allowed;' title='First complete step 1'";
        }
        
        str += ">2. " + Str_Step2 + "</span>";        
        str += "<br><br>";
        str += "&nbsp;&nbsp;&nbsp;<img src='images/bluearrow.jpg'>&nbsp;&nbsp;Receive a score based on your performance.";
        str += "<br><br>";
        str += "<span style='font-family:Arial Rounded MT Bold; color:#08036c; font-size:11pt;";

        if(MaxStep > 2)
        {       
            str += "' onmouseover='makePromoStepOptional(this)' onmouseout='makePromoStepNormal(this)' onclick='Step3()' title='Get feedback and tips for your performance.'"
        }
        
        else
        {
            str += " cursor:not-allowed;' title='First complete step 2'";
        }
        
        str += ">3. " + Str_Step3 + "</span>";
        //str += "<span style='font-family:Courier New; font-size:11pt; color:#cb1616'>&nbsp;&nbsp;<b>-Under Construction-</b></span>";
        str += "<br><br>";
        str += "&nbsp;&nbsp;&nbsp;<img src='images/bluearrow.jpg'>&nbsp;&nbsp;See what Jenny thinks about you and receive feedback.";
        str += "<br/>";
        str += "<br/>";
        str += "<br/>";
        str += "<br style='font-size:3pt;'/>";
        str += "<span style='font-size:11pt;'>Jenny might not understand everything you say.<br>Your unrecognized sentences will be added to our <span style='color:blue;' onmouseover='body.style.cursor = " + Commas + "pointer" + Commas + "' onmouseout='body.style.cursor = " + Commas + "auto" + Commas + "' onclick='CreationForums()' title='Join the collaborative effort to create Jenny!'><u>Creation Forums</u></span> , where users can fill in her missing responses.";

        str += "</div>"

        main_window.innerHTML = str;
        
    }        

    //urchinTracker('/mainpage/Home');        
}

function TalkToJenny()
{
  	document.body.style.cursor = "wait";

    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {

        main_window.style.backgroundImage="";

        var str = GetStepTopSection(1,MaxStep);

        str += "<div id ='MainWindow_MainSection'>";
        str += "<div id='MainWindow_ChatWindow_Left'>";
        str += "<div id='MainWindow_ChatWindow_ChatLog'>";
        str += "</div>"; //MainWindow_ChatWindow_ChatLog

        str += "<div id='MainWindow_SpaceDivider'></div>";
        str += "<div id='MainWindow_TextWindow'>";
        str += "<div id='MainWindow_TextWindow_Text'>Type here:</div>";
        str += "<div id='MainWindow_TextWindow_TextBox' style='text-align: center;'>"; 
        str += "<input id='MainWindow_TextBox_User' type='text' style='width:444px; border-color:#bbb; border-style:solid; background-color:#f8fae8;' /></div>"; //MainWindow_TextWindow_TextBox
        str += "<div id='MainWindow_TextWindow_Button' style='text-align: center'>";
        str += "<button id='MainWindow_TextWindow_Button_Button' style='width: 80px' onclick='SendSentence()' title='Send Instant Message to Jenny'>Send</button></div>"; // MainWindow_TextWindow_Button
        str += "</div>"; //MainWindow_TextWindow
        str += "</div>"; //MainWindow_ChatWindow_Left


        str += "<div id='MainWindow_ChatWindow_Right'>";
        str += "<div id='MainWindow_ChatWindow_Photo'>";

        if(!IsConversationStarted && ! IsConversationOver)
        {
            /*if(document.all) // If Explorer
            {
                str += "<span style='text-align:left;'><OBJECT style='border:2px outset #bbb9ba;' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
            } 
        
            else // If FireFox (outset feature doesn't work well in firefox)
            {
                str += "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
            }

            str += "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'";
            str += "WIDTH='136' HEIGHT='182' id='ChatPromo_IE'>";
            str += "<PARAM NAME=movie VALUE='flash/CreateJenny - ChatPromo.swf'>";
            str += "<PARAM NAME=quality VALUE=best>";
            str += "<PARAM NAME=bgcolor VALUE=#FFFFFF>";
            str += "<EMBED id='ChatPromo_FF' play=false src='flash/CreateJenny - ChatPromo.swf' quality=best bgcolor=#FFFFFF WIDTH='136' HEIGHT='182'";
            str += "NAME='CreateJenny - ChatPromo' ALIGN='' TYPE='application/x-shockwave-flash'";
            str += "PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED>";
            str += "</OBJECT>";
            str += "<br/><br style='font-size:6pt'/>";*/
            
            
            
            
        }    
        
        str += "</div>"; //MainWindow_ChatWindow_Photo 

        str += "<div id='MainWindow_ChatWindow_Feelings'>";
        str += "</div>"; //MainWindow_ChatWindow_Feelings
        str += "</div>"; //MainWindow_ChatWindow_Right

        
        str += "</div>"; //MainWindow_MainSection
        
        str += GetStepBottomSection(1);

        main_window.innerHTML = str;
        
        /*if(document.all) // If Explorer
        {
            var movie = document.getElementById("ChatPromo_IE");
            
            if(movie != null)
            {
                movie.StopPlay();
            }
        }*/

        var chat_log_window = document.getElementById('MainWindow_ChatWindow_ChatLog');
            
        if (chat_log_window != null)
        {
            
            if(!IsConversationStarted && ! IsConversationOver)
            {
                var tmp_str = "<div style='padding-left:10px;'><img src='images/scenario_1.gif' />";
                tmp_str += "<div style='margin-top:20px;'><span style='color:#3b5998; font-size:15pt;'><b>Location&nbsp;</b></span><img src='images/greenarrow_long.gif'><span style='font-size:12pt;'>&nbsp;</span><span style='font-family:Arial Rounded MT Bold; color:#0e1f5b; font-size:14pt;'> East Hampton, Long Island</span></div>";
                tmp_str += "<div style='margin-top:10px;'><span style='color:#3b5998; font-size:15pt;'><b>Situation&nbsp;</b></span><img src='images/greenarrow_long.gif'><span style='font-size:12pt;'>&nbsp;</span><span style='font-family:Arial Rounded MT Bold; color:#0e1f5b; font-size:14pt;'> Sitting next to Jenny in a cafe</span></div>";
                tmp_str += "<div style='margin-top:10px;'><span style='color:#3b5998; font-size:15pt;'><b>Objective&nbsp;</b></span><img src='images/greenarrow_long.gif'><span style='font-size:12pt;'>&nbsp;</span><span style='font-family:Arial Rounded MT Bold; color:#0e1f5b; font-size:14pt;'> Get Jenny's phone number</span></div>";
                tmp_str += "<div style='margin-top:20px;'><span style='font-family:Arial; font-size:10pt;'>To <b>start talking</b> to Jenny, <b>type</b> your opening line in the textbox below. Then <b>press enter</b> to send the message.</span></div>";
                tmp_str += "<div style='margin-top:10px;'><span style='font-family:Arial; font-size:10pt;'>To <b>finish</b> the conversation, simply type <b>&#34;Bye&#34;</b> or click <b>Continue</b>.</span></div>";
                
                chat_log_window.innerHTML = tmp_str;
                
                ChatLog = "<span style='font-family:Arial; font-size:13px; color:#283a52;'>Thank you for participating!<br><br><u>Tips:</u><br><br style='font-size:4pt;'>1. Keep it simple.<br>2. Try to flatter her.<br>3. Don't be too pushy.</span>";
                ChatLog += "<hr><!--Start-->";
            }
            
            else
            {
                chat_log_window.innerHTML = ChatLog;
                cursorEOT(chat_log_window);
            }
        }    

        if(IsConversationStarted)
        {
            UpdateImage();
           	
           	if(IsEmotionsDisplayed)
           	{
               	ShowFeelings();
           	}
           	
           	else
           	{
               	HideFeelings();
           	}
        }
        
        if(!IsConversationStarted && !IsConversationOver)
        {
            var right_part = document.getElementById('MainWindow_ChatWindow_Right');
            
            if(right_part != null)
            {
                right_part.style.backgroundImage="url(images/coffee.jpg)";                
            }
        }

        var button = document.getElementById('MainWindow_TextWindow_Button_Button');
        
        if(text_box != null)
        {
            text_box.focus();
            text_box.focus();
        }

        var text_box = document.getElementById('MainWindow_TextBox_User');
        
        if(text_box != null)
        {
            text_box.focus();
            text_box.focus();
        }
    }    


  	document.body.style.cursor = "auto";
  	
    //urchinTracker('/mainpage/TalkToJenny');        
}

function GetVisualScale(num, vert, red)
{
    var str = "<TABLE nowrap bgcolor='lightcyan' border='1' bordercolor='steelblue' RULES='none' cellspacing='0' cellpadding='0'>";
	if(!vert)
	{
	    str += "<TR valign='center'>";
    }
    
    var i=0;		    

	for(i=0; i <= 90; i+=10) // green indicators vert & horiz
	{
		if(vert)
		{
		    str += "<TR valign='center'>";
	    }

		str += "<TD align='center'>";
		
		str += "<IMG border='0' bordercolor='white' src='";

		if(vert)
		{
		    if((100-num) > i) // oposite, because the table starts from the upper point, not bottom
		    {
			    str += "images/empty.jpg'>"; // should have been full, had we not started from top of table
		    }
		
		    else
		    {
			    if(!red)
			    {
				    str += "images/fullvert_green.jpg'>";
			    }

			    else
			    {
				    str += "images/fullvert_red.jpg'>";
			    }
		    }
        }
        
        else // horiz
        {
			if(num > i && num > 1)
			{
 				if(!red)
				{
					str += "images/fullhoriz_green.jpg'>";
				}

				else
				{
					str += "images/fullhoriz_red.jpg'>";
				}
			}
		
			else
			{
				str += "images/empty.jpg'>";
			}
        }		    

		if(vert)
		{
		    str += "</TR>";
        }		    

		str += "</TD>";
    }    

	if(!vert)
	{
	    str += "</TR>";
    }		    

	str += "</TABLE>";
	
	return str;
}

function ShowFeelings()
{
    var feelings_window = document.getElementById("MainWindow_ChatWindow_Feelings");
        
    if(feelings_window != null)
    {
        IsEmotionsDisplayed = true;
        
		var str = "<span style='font-size:10pt;' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)' onclick='HideFeelings()' title='Hide Jenny&#39;s emotions'>Hide emotions</span><hr><br style='font-size:4pt;'/>";
		str += "<Table id='Amygdala_Emotions' border=0 cellspacing='0' cellpadding='0'>";
		//str += "<TR valign=top>";

		// anger
		str += "<TR valign='top'>";

		str += "<TD width='48' align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "Anger";
		str += "</SPAN>";
		str += "</TD>";

		str += "<TD align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "<SPAN style='font-size:6pt;' id='Amygdala_Anger'>1</SPAN>";
		str += "</SPAN>";
		str += "</TD>";

		str += "</TR>";


		// sadness
		str += "<TR valign='top'>";

		str += "<TD width='48' align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "Sadness";
		str += "</SPAN>";
		str += "</TD>";

		str += "<TD align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "<SPAN style='font-size:6pt;' id='Amygdala_Sadness'></SPAN>";
		str += "</SPAN>";
		str += "</TD>";

		str += "</TR>";


		// fear
		str += "<TR valign='top'>";

		str += "<TD width='48' align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "Fear";
		str += "</SPAN>";
		str += "</TD>";

		str += "<TD align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "<SPAN style='font-size:6pt;' id='Amygdala_Fear'></SPAN>";
		str += "</SPAN>";
		str += "</TD>";

		str += "</TR>";


		// enjoyment
		str += "<TR valign='top'>";

		str += "<TD width='53' align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "Enjoyment";
		str += "</SPAN>";
		str += "</TD>";

		str += "<TD align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "<SPAN style='font-size:6pt;' id='Amygdala_Enjoyment'></SPAN>";
		str += "</SPAN>";
		str += "</TD>";

		str += "</TR>";


		// love
		str += "<TR valign='top'>";

		str += "<TD width='48' align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "Love";
		str += "</SPAN>";
		str += "</TD>";

		str += "<TD align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "<SPAN style='font-size:6pt;' id='Amygdala_Love'></SPAN>";
		str += "</SPAN>";
		str += "</TD>";

		str += "</TR>";


		// surprise
		str += "<TR valign='top'>";

		str += "<TD width='48' align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "Surprise";
		str += "</SPAN>";
		str += "</TD>";

		str += "<TD align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "<SPAN style='font-size:6pt;' id='Amygdala_Surprise'></SPAN>";
		str += "</SPAN>";
		str += "</TD>";

		str += "</TR>";


		// disgust
		str += "<TR valign='top'>";

		str += "<TD width='48' align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "Disgust";
		str += "</SPAN>";
		str += "</TD>";

		str += "<TD align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "<SPAN style='font-size:6pt;' id='Amygdala_Disgust'></SPAN>";
		str += "</SPAN>";
		str += "</TD>";

		str += "</TR>";


		// shame
		str += "<TR valign='top'>";

		str += "<TD width='48' align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "Shame";
		str += "</SPAN>";
		str += "</TD>";

		str += "<TD align='left' style='height:16px;'>";
		str += "<SPAN style='color:#00366e; font-size:7pt; width:100%'>";
		str += "<SPAN style='font-size:6pt;' id='Amygdala_Shame'></SPAN>";
		str += "</SPAN>";
		str += "</TD>";

		str += "</TR>";

		str += "</Table>";
			
        feelings_window.innerHTML = str;
        
        UpdateEmotions();
    }				

    var text_box = document.getElementById('MainWindow_TextBox_User');
        
    if(text_box != null)
    {
        text_box.focus();
        text_box.focus();
    }

    //urchinTracker('/mainpage/TalkToJenny/ShowFeelings');        
}

function HideFeelings()
{
    var feelings_window = document.getElementById("MainWindow_ChatWindow_Feelings");
        
    if(feelings_window != null)
    {
        IsEmotionsDisplayed = false;
        
		var str = "<span style='font-size:10pt;' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)' onclick='ShowFeelings()' title='Show Jenny&#39;s emotions'>Show emotions</span><hr><br style='font-size:4pt;'/>";
        feelings_window.innerHTML = str;
    }

    var text_box = document.getElementById('MainWindow_TextBox_User');
        
    if(text_box != null)
    {
        text_box.focus();
        text_box.focus();
    }

    //urchinTracker('/mainpage/TalkToJenny/HideFeelings');        
}
    		
function ShowResponseGraph(response)
{
    response = ReplaceSymbols(response);
    var graph_window = document.getElementById('MainWindow_SAIGraph');
    
    if(graph_window != null)
    {
        var str = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
	    str += "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'";
	    str += "WIDTH='360'";
	    str += "HEIGHT='273'";
	    str += "id='charts'";
	    str += "ALIGN=''>";
        str += "<PARAM NAME=movie VALUE='charts/charts.swf?library_path=charts/charts_library&xml_source=php/SAIBar.php?string_data="; 
        
        var tmp_log = StateLog;
        var new_log = "";
        
        while(tmp_log.length)
        {
            if(tmp_log.charAt(0) != " " && tmp_log.charAt(0) != "," && tmp_log.charAt(0) != ":" && tmp_log.charAt(0) != "#"
            && tmp_log.charAt(0) != "S" && tmp_log.charAt(0) != "A" && tmp_log.charAt(0) != "I")
            {
                if(!(tmp_log.charAt(0) == "|" && new_log.charAt(new_log.length-1) == "|"))
                {
                    new_log += tmp_log.charAt(0);
                }
            }
            
            tmp_log = tmp_log.substr(1,tmp_log.length-1);
        }
        
        var new_log_array = new Array();
        new_log_array = new_log.split("OP");
        
        var i=0;
        
        for(i=0; i < ReceivedResponsesArray.length; i++)
        {
            if(ReceivedResponsesArray[i] == response)
            {
                break;
            }
        }            
        
        new_log = new_log_array[++i];
        
        str += new_log;
        str += "'>";
        str += "<PARAM NAME=quality VALUE=high>";
        str += "<PARAM NAME=bgcolor VALUE=#ffffff>";
        str += "<EMBED src='charts/charts.swf?library_path=charts/charts_library&xml_source=php/SAIBar.php?string_data=";
        str += new_log;
        str += "' ";
        str += "quality=high ";
        str += "bgcolor=#ffffff ";
        str += "WIDTH='360' ";
        str += "HEIGHT='273' ";
        str += "NAME='charts' ";
        str += "ALIGN='' ";
        str += "swLiveConnect='true' ";
        str += "TYPE='application/x-shockwave-flash' ";
        str += "PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'>";
        str += "</EMBED>";
        str += "</OBJECT>";

        graph_window.innerHTML = str;
    }
}

function CanMoveToStep2()
{
    if(!IsConversationStarted)
    {
        alert("\nPlease talk to Jenny first before moving to the next step.\n\nTo start talking to Jenny, simply type a message and either press Enter or click Send.\n");

        var text_box = document.getElementById('MainWindow_TextBox_User');

        if(text_box != null)
        {
            text_box.focus();
        }

        return false;
    }
    
    if(!IsConversationOver)
    {
        var text_box = document.getElementById('MainWindow_TextBox_User');

        if(text_box != null)
        {
            ChatLog += "<br><br>Please wait...";
            text_box.value = "bye";
            SendSentence();
            return false;
        }    
    }
    
    return true;
}

function GetScore()
{
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
      	document.body.style.cursor = "wait";
      	
        main_window.style.backgroundImage="";
       
        if(MaxStep < 2)
        {
            MaxStep = 2;
        }
        
        var str = GetStepTopSection(2,MaxStep);
        str += "<div id ='MainWindow_MainSection'>";
        str += "<p style='font-size:12pt;'>Processing request... Please wait<br/><br/>";
        str += "If page appears frozen please refresh and try again</p>";
        str += "</div>";
        str += GetStepBottomSection(2);
  
        main_window.innerHTML = str;
        
        if(Score > 0)
        {
            PageMethods.RetrieveScoreData(true, DisplayScore, GetError, GetTimeout);
        }
        
        else
        {
            PageMethods.RetrieveScoreData(false, DisplayScore, GetError, GetTimeout);
        }
    }
}

function DisplayScore(response)
{
    if (response == null)
    {
       return;
    }

    var result = response;

    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        var data = new Array();
        data = result.split('|');
        
        var top_score = data[0];
        var average_score = data[1];
        var top_ten_data = data[2];
        var affiliate_data = data[3];
        
        main_window.style.backgroundImage="";
       
        if(MaxStep < 2)
        {
            MaxStep = 2;
        }
        
        var str = GetStepTopSection(2,MaxStep);
        str += "<div id ='MainWindow_MainSection'>";

        var score = "";
        score += Score;
        
        if(score.indexOf('.') != -1)
        {
            score = score.substring(0,score.indexOf('.') + 3);
        }            
        
        str += "<div id ='MainWindow_MainSection_Score'>";
        str += "<br style='font-size:4pt;'><center><span style='font-size:16pt;'><b>Your score: ";
        str += score;
        str += "</b></span></center></br>";
        str += "<OBJECT style='cursor:not-allowed;' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
	    str += "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'";
	    str += "WIDTH='290'";
	    str += "HEIGHT='275'";
	    str += "id='charts'";
	    str += "ALIGN=''>";
        str += "<PARAM NAME=movie VALUE='charts/charts.swf?library_path=charts/charts_library&xml_source=php/Score.php?string_data="; 
        str += score + "|" + top_score + "|" + average_score;
        str += "'>";
        str += "<PARAM NAME=quality VALUE=high>";
        str += "<PARAM NAME=bgcolor VALUE=#ffffff>";
        str += "<EMBED  style='cursor:not-allowed;' src='charts/charts.swf?library_path=charts/charts_library&xml_source=php/Score.php?string_data=";
        str += score + "|" + top_score + "|" + average_score;
        str += "' ";
        str += "quality=high ";
        str += "bgcolor=#ffffff ";
        str += "WIDTH='290' ";
        str += "HEIGHT='275' ";
        str += "NAME='charts' ";
        str += "ALIGN='' ";
        str += "swLiveConnect='true' ";
        str += "TYPE='application/x-shockwave-flash' ";
        str += "PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'>";
        str += "</EMBED>";
        str += "</OBJECT>";
        str += "<span style='font-size:9pt;'><center><b>";
        var chat_num = ChatID.substring(ChatID.indexOf('_') + 1, ChatID.length);
        chat_num *= 1;
        chat_num += 10000;
        str += chat_num;
        str += "</b> chats have been logged to our databases</center></span>";
        str += "</div>";
        
        str += "<div id ='MainWindow_MainSection_Top10'>";
        str += "<span style='font-size:16pt;'><b>Top 10 scores:</b></span>";
        str += "<table style='width:100%; border:2px solid #bbb; margin-top:10px;'>";
        str += "<tr style='background-color:#bbb;'><td style='width:140px; font-size:11pt;'><br style='font-size:2pt;'/><b>Name</b><br style='font-size:3pt;'/></td><td style='width:100px; font-size:11pt;'><br style='font-size:2pt;'/><b>Score</b><br style='font-size:3pt;'/></td></tr>";
        
        var top_ten_array = new Array();
        top_ten_array = top_ten_data.split("~");
        
        for(i=0; i < top_ten_array.length; i++)
        {
            str += "<tr style='background-color:#ffeeee;'><td style='border-top:1px solid #bbb; padding-top:4px;'><span style='font-family:Courier New; font-size:11pt; color:#cb1616'>";
            
            var tmp_array = new Array();
            var tmp_str = top_ten_array[i];
            tmp_array = tmp_str.split("%");
            
            if(tmp_array[1] == "")
            {
                str += "Anonymous";
            }
            
            else
            {
                str += tmp_array[1];
            }

            str += "</span><br style='font-size:2pt;'/></td><td style='border-top:1px solid #bbb; padding-top:4px;'><span style='font-family:Courier New; font-size:11pt; color:#cb1616'>";
            str += tmp_array[0];
            str += "</span><br style='font-size:2pt;'/></td></tr>";
        }
                    
        str += "</table>";
        str += "</div>";


        if(NickName == "")
        {
            str += "<div id ='MainWindow_MainSection_NickName'>";
            str += "<span style='font-size:16pt;'><b>Add your score:</b></span><br><br style='font-size:8pt;'>";
            str += "<div style='margin-top:20px;'><span style='color:#313881'>Adding your nickname will allow you receiving credit for your score and chat logs.</span></div>";
            str += "<div style='margin-top:20px;'>Nick name:&nbsp;&nbsp;&nbsp;<input id='TextBox_NickName' type='text' style='' /></div>";
            str += "<div style='margin-top:30px;'><input type='checkbox' id='CheckBox_NewsLetter' onclick='DisableOrEnableNewsLetter()' CHECKED><span style='color:#313881'> Also subscribe to our Free Newsletter!</span></div>";
            str += "<div style='margin-top:20px; with:100%;'><span id='NewsLetter'>Your email: &nbsp;<input type='text' id='TextBox_Email'></span></div>";
            str += "<div style='margin-top:50px; width:100%; height:15px;'><hr/></div>";

            str += "<img src='images/submittopic.jpg' title='Add your score' onclick='UpdateNickName()' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>";
            str += "<span style='font-size:11pt; vertical-align:top;' onclick='UpdateNickName()' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>Submit</span>";
            //str += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            //str += "<img src='images/canceltopic.jpg' title='Don&#39;t use nickname' onclick='UpdateNickName(false)' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>";
            //str += "<span style='font-size:11pt; vertical-align:top;' onclick='UpdateNickName(false)' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>No thanks</span>";
            str += "</div>";
    }
        
        else
        {
            str += "<div id ='MainWindow_MainSection_JoinCreationForums'>";
            str += "<span style='font-size:12pt; color:#131958'><b>Help us to create Jenny!</b></span><br><br><span style='font-size:10pt; color:#313881'>Jenny&#39;s responses and reactions are created by people from all around the world.</span><br><br><span style='font-size:11pt; color:#313881'>Join now our <span style='color:blue;' onmouseover='body.style.cursor = " + Commas + "pointer" + Commas + "' onmouseout='body.style.cursor = " + Commas + "auto" + Commas + "' onclick='CreationForums()' title='Join the collaborative effort to create Jenny!'><u>Creation Forums</u></span> to fill in Jenny&#39;s missing responses.</span>";
            str += "</div>";
            
            str += "<div id ='MainWindow_MainSection_Affiliate'>";
            str += affiliate_data;
            str += "</div>";
        }
    

        str += "</div>";
        str += GetStepBottomSection(2);
  
        main_window.innerHTML = str;
        
      	setTimeout(NickNameTextBoxFocus, 500);

      	document.body.style.cursor = "auto";
    }

    //urchinTracker('/mainpage/GetScore');        
}


function NickNameTextBoxFocus()
{
        var textbox_nickname = document.getElementById('TextBox_NickName');
    
        if(textbox_nickname != null)
        {
            textbox_nickname.focus();
        }
}


function ShowReport()
{
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        main_window.style.backgroundImage="";
        
        if(MaxStep < 3)
        {
            MaxStep = 3;
        }
        
        CurrentUnrecognizedSentence = "";
        CurrentStringData = "";
        CurrentContextIndexData = "";
        
        var str = GetStepTopSection(3,MaxStep);

        str += "<div id ='MainWindow_MainSection'>";

        str += "<div id ='MainWindow_MainSection_SwitchButton'>";
        str += "<div id ='MainWindow_MainSection_SwitchButton_Decoration'>";
        str += "<button style='width: 150px' onclick='GetFeedback()' title='Get feedback summary based on your performance and Jenny&#39;s responses'>Simple Mode</button>";
        str += "</div></div>";


        str += "<span style='font-size:10pt;'>";
        str += "Jenny&#39;s state of mind depends on her <b>Personal Security</b>, <b>Sexual Attraction</b>, and <b>Mental Interest</b> in you.<br><br style='font-size:1pt;'>";
        str += "The graph below summarizes Jenny&#39;s state of mind during the conversation:</span>";
        
        str += "<div style='margin-top:10px;' id='MainWindow_SAIGraph'>";
        str += "<OBJECT style='cursor:not-allowed;' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
	    str += "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'";
	    str += "WIDTH='375'";
	    str += "HEIGHT='273'";
	    str += "id='charts'";
	    str += "ALIGN=''>";
        str += "<PARAM NAME=movie VALUE='charts/charts.swf?library_path=charts/charts_library&xml_source=php/SAI.php?string_data="; 
        
        var tmp_log = StateLog;
        var new_log = "";
        
        while(tmp_log.length)
        {
            if(tmp_log.charAt(0) != " " && tmp_log.charAt(0) != "," && tmp_log.charAt(0) != ":" && tmp_log.charAt(0) != "#"
            && tmp_log.charAt(0) != "S" && tmp_log.charAt(0) != "A" && tmp_log.charAt(0) != "I")
            {
                if(!(tmp_log.charAt(0) == "|" && new_log.charAt(new_log.length-1) == "|"))
                {
                    new_log += tmp_log.charAt(0);
                }
            }
            
            tmp_log = tmp_log.substr(1,tmp_log.length-1);
        }
        
        str += new_log;
        str += "'>";
        str += "<PARAM NAME=quality VALUE=high>";
        str += "<PARAM NAME=bgcolor VALUE=#ffffff>";
        str += "<EMBED  style='cursor:not-allowed;' src='charts/charts.swf?library_path=charts/charts_library&xml_source=php/SAI.php?string_data=";
        str += new_log;
        str += "' ";
        str += "quality=high ";
        str += "bgcolor=#ffffff ";
        str += "WIDTH='375' ";
        str += "HEIGHT='273' ";
        str += "NAME='charts' ";
        str += "ALIGN='' ";
        str += "swLiveConnect='true' ";
        str += "TYPE='application/x-shockwave-flash' ";
        str += "PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'>";
        str += "</EMBED>";
        str += "</OBJECT>";
        str += "</div>";
        
        str += "<div id='MainWindow_Responses'>";

        str += "<span style='color:#131958; font-size:11pt;'><b>Jenny&#39;s Responses:</b></span><br/><br style='font-size:4pt;'/>";

        var i;
        
        if(!ReceivedResponsesArray.length)
        {
            str += "<p>No responses have been found.</p>";
        }
            
        else
        {
            str += "<table id='ResponsesList'>";
                
            for(i=0; i < ReceivedResponsesArray.length; i++)
            {
                if(ReceivedResponsesArray[i] != "")
                {
                    str += "<tr><td onclick='ShowResponseGraph(" + Commas + ReceivedResponsesArray[i] + Commas + "," + LastReceivedContextIndexArray[i] + ")' ";
                    str += "onmouseover='makeTDOptional(this," + Commas + ReceivedResponsesArray[i] + Commas + ");' onmouseout='makeTDNormal(this,true)'";
                    str += "><b>" + (i+1) + ".</b> ";
                    str += ReceivedResponsesArray[i];
                    str += "</tr></td>";
                }    
            }

            str += "</table>";
        }

        str += "</div>";
        
        str += "<div id='MainWindow_ChatLog'>";
        str += "</div>";

        str += "</div>";
        str += "</div>";
        str += GetStepBottomSection(3);
  
        main_window.innerHTML = str;
        
        DisplayChatLog("",true);
    }    
 
    //urchinTracker('/mainpage/GetFeedback/Advanced');        
}

function GetAverageFromStateLog(type)
{
    var average = 0;
    var count = 0;
    var tmp_log = StateLog;
        
    
    while(tmp_log.length)
    {
        if(tmp_log.charAt(0) == type)
        {
            var first = tmp_log.indexOf("|");
            var last = tmp_log.indexOf("|", first + 1);
            var num = tmp_log.substring(first + 1, last);
            num *= 1;
            average += num;
                
            count++;
        } 
            
        tmp_log = tmp_log.substr(1,tmp_log.length-1);
    }
    
    average /= count;
    
    return average;        
}

function CalculateScore()
{
    if(Score == 0)
    {
        if(IsPhoneGiven)
        {
            Score += 20;
        }
            
        var tmp_average = GetAverageFromStateLog("S");
            
        if(tmp_average > 0)
        {
            Score += (tmp_average * 0.15); 
        }
            
        tmp_average = GetAverageFromStateLog("A");
            
        if(tmp_average > 0)
        {
           Score += (tmp_average * 0.15); 
        }
            
        tmp_average = GetAverageFromStateLog("I");
            
        if(tmp_average > 0)
        {
            Score += (tmp_average * 0.15); 
        }
            
        if(UserInformation_Name != "")
        {
            Score += 3;
        }
            
        if(UserInformation_Age != "")
        {
            Score += 3;
        }

        if(UserInformation_Location != "")
        {
            Score += 3;
        }

        if(UserInformation_Occupation != "")
        {
            Score += 3;
        }

        if(UserInformation_AcademicLevel != "")
        {
            Score += 3;
        }
            
        var min = cycles / 60;
            
        if(min > 5)
        {
           min = 5;
        }

        Score += (min * 4);
    }
}

function GetFeedbackData()
{
    var str = "";

    var tmp = cycles / 60;
            
    if(tmp >= 1)
    {
        str += "P";
    }
    
    else
    {
        str += "N";
    }
    
    str += "|";

    tmp = GetAverageFromStateLog("S");
    
    if(tmp > 0)
    {
        str += "P";
    }
    
    else
    {
        str += "N";
    }
    
    str += "|";

    tmp = GetAverageFromStateLog("A");
    
    if(tmp > 0)
    {
        str += "P";
    }
    
    else
    {
        str += "N";
    }

    str += "|";

    tmp = GetAverageFromStateLog("I");
    
    if(tmp > 0)
    {
        str += "P";
    }
    
    else
    {
        str += "N";
    }

    str += "|";

    var details = 0;

    if(UserInformation_Name != "")
    {
        details++;
    }
            
    if(UserInformation_Age != "")
    {
        details++;
    }

    if(UserInformation_Location != "")
    {
        details++;
    }

    if(UserInformation_Occupation != "")
    {
        details++;
    }

    if(UserInformation_AcademicLevel != "")
    {
        details++;
    }

    if(details > 2)
    {
        str += "P";
    }
    
    else
    {
        str += "N";
    }

    str += "|";

    if(IsPhoneGiven)
    {
        str += "P";
    }
    
    else
    {
        str += "N";
    }
    
    /*str += "|";
    
    if(Score > 20)
    {
        str += "P";
    }
    
    else
    {
        str += "N";
    }*/

    return str;
}

function GetFeedback()
{
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
      	document.body.style.cursor = "wait";
      	
        main_window.style.backgroundImage="";
       
        if(MaxStep < 3)
        {
            MaxStep = 3;
        }
        
        var str = GetStepTopSection(3,MaxStep);
        str += "<div id ='MainWindow_MainSection'>";
        str += "<p style='font-size:12pt;'>Processing request... Please wait<br/><br/>";
        str += "If page appears frozen please refresh and try again</p>";
        str += "</div>";
        str += GetStepBottomSection(3);
  
        main_window.innerHTML = str;

        PageMethods.RetrieveFeedbackData(GetFeedbackData(), DisplayFeedback, GetError, GetTimeout);
    }
}

function DisplayFeedback(response)
{
    if (response == null)
    {
       return;
    }

    var result = response;
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        var data = new Array();
        data = result.split('|');
        
        var feedback_data_str = data[0];
        var improvement_affiliate = data[1];
        var dating_line = data[2];
        var improvement_line = data[3];
        
        main_window.style.backgroundImage="";
       
        if(MaxStep < 3)
        {
            MaxStep = 3;
        }
        
        var str = GetStepTopSection(3,MaxStep);
        str += "<div id ='MainWindow_MainSection'>";

        var score = "";
        score += Score;
        
        if(score.indexOf('.') != -1)
        {
            score = score.substring(0,score.indexOf('.') + 3);
        }            
        
        str += "<div id ='MainWindow_MainSection_SwitchButton'>";
        str += "<div id ='MainWindow_MainSection_SwitchButton_Decoration'>";
        str += "<button style='width:135px;' onclick='ShowReport()' title='Get a full detailed analytical report of Jenny&#39;s responses'>Advanced Mode</button>";
        str += "</div></div>";

        str += "<div id ='MainWindow_MainSection_Feedback'>";
        str += "<span style='font-size:16pt;'>";
        str += "<b>Feedback:</b>"
        str += "</span><br/><br/><br/>"
        
        if(CurrentFeedbackData == "")
        {
            if(feedback_data_str != "")
            {
                var feedback_data_array = new Array();
                
                feedback_data_array = feedback_data_str.split("~");

                CurrentFeedbackData = "<table>";
            
                for (var i=0; i < feedback_data_array.length; i++)
                {
                    CurrentFeedbackData += "<tr><td valign=top style='width:60px;'>";
                    CurrentFeedbackData += "<img src='images/pointing_hand.jpg'/>";
                    CurrentFeedbackData += "</td><td><span style='font-size:10pt;'>";
                    CurrentFeedbackData += feedback_data_array[i];
                    CurrentFeedbackData += "</span><br/><br/></td></tr>";
                }
            
                CurrentFeedbackData += "</table>";
            }
        
            else
            {
                CurrentFeedbackData += "<ul><li>Good job! Your performance was excellent!</li></ul>";
                CurrentFeedbackData += "<br/>";
            }
        }
        
        str += CurrentFeedbackData;
        str += "<br/>";       
        str += improvement_line;
        str += "</div>";
     

        str += "<div id ='MainWindow_MainSection_UserInformation'>";

        str += "<span style='font-size:12pt; color:#131958'>";
        str += "<b>Your image in Jenny&#39;s eyes:</b>";
        str += "</span><br/><br/><br/>";
        
        if( (UserInformation_Name == "User" || UserInformation_Name == "") && UserInformation_Age == "" && 
           UserInformation_Location == "" && UserInformation_Occupation == "" && UserInformation_AcademicLevel == "")
        {
            str += "<span style='color:#313881'>Jenny didn't collect any information about you.</span><br/>";
        }           


        if(UserInformation_Name != "User" && UserInformation_Name != "")
        {
            str += "<span style='color:#313881'>Name:  <b>";
            str += UserInformation_Name;
            str += "</b></span><br/><br style='font-size:3pt;'/>";
        }
            
        if(UserInformation_Age != "")
        {
            str += "<span style='color:#313881'>Age:  <b>";
            str += UserInformation_Age;
            str += "</b></span><br/><br style='font-size:3pt;'/>";
        }

        if(UserInformation_Location != "")
        {
            str += "<span style='color:#313881'>Location:  <b>";
            str += UserInformation_Location;
            str += "</b></span><br/><br style='font-size:3pt;'/>";
        }

        if(UserInformation_Occupation != "")
        {
            str += "<span style='color:#313881'>Occupation:  <b>";
            str += UserInformation_Occupation;
            str += "</b></span><br/><br style='font-size:3pt;'/>";
        }

        if(UserInformation_AcademicLevel != "")
        {
            str += "<span style='color:#313881'>Academic Level:  <b>";
            str += UserInformation_AcademicLevel;
            str += "</b></span><br/><br style='font-size:3pt;'/>";
        }

        
        str += "<br/>";
        str += "<span style='color:#313881'>";

        if(IsPhoneGiven)
        {
            str += "You <b>succeeded</b> to get her <b>phone number</b>!";
        }
        
        else
        {
            str += "You <b>failed</b> to get her <b>phone number</b>.";
        }
       
        str += "</span>";
        str += "</div>";


        str += "<div id ='MainWindow_MainSection_ShortAffiliate'>";
        str += improvement_affiliate;
        str += "</div>";

        
        str += "<div id ='MainWindow_MainSection_SentenceAffiliate'>";
        str += "<span style='font-size:12pt; color:#131958'>";
        str += "<b>Date single women online</b>";
        str += "</span><br/><br/><span style='color:#313881'>";
        str += "The love of your life is just a click away!<br/><br/>";
        str += dating_line;
        str += "</span></div>";

        
        str += "</div>";
        str += GetStepBottomSection(3);
  
        main_window.innerHTML = str;
        
      	document.body.style.cursor = "auto";
    }

    //urchinTracker('/mainpage/GetFeedback');        
}

function CreationForums()
{
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        main_window.style.backgroundImage="";
        
        CurrentUnrecognizedSentence = "";
        CurrentStringData = "";
        CurrentContextIndexData = "";
        
        var str = GetCreationTopSection();
        str += "<div id ='MainWindow_MainSection'>";
        str += "<p style='font-size:12pt;'>The following sentences were unrecognizable to Jenny.<br><br style='font-size:4pt;'>Click on one of the sentences below to fill in her missing response.</p>";
        
        str += "<div id='MainWindow_MissingData'>";

        str += "<b>Unrecognized Sentences:</b><br/><br/>";

        var i;
        
        if(!MissingResponsesArray.length)
        {
            str += "<p>No unrecognized sentences have been found.<br><br>Please <span style='color:blue;' onmouseover='body.style.cursor = " + Commas + "pointer" + Commas + "' onmouseout='body.style.cursor = " + Commas + "auto" + Commas + "' onclick='Step1()' title='Start the conversation'><u>talk to Jenny</u></span> first and come back later to fill in your unrecognized sentences.</p>";
        }
            
        else
        {
            str += "<table id='MissingDataList'>";
                
            for(i=0; i < MissingResponsesArray.length; i++)
            {
                if(MissingResponsesArray[i] != "")
                {
                    str += "<tr><td onclick='FillPatterns(" + Commas + MissingResponsesArray[i] + Commas + "," + LastReceivedContextIndexArray[i] + ")' ";
                    str += "onmouseover='makeTDOptional(this," + Commas + MissingResponsesArray[i] + Commas + ");' onmouseout='makeTDNormal(this,false)'";
                    str += ">" + (i+1) + ". ";
                    str += MissingResponsesArray[i];
                    str += "</tr></td>";
                }    
            }

            str += "</table>";
        }

        str += "</div>";
        
        str += "<div id='MainWindow_ChatLog'></div>";
        str += "</div>";
        str += GetCreationBottom();

        str += "</div>";
  
        main_window.innerHTML = str;

        if(MissingResponsesArray.length)
        {
            DisplayChatLog("",false);
        }
    }    

    //urchinTracker('/mainpage/CreationForums');        
}

function TellAFriend()
{
    window.open('htmls/TellAFriend.htm','','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=482,height=391,titlebar=yes');
    //urchinTracker('/mainpage/TellAFriend');        
}

function Comments()
{
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        main_window.style.backgroundImage="";
        
        var str = "<p style='font-size:14pt;'>Processing request...</p><br/>";
        str += "<p style='font-size:14pt;'>If page appears frozen please refresh and try again</p>";
        
        main_window.innerHTML = str;
    }        
    
   	document.body.style.cursor = "wait";
   	PageMethods.GetTalkBacksData(DisplayTalkBacksData, GetError, GetTimeout);
}

function AboutTAVision()
{
    window.open("http://www.TA-Vision.com");
    //urchinTracker('/mainpage/AboutTAVision');        
}

function Links()
{
    window.location.href = "content/links.aspx";
    //urchinTracker('/mainpage/Links');        
}

function ContactUs()
{
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        main_window.style.backgroundImage="";
        
        var str = "<h1 class='PageHeader'>Contact Us</h1><br>";

        str += "<h2 class='TextHeader'>Technical Support</h2>";
        str += "<p><a href='mailto:Support@CreateJenny.com'>Support@CreateJenny.com</a></p><br><br>"
        str += "<h2 class='TextHeader'>Comments and Feedback</h2>";
        str += "<p><a href='mailto:Feedback@CreateJenny.com'>Feedback@CreateJenny.com</a></p><br><br>"
        str += "<h2 class='TextHeader'>Investor Relations</h2>";
        str += "<p><a href='mailto:IR@CreateJenny.com'>IR@CreateJenny.com</a></p><br><br>"
        str += "<h2 class='TextHeader'>Business Development</h2>";
        str += "<p><a href='mailto:BD@CreateJenny.com'>BD@CreateJenny.com</a></p><br><br>"
        
        main_window.innerHTML = str;
    }    

    //urchinTracker('/mainpage/ContactUs');        
}

function TermsofUse()
{
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        main_window.style.backgroundImage="";
        
        var str = "<h1 class='PageHeader'>Terms of Use</h1>";

        str += "<h2 class='TextHeader'>Acceptance of Terms of Use</h2>";
        str += "<p>T.A. Vision Ltd. (&#34;TA Vision&#34;) makes this Web Site, including all information, graphics, documents, text, products and all other elements of the Site and all products offered on this Site and services operated through the Site, available for your use subject to the terms and conditions set forth in this document (&#34;Terms of Use&#34;). By accessing and using this Web Site, use of any TA Vision Services, downloading any Products, or browsing the Web Site, you agree to be bound by the following Terms of Use and all terms and conditions contained and/or referenced herein or any additional terms and conditions set forth on this Web Site and all such terms shall be deemed accepted by you. If you do NOT agree to all these Terms of Use, you should NOT use this Web Site. If you do not agree to any additional specific terms which apply to particular Content (as defined below) or to particular transactions concluded through this Web Site, then you should NOT use the part of the Web Site which contains such Content or through which such transactions may be concluded and you should not use such Content or conclude such transactions.</p>";
        str += "<p>These Terms of Use may be amended by TA Vision at any time. Such amended Terms of Use shall be effective upon posting on this Web Site. Please check the Terms of Use published on this Web Site regularly to ensure that you are aware of all terms governing your use of this Web Site. Also, specific terms and conditions may apply to specific content, products, materials, services or information contained on or available through this Web Site (the &#34;Content&#34;) or transactions concluded through this Web Site. Such specific terms may be in addition to these Terms of Use or, where inconsistent with these Terms of Use, only to the extent the content or intent of such specific terms is inconsistent with these Terms of Use, such specific terms will supersede these Terms of Use. </p>TA Vision reserves the right to make changes or updates with respect to or in the Content of the Web Site or the format thereof at any time without notice. TA Vision reserves the right to terminate or restrict access to the Web Site for any reason whatsoever at its sole discretion.</p>";

    
        str += "<br><h2 class='TextHeader'>Warranties and disclaimers</h2>";
        str += "<p>Although care has been taken to ensure the accuracy of the information on this Web Site, TA Vision assumes no responsibility therefor. ALL CONTENT IS PROVIDED &#34;AS IS&#34; AND &#34;AS AVAILABLE&#34;. TA Vision HEREBY EXPRESSLY DISCLAIMS ANY REPRESENTATIONS OR WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, NON-INFRINGEMENT, OR AS TO THE OPERATION OF THIS WEB SITE OR THE CONTENT. TA Vision DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS AS TO THE SECURITY OF THIS WEB SITE. YOU ACKNOWLEDGE ANY INFORMATION SENT MAY BE INTERCEPTED IN TRANSMISSION OR OTHERWISE. TA Vision DOES NOT WARRANT THAT THE WEB SITE OR THE SERVERS WHICH MAKE THIS WEB SITE AVAILABLE OR ELECTRONIC COMMUNICATIONS SENT BY TA Vision ARE FREE FROM VIRUSES OR ANY OTHER HARMFUL ELEMENTS.</p>";
        str += "<p>The use of the services or the downloading or other use of any products through the site is done at your own discretion and risk and with your agreement that you will be solely responsible for any damage to your computer system, loss of data, or other harm that results from such activities. TA Vision assumes no liability for any computer virus or other similar software code that is downloaded to your computer from the Web Site or in connection with any services or products offered through the Web Site. No advice or information whether oral or written, obtained by you from TA Vision or from the Web Site shall create any warranty not expressly stated in the Terms of Use.</p>";
        str += "<p>The Web Site may contain references to specific TA Vision products and services that may not be (readily) available in a particular country. Any such reference does not imply or warrant that any such products or services shall be available at any time in any particular country. </p>";
        str += "<p>IN NO EVENT SHALL TA Vision OR ANY OF ITS AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS, CONTRACT, REVENUE, DATA, INFORMATION OR BUSINESS INTERRUPTION), UNDER ANY THEORY OF LIABILITY, RESULTING FROM, ARISING OUT OF OR IN CONNECTION WITH THE USE OF, OR INABILITY TO USE THIS WEB SITE OR THE CONTENT, PRODUCTS, SERVICES, THE STATEMENTS OR ACTIONS OF ANY THIRD PARTY ON OR THROUGH THIS SITEM ANY UNAUTHORIZED ACCESS TO OR ALTERATION OF YOUR TRANSMISSION OR DATA, ANY INFORMATION THAT IS SENT OR RECEVIED, OR NOT SENT OR RECEIVED, ANY FAILURE TO STORE DATA, ANY LOSS OF DATA, LOSS OR DAMAGE TO FILES, LOSS OR DAMAGE TO THE CONTENT, ANY SERVICES AVAILABLE THROUGH THE SITE THAT ARE DELAYED OR INTERRUPTED, EVEN IF TA Vision HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ANY ACTION BROUGHT AGAINST TA Vision PERTAINING TO OR IN CONNECTION WITH THIS WEB SITE MUST BE COMMENCED AND NOTIFIED TO TA Vision IN WRITING WITHIN ONE (1) YEAR AFTER THE DATE THE CAUSE FOR ACTION AROSE.</p>";
        str += "<p>Some jurisdictions do not allow the exclusion of implied warranties or limitations, so the above limitations may not apply to you.</p>";

        str += "<br><h2 class='TextHeader'>Links to other sites</h2>";
        str += "<p>This Web Site may provide links to other web sites that are not under the control of TA Vision. TA Vision shall not be responsible in any way for the content of such other web sites. TA Vision provides such links only as a convenience to the user of this Web Site, and the inclusion of any link to any such web sites does not imply endorsement by TA Vision of the content of such web sites.</p>";


        str += "<br><h2 class='TextHeader'>Intellectual Property</h2>";
        str += "<p>Copyright, trademark and all other proprietary rights in the Content (including but not limited to software, services, audio, video, text and photographs) rests with TA Vision or its licensors. All rights in the Content not expressly granted herein are reserved. You agree not to copy, republish, frame, download, transmit, modify, rent, lease, loan, sell, assign, distribute, license, sublicense, reverse engineer, or create derivative works based on the Site, its Products or its Services except as expressly authorized herein. Except as otherwise provided, the Content published on this Web Site may be reproduced or distributed in unmodified form for personal non-commercial use only. Any other use of the Content, including without limitation distribution, reproduction, modification, display or transmission without the prior written consent of TA Vision is strictly prohibited. All copyright and other proprietary notices shall be retained on all reproductions.</p>";
        str += "<p>TA Vision hereby disclaims any rights to trademarks, service marks, trade names, logos, copyright, patents, domain names or other intellectual property interests of third parties. All intellectual property interests of third parties listed above are the properties of their respective owners. TA Vision disclaims any proprietary interests in the intellectual property rights other than their own.</p>";

        str += "<br><h2 class='TextHeader'>Information Provided By You</h2>";
        str += "<p>Any material or information sent through or in connection with this Web Site by you (&#34;User Materials&#34;) will be treated as non-confidential and non-proprietary, and immediately become the property of TA Vision, subject to any privacy policies posted on this Web Site. TA Vision may use such User Materials as it deems fit, anywhere in the world, without obligation for compensation, and free of any moral rights, intellectual property rights and/or other proprietary rights in or to such User Materials.</p>";


        str += "<br><h2 class='TextHeader'>Software</h2>";
        str += "<p>Software made available for downloading from or through this Web Site is licensed subject to the terms of the applicable end use license agreement. Both the Software and any accompanying documentation made available through this Web Site is the copyrighted work of TA Vision. Except as set forth in the applicable end user license agreement, the software is made available for use by end users only and any further copying, reproduction or redistribution of the software is expressly prohibited. You must agree to the terms of the applicable end user license agreement to download or order Products or Services from this Web Site.</p>";
        str += "<p>You may not use, copy, republish, frame, emulate, clone, download, transmit, rent, lease, loan, sell, assign, modify, distribute, license, sublicense, decompile, disassemble, create a derivative work otherwise reverse engineer, or transfer the licensed program, or any subset of the Web Site, its Products or Services, except as expressly authorized herein or in the applicable end user license agreement. Any such unauthorized use shall result in immediate and automatic termination of this license and may result in criminal and/or civil prosecution.</p>";
        str += "<p>WARRANTIES, IF ANY, WITH RESPECT TO SUCH SOFTWARE SHALL ONLY APPLY AS EXPRESSLY SET FORTH IN THE APPLICABLE END USER LICENSE AGREEMENT. TA Vision HEREBY EXPRESSLY DISCLAIMS ALL FURTHER REPRESENTATIONS AND WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE OR NON-INFRINGEMENT WITH RESPECT TO THE SOFTWARE.</p>";
        str += "<p>Without limiting the foregoing, TA Vision makes no warranty that: the services and products will meet your requirements; the services and products will be uninterrupted, timely, secure, or error-free; the results that may be obtained from the use of the services or materials will be effective, accurate, or reliable; the quality of any services or products purchased or accessible by you through the site will meet your expectations; any errors in the software obtained from or used through the site, or any defects in the site, its services or products, will be corrected.</p>";

        str += "<br><h2 class='TextHeader'>Comments</h2>";
        str += "<p>A Comment Forum is available on this Web Site for public comment by customers and visitors alike. Any notes, postings, ideas, suggestions, concepts, or other material submitted through this feature will become the property of TA Vision and TA Vision shall be entitled to use such material for any type of use forever, including in any media whether now known or hereafter devised.</p>";
        str += "<p>Information that you provide while making entries in the Comment Forum is available for all to see. Discretion should be used in entering personally identifiable information within such forums, as it may be collected by third parties. Use of personally identifiable information contained in the Comment Forum, and your options regarding our use of this information, is contained in TA Vision's Privacy Policy.</p>";
        str += "<p>TA Vision reserves the right to delete any message submitted to the Comment Forum, at its sole discretion, at any time and for any reason, including, but not limited to material which in TA Vision's opinion:</p>";
        str += "<ul>  <li>(A) may constitute libel, defamation, invasion of privacy, or is      obscene, pornographic, abusive, or threatening;   <li>(B) may infringe any intellectual property or other right of any      entity or person;   <li>(C) may violate any applicable law or advocates illegal activity;  <li>(D) advertises or otherwise solicits funds or is a solicitation      for goods, services, advertisers or sponsors or otherwise engages      in commercial activity;  <li>(E) disrupts the normal flow of dialogue or otherwise act in a way      which affects the ability of other people to engage in real time      activities via TA Vision's Sites;    <li>(F) includes programs which may contain viruses, worms, trojan       horses or other computer code, files or programs designed to       interrupt, destroy or limit the functionality of any computer       software or hardware or telecommunication;     <li>(G) violates any policy or regulation established from time to       time regarding use of TA Vision Sites or any networks connected to       TA Vision Sites; or    <li>(H) contains links to other sites that contain the kind of content      which falls within the descriptions set out in (A) to (G) above.  </li> </ul>";


        str += "<br><h2 class='TextHeader'>Linking to the Web Site</h2>";
        str += "<p>Linking to the Web Site is permitted provided that you comply with the following rules. You may link to the home page of the Web Site or to any other page of the Web Site. However you are not allowed to use in-line linking or framing. You must not imply that TA Vision endorses or sponsors the linker or its site, products or services. You must not use our intellectual property including but not limited to trademarks, trade name, copyright without advance written permission from TA Vision. Furthermore, you agree to remove the link at any time upon our request.</p>";

        str += "<br><h2 class='TextHeader'>Applicable Law</h2>";
        str += "<p>These Terms of Use and any disputed relating hereto shall be governed by and construed in accordance with the laws of the State of Israel without regard to its principles of conflict of laws. You agree to the exclusive jurisdiction of the courts of the State of Israel for any claim or cause of action arising out of, or relating to or in connection with these Terms of Use or this Web Site, provided that such exclusivity does not apply to legal actions initiated or brought by TA Vision.</p>";
        str += "<p>TA Vision does not bear any responsibility nor assumes any risks if by any reason a product or a service made available on this Web Site breaches national law of any state. Those who access this Site do so on their own initiative and are responsible for compliance with their national laws.</p>";
        str += "<p>Questions may be submitted to <A href='mailto:Legal@TA-Vision.com'>Legal@TA-Vision.com</A> Please also have a look at at our Online Privacy Policy</A>.<p>";
 
        
        main_window.innerHTML = str;
    }    

    //urchinTracker('/mainpage/TermsOfUse');        
}

function PrivacyStatement()
{
    /*if(IsConversationStarted)
    {
        PageMethods.ASPReleaseWaitEvent(UserID);
        StopTimer();
    }*/
       
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        main_window.style.backgroundImage="";
        
        var str = "<h1 class='PageHeader'>Web Privacy Statement</h1>";

        str += "<h2 class='TextHeader'>Collecting and Using Personal Information</h2>";
        str += "<p>Welcome to TA Vision&#39;s websites. We appreciate your interest in us. When you visit and navigate our sites and when you communicate with us via our sites, we will not collect personal information about you unless you provide us that information voluntarily. Any non-public personal information that you may provide via our sites will be used solely for the purpose stated on the page where it is collected.  (In some cases, and in all cases where required by law or regulation, you will be able to update the information that you provide to us either by sending us an e-mail or, where you have established personal profiles with us, by updating your profile online. Please refer to the specific pages where data is collected for more information). TA Vision will not sell, license, transmit or disclose this information outside of TA Vision and its affiliated companies unless (a) expressly authorized by you, (b) necessary to enable TA Vision contractors or agents to perform certain functions for us, or (c) required or permitted by law. In all cases, we will disclose the information consistent with applicable laws and regulations and we will require the recipient to protect the information and use it only for the purpose it was provided.</p>";
        str += "<p>By &#34;personal information&#34;, we mean data that is unique to an individual, such as a name, address, Social Security number, e-mail address, or telephone number. From time to time, we may request personal information from you at our sites in order to deliver requested materials to you, respond to your questions, or deliver a product or service.</p>";
        
        str += "<h2 class='TextHeader'>Your E-Mail</h2>";
        str += "<p>We welcome your comments or questions about our websites and have provided e-mail boxes for that purpose. We will share your comments and questions with our customer service representatives and those employees most capable of addressing your questions and concerns.</p>";
        str += "<p>Please note that your e-mail, like most, if not all, non-encrypted Internet e-mail communications, may be accessed and viewed by other Internet users, without your knowledge and permission, while in transit to us. For that reason, to protect your privacy, please do not use e-mail to communicate information to us that you consider confidential.</p>";
        str += "<p>There are some locations on TA Vision&#39;s websites where we have made special provisions for a more secure environment in which we can exchange information with you. At each of these locations, we will provide you with appropriate instructions.</p>";
        
        str += "<h2 class='TextHeader'>Other Information; &#34;Cookies&#34;</h2>";
        str += "<p>You should also be aware that when you visit our websites, we collect certain information that does not identify you personally, but provides us with &#34;usage data&#34;, such as the number of visitors we receive or what pages are visited most often. This data helps us to analyze and improve the usefulness of the information we provide at these websites.</p>";
        str += "<p>Like most commercial website owners, we may also use what is known as &#34;cookie&#34; technology. A &#34;cookie&#34; is an element of data that a website can send to your browser when you link to that website. It is not a computer program and has no ability to read data residing on your computer or instruct it to perform any step or function. By assigning a unique data element to each visitor, the website is able to recognize repeat users, track usage patterns and better serve you when you return to that site. The cookie does not extract other personal information about you, such as your name or address. Most browsers provide a simple procedure that will enable you to control whether you want to receive cookies by notifying you when a website is about to deposit a cookie file.</p>";
        
        str += "<h2 class='TextHeader'>Linking to Other Sites</h2>";
        str += "<p>From time to time, TA Vision websites may provide links to other websites, not owned or controlled by TA Vision, that we think might be useful or of interest to you. We cannot, however, be responsible for the privacy practices used by other website owners or the content or accuracy of those other websites. Links to various non-TA Vision websites do not constitute or imply endorsement by TA Vision of these websites, any products or services described on these sites, or of any other material contained in them.</p>";

        str += "<h2 class='TextHeader'>Security</h2>";
        str += "<p>TA Vision has adopted and adheres to stringent security standards designed to protect non-public personal information at CreatJenny.com against accidental or unauthorized access or disclosure. Among the safeguards that TA Vision has developed for this site are administrative, physical and technical barriers that together form a protective firewall around the information stored at this site. We periodically subject our site to simulated intrusion tests and have developed comprehensive disaster recovery plans.</p>";
        
        str += "<h2 class='TextHeader'>Changes to This Statement</h2>";
        str += "<p>TA Vision may change this Statement from time to time. We encourage you to periodically reread this Policy to see if there have been any changes that may affect you. This Statement is not intended to and does not create any contractual or other legal rights in or on behalf of any party.</p>";

        main_window.innerHTML = str;
    }    
    
    //urchinTracker('/mainpage/PrivacyStatement');
}


function GetCreationTopSection()
{
    var str = "<div id='MainWindow_CreationDescription'>";
    str += "<div id='MainWindow_StepDescription_Steps'>";
    str += "<span style='font-size:13pt; font-family:Courier New;'><b>";
    str += "Creation Forums";
    str += "</b></span><br/><br/>";
    str += "</div></div>";
    
    return str;
}

function GetCreationBottom()
{
    var str = "<div id='MainWindow_CreationControls'>";
    str += "</div>";
    
    return str;
}

function FillPatterns(sentence, index)
{
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        if(!ShowedFillingExample)
        {
            ShowedFillingExample = true;
            PromoMissingResponses(sentence, index);
            return;
        }
        
        CurrentUnrecognizedSentence = ReplaceSymbols(sentence);

        CurrentContextIndexData = index;
        
        var str = GetCreationTopSection();

        str += "<div id ='MainWindow_MainSection'>";
        str += "<p style='font-family:Arial Rounded MT Bold; font-size:18px; color:#05152d;'>How do you think Jenny would have responded to what you said?</p>";
        str += "<p>Each facial expression represents a different state of mind.<br>For each state of mind, ";
        str += "fill in Jenny's response that best fits the context of the following sentence:</p>";
        str += "<span style='font-family:Arial Rounded MT Bold; font-size:18px; color:#05152d;'>" + sentence + "</span><br><br style='font-size:10px;'>";
        str += "<table style='border-top:1px solid #bbb;'>";

        //////////////
        str += "<tr>";

        str += "<td>";

        str += "<table border=0>";
        str += "<tr>";
        str += "<td rowspan=2 style='width:50px;'>";
        str += "<img src='images/img_000.jpg' height=47px width=44px />";
        str += "</td>";
        str += "<td style='color:#283a52;'>";
        str += "Jenny's response:";
        str += "</td>";
        str += "</tr>";
        
        str += "<tr>";
        str += "<td style='width:220px;'>";
        str += "<input type=text id='TextBox_Response_1' style='width:200px;' onfocus='DisplayStateDescription(1)'>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";

        str += "</td>";

        str += "<td>";

        str += "<table border=0>";
        str += "<tr>";
        str += "<td rowspan=2 style='width:50px;'>";
        str += "<img src='images/img_001.jpg' height=47px width=44px />";
        str += "</td>";
        str += "<td style='color:#283a52;'>";
        str += "Jenny's response:";
        str += "</td>";
        str += "</tr>";
        
        str += "<tr>";
        str += "<td style='width:220px;'>";
        str += "<input type=text id='TextBox_Response_2' style='width:200px;' onfocus='DisplayStateDescription(2)'>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";

        str += "</td>";

        str += "<td id='StateDescription' rowspan=4 style='width:245px; border-left:1px solid #bbb;' valign=top></td>";
        str += "</tr>";
        ///////////////

        ///////////////
        str += "<tr>";

        str += "<td>";

        str += "<table border=0>";
        str += "<tr>";
        str += "<td rowspan=2 style='width:50px;'>";
        str += "<img src='images/img_010.jpg' height=47px width=44px />";
        str += "</td>";
        str += "<td style='color:#283a52;'>";
        str += "Jenny's response:";
        str += "</td>";
        str += "</tr>";
        
        str += "<tr>";
        str += "<td style='width:220px;'>";
        str += "<input type=text id='TextBox_Response_3' style='width:200px;' onfocus='DisplayStateDescription(3)'>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";

        str += "</td>";

        str += "<td>";

        str += "<table border=0>";
        str += "<tr>";
        str += "<td rowspan=2 style='width:50px;'>";
        str += "<img src='images/img_011.jpg' height=47px width=44px />";
        str += "</td>";
        str += "<td style='color:#283a52;'>";
        str += "Jenny's response:";
        str += "</td>";
        str += "</tr>";
        
        str += "<tr>";
        str += "<td style='width:220px;'>";
        str += "<input type=text id='TextBox_Response_4' style='width:200px;' onfocus='DisplayStateDescription(4)'>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";

        str += "</td>";
        ///////////////

        ///////////////
        str += "<tr>";

        str += "<td>";

        str += "<table border=0>";
        str += "<tr>";
        str += "<td rowspan=2 style='width:50px;'>";
        str += "<img src='images/img_100.jpg' height=47px width=44px />";
        str += "</td>";
        str += "<td style='color:#283a52;'>";
        str += "Jenny's response:";
        str += "</td>";
        str += "</tr>";
        
        str += "<tr>";
        str += "<td style='width:220px;'>";
        str += "<input type=text id='TextBox_Response_5' style='width:200px;' onfocus='DisplayStateDescription(5)'>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";

        str += "</td>";

        str += "<td>";

        str += "<table border=0>";
        str += "<tr>";
        str += "<td rowspan=2 style='width:50px;'>";
        str += "<img src='images/img_101.jpg' height=47px width=44px />";
        str += "</td>";
        str += "<td style='color:#283a52;'>";
        str += "Jenny's response:";
        str += "</td>";
        str += "</tr>";
        
        str += "<tr>";
        str += "<td style='width:220px;'>";
        str += "<input type=text id='TextBox_Response_6' style='width:200px;' onfocus='DisplayStateDescription(6)'>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";

        str += "</td>";
        ///////////////

        ///////////////
        str += "<tr>";

        str += "<td>";

        str += "<table border=0>";
        str += "<tr>";
        str += "<td rowspan=2 style='width:50px;'>";
        str += "<img src='images/img_110.jpg' height=47px width=44px />";
        str += "</td>";
        str += "<td style='color:#283a52;'>";
        str += "Jenny's response:";
        str += "</td>";
        str += "</tr>";
        
        str += "<tr>";
        str += "<td style='width:220px;'>";
        str += "<input type=text id='TextBox_Response_7' style='width:200px;' onfocus='DisplayStateDescription(7)'>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";

        str += "</td>";

        str += "<td>";

        str += "<table border=0>";
        str += "<tr>";
        str += "<td rowspan=2 style='width:50px;'>";
        str += "<img src='images/img_111.jpg' height=47px width=44px />";
        str += "</td>";
        str += "<td style='color:#283a52;'>";
        str += "Jenny's response:";
        str += "</td>";
        str += "</tr>";
        
        str += "<tr>";
        str += "<td style='width:220px;'>";
        str += "<input type=text id='TextBox_Response_8' style='width:200px;' onfocus='DisplayStateDescription(8)'>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";

        str += "</td>";
        ///////////////


        str += "</table>";
        str += "</div>";
        
        str += "<div id='MainWindow_CreationControls'>";
        str += "<img src='images/submitpattern.jpg' title='Submit responses' onclick='AddNewPattern()' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>";
        str += "<span style='font-size:11pt; vertical-align:top;' onclick='AddNewPattern()' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>Submit</span>";
        str += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        str += "<img src='images/cancelpattern.jpg' title='Cancel' onclick='CreationForums()' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>";
        str += "<span style='font-size:11pt; vertical-align:top;' onclick='CreationForums()' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>Cancel</span>";
        str += "</div>";

        main_window.innerHTML = str;

        var text_box = document.getElementById('TextBox_Response_1');
        
        if(text_box != null)
        {
            text_box.focus();
            text_box.focus();
        }
    }    

    //urchinTracker('/mainpage/CreationForums/FillPatterns');
}

function DisplayStateDescription(state)
{
    var state_description = document.getElementById('StateDescription');
            
    if (state_description != null)
    {
        var str = "<div style='overflow:auto; height:222px; width:100%; padding-left:5px; padding-top:5px;'>";
        str += "<span style='font-family:Arial Rounded MT Bold; font-size:18px; color:#05152d;'>State Description</span><br><br>";
        str += "<table>";
        str += "<tr>";
        
        switch(state)
        {
        
        case 1:
            str += "<td style='width:50px; color:#0e3064;' title='Personal security'>Security:</td>";
            str += "<td style='width:40px;'><img src='images/negative.jpg'/></td>";
            str += "<td rowspan=3 style='text-align:right; width:111px;'><img src='images/img_000.jpg' width=111px height=119px /></td>";
            str += "</tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Sexual attraction'>Attraction:</td><td style='width:40px;'><img src='images/negative.jpg'/></td></tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Mental interest'>Interest:</td><td style='width:40px;'><img src='images/negative.jpg'/></td></tr>";
            str += "</table>";
            str += "<p style='font-size:12px; font-family:Courier New;'>";
            str += "A total rejection - an utter lack of interest in each one of the parameters. A strong will to finish the conversation as fast as possible in order to avoid immediate danger. Possible reactions of anger, fear, and a snappy attitude. Obvious impatience.";
            str += "</p>";        
            break;
            
        case 2:
            str += "<td style='width:50px; color:#0e3064;' title='Personal security'>Security:</td>";
            str += "<td style='width:40px;'><img src='images/negative.jpg'/></td>";
            str += "<td rowspan=3 style='text-align:right; width:111px;'><img src='images/img_001.jpg' width=111px height=119px /></td>";
            str += "</tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Sexual attraction'>Attraction:</td><td style='width:40px;'><img src='images/negative.jpg'/></td></tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Mental interest'>Interest:</td><td style='width:40px;'><img src='images/positive.jpg'/></td></tr>";
            str += "</table>";
            str += "<p style='font-size:12px; font-family:Courier New;'>";
            str += "A state of rejection, though curiosity and intellectual stimulation exist. A will to end the conversation due to lack of security and physical rejection in contradiction to emotions of curiosity and a will to continue chatting. A snappy attitude, impatience, and negative words are possible. However, answers to relevant questions and limited cooperation are conceivable.";
            str += "</p>";        
            break;

        case 3:
            str += "<td style='width:50px; color:#0e3064;' title='Personal security'>Security:</td>";
            str += "<td style='width:40px;'><img src='images/negative.jpg'/></td>";
            str += "<td rowspan=3 style='text-align:right; width:111px;'><img src='images/img_010.jpg' width=111px height=119px /></td>";
            str += "</tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Sexual attraction'>Attraction:</td><td style='width:40px;'><img src='images/positive.jpg'/></td></tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Mental interest'>Interest:</td><td style='width:40px;'><img src='images/negative.jpg'/></td></tr>";
            str += "</table>";
            str += "<p style='font-size:12px; font-family:Courier New;'>";
            str += "There is a strong sexual attraction which is reflected in nervousness and a desire to continue the conversation under certain conditions. Nonetheless, the user is perceived negatively as an individual who is uninteresting, superficial, and shallow. Jenny has no security in the user and therefore feels uncomfortable and tries to end the conversation. In this state Jenny will be more restrained, will cooperate in a limited way, and will answer questions briefly with no enthusiasm.";
            str += "</p>";        
            break;

        case 4:
            str += "<td style='width:50px;' color:#0e3064;>Security:</td>";
            str += "<td style='width:40px;'><img src='images/negative.jpg'/></td>";
            str += "<td rowspan=3 style='text-align:right; width:111px;'><img src='images/img_011.jpg' width=111px height=119px /></td>";
            str += "</tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Sexual attraction'>Attraction:</td><td style='width:40px;'><img src='images/positive.jpg'/></td></tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Mental interest'>Interest:</td><td style='width:40px;'><img src='images/positive.jpg'/></td></tr>";
            str += "</table>";
            str += "<p style='font-size:12px; font-family:Courier New;'>";
            str += "The user has Jenny’s affection but has not gained her trust. Jenny will show interest and appear excited, but will not always fully cooperate. She might keep some sort of physical distance from the user for safety reasons. Her emotions will be reflected by her open body language (her upper part is turned towards the user, and her legs are crossed). She will gladly respond to most questions, but mainly non-intimate ones. Cooperation and extended answers are expected of her, in addition to a seductive style and teasing.";
            str += "</p>";        
            break;

        case 5:
            str += "<td style='width:50px; color:#0e3064;' title='Personal security'>Security:</td>";
            str += "<td style='width:40px;'><img src='images/positive.jpg'/></td>";
            str += "<td rowspan=3 style='text-align:right; width:111px;'><img src='images/img_100.jpg' width=111px height=119px /></td>";
            str += "</tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Sexual attraction'>Attraction:</td><td style='width:40px;'><img src='images/negative.jpg'/></td></tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Mental interest'>Interest:</td><td style='width:40px;'><img src='images/negative.jpg'/></td></tr>";
            str += "</table>";
            str += "<p style='font-size:12px; font-family:Courier New;'>";
            str += "Jenny has confidence in the user and does not fear him. However, she does not see any potential in him, neither mental nor sexual. There is no physical attraction or genuine desire to start chatting. Jenny will not pay much attention to the user. She might act politely and smile occasionally, but her answers will be short, primarily to be polite.";
            str += "</p>";       
            break;
            
        case 6:
            str += "<td style='width:50px; color:#0e3064;' title='Personal security'>Security:</td>";
            str += "<td style='width:40px;'><img src='images/positive.jpg'/></td>";
            str += "<td rowspan=3 style='text-align:right; width:111px;'><img src='images/img_101.jpg' width=111px height=119px /></td>";
            str += "</tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Sexual attraction'>Attraction:</td><td style='width:40px;'><img src='images/negative.jpg'/></td></tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Mental interest'>Interest:</td><td style='width:40px;'><img src='images/positive.jpg'/></td></tr>";
            str += "</table>";
            str += "<p style='font-size:12px; font-family:Courier New;'>";
            str += "Jenny feels secure. She regards the user as mental stimulation and sees in him a potential for a profound conversation. Nevertheless, there is no physical interest. In other words, the character does not consider the user as a potential lover. She will regard him as a true friend. Jenny will elaborate her answers, and may strive to converse more deeply.";
            str += "</p>";                 
            break;

        case 7:
            str += "<td style='width:50px; color:#0e3064;' title='Personal security'>Security:</td>";
            str += "<td style='width:40px;'><img src='images/positive.jpg'/></td>";
            str += "<td rowspan=3 style='text-align:right; width:111px;'><img src='images/img_110.jpg' width=111px height=119px /></td>";
            str += "</tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Sexual attraction'>Attraction:</td><td style='width:40px;'><img src='images/positive.jpg'/></td></tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Mental interest'>Interest:</td><td style='width:40px;'><img src='images/negative.jpg'/></td></tr>";
            str += "</table>";
            str += "<p style='font-size:12px; font-family:Courier New;'>";
            str += "Jenny has confidence in the user and she feels a sexual attraction. Her body language will be open, and cooperation is expected. Jenny might aspire for physical contact without redundant conversation topics. It is possible that she may give rise to more serious issues in order to test the user’s mental capabilities and to appease herself. Jenny will be smiling, perhaps even provocative. She is expected to elaborate her answers for personal and romantic issues.";
            str += "</p>";              
            break;
            
        case 8:
            str += "<td style='width:50px; color:#0e3064;' title='Personal security'>Security:</td>";
            str += "<td style='width:40px;'><img src='images/positive.jpg'/></td>";
            str += "<td rowspan=3 style='text-align:right; width:111px;'><img src='images/img_111.jpg' width=111px height=119px /></td>";
            str += "</tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Sexual attraction'>Attraction:</td><td style='width:40px;'><img src='images/positive.jpg'/></td></tr>";
            str += "<tr><td style='width:50px; color:#0e3064;' title='Mental interest'>Interest:</td><td style='width:40px;'><img src='images/positive.jpg'/></td></tr>";
            str += "</table>";
            str += "<p style='font-size:12px; font-family:Courier New;'>";
            str += "This is the ultimate situation for the user. Jenny has confidence in him, and she regards him as an intelligent and educated man. In addition, she sees sexual potential in him. The combination of these virtues creates a real challenge for Jenny and she thinks of the user as an ideal man for long term purposes. Jenny will be smiling most of the time. She will be polite, shy, and will do as much as possible to impress the user. She will most likely elaborate her answers, and radiate openness and full cooperation with the user. It is possible that she might try to bring up romantic issues. Jenny will strive to continue the conversation, unless an opportunity for future interactions with the user presents itself (phone number, a meeting place, etc.).";
            str += "</p>";         
            break;
        }
        
        str += "</div>";
        state_description.innerHTML = str;
    }
}

function PromoMissingResponses(sentence, index)
{
    var main_window = document.getElementById('MainWindow');
    
    if(main_window != null)
    {
        var str = GetCreationTopSection();

        /////////////////////
        str += "<div id='MainWindow_MainSection'>";
        str += "<br/><br style='font-size:8pt;'><span style='font-family:Arial Rounded MT Bold; color:#08036c; font-size:14pt;'>Jenny can respond to each sentence in 8 different ways depending on her state of mind.</span>";
        str += "<br><br><br>";
        str += "<span style='font-family:Arial Rounded MT Bold; color:#08036c; font-size:14pt;'>For Example:</span>";
        str += "<br><br><br><br>";
        str += "<span style='font-size:14pt;'>User: <b>My friend's throwing a party tomorrow, wanna come?</b></span>";
        str += "<br><br><br><br>";

        str += "<table>";
        str += "<tr>";

        str += "<td>";
        str += "<table>";
        str += "<tr>";
        str += "<td style='width:50px; color:#0e3064;' title='Personal security'>Security:</td>";
        str += "<td style='width:40px;'><img src='images/negative.jpg'/></td>";
        str += "<td rowspan=3 style='text-align:right; width:111px;'><img src='images/img_000.jpg' width=111px height=119px /></td>";
        str += "</tr>";
        str += "<tr><td style='width:50px; color:#0e3064;' title='Sexual attraction'>Attraction:</td><td style='width:40px;'><img src='images/negative.jpg'/></td></tr>";
        str += "<tr><td style='width:50px; color:#0e3064;' title='Mental interest'>Interest:</td><td style='width:40px;'><img src='images/negative.jpg'/></td></tr>";
        str += "</table>";
        str += "</td>";

        str += "<td>";
        str += "<span style='font-size:13pt;'>Jenny's Response:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><br><br>";
        str += "<span style='font-size:14pt;'><b>Forget it!</b></span>";
        str += "</td>";


        str += "<td>";
        str += "<table>";
        str += "<tr>";
        str += "<td style='width:50px; color:#0e3064;' title='Personal security'>Security:</td>";
        str += "<td style='width:40px;'><img src='images/positive.jpg'/></td>";
        str += "<td rowspan=3 style='text-align:right; width:111px;'><img src='images/img_110.jpg' width=111px height=119px /></td>";
        str += "</tr>";
        str += "<tr><td style='width:50px; color:#0e3064;' title='Sexual attraction'>Attraction:</td><td style='width:40px;'><img src='images/positive.jpg'/></td></tr>";
        str += "<tr><td style='width:50px; color:#0e3064;' title='Mental interest'>Interest:</td><td style='width:40px;'><img src='images/negative.jpg'/></td></tr>";
        str += "</table>";
        str += "</td>";

        str += "<td>";
        str += "<span style='font-size:13pt;'>Jenny's Response:</span><br><br>";
        str += "<span style='font-size:14pt;'><b>Yeah :) I'd love to!</b></span>";
        str += "</td>";


        str += "</tr>";
        str += "</table>";

            
        str += "</div>";
        ////////////////////

        sentence = ReplaceSymbols(sentence);
        str += "<div id='MainWindow_CreationControls'>";
        str += "<button onclick='FillPatterns(" + Commas + sentence + Commas + "," + index + ")'>Start Filling &#62;&#62;</button>";
        str += "</div>";
         
        main_window.innerHTML = str;
    }

    //urchinTracker('/mainpage/CreationForums/PromoMissingResponses');
}

function AddNewPattern()
{
    CurrentStringData = ChatID + "%FS%";
    CurrentStringData += CurrentUnrecognizedSentence + "%FS%";
    
    var i;
    
    for(i=0; i < 8; i++)
    {
        var state_description = document.getElementById('TextBox_Response_' + (i+1) );
            
        if (state_description != null)
        {
            if(state_description.value == "")
            {
                CurrentStringData = "";
                alert("\nPlease complete all possible responses before submitting.\n\nTo do that, simply fill Jenny's response next to each facial expression.");
                state_description.focus();
                return;
            }
            
            else
            {
                CurrentStringData += state_description.value;
            
                if(i < 7)
                {
                    CurrentStringData += "%FS%";
                }            
            }
        }
    }
    
    
    if(NickName == "")
    {
        var main_window = document.getElementById('MainWindow');
    
        if(main_window != null)
        {    
            var str = GetCreationTopSection();

            str += "<div id ='MainWindow_MainSection'>";    
            str += "<div style='padding:20px;'>";    
        
            str += "<br><br><br><br><span style='font-size:15px;'>Would you like to add your nickname?</span><br><br><br>";
            str += "Nick name:&nbsp;&nbsp;&nbsp;<input id='TextBox_NickName' type='text' style='' /><br><br>";
            str += "<hr style='width:265px;'>";
    
            str += "<img src='images/submittopic.jpg' title='Use nickname' onclick='AddNewPatternToServer(true)' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>";
            str += "<span style='font-size:11pt; vertical-align:top;' onclick='AddNewPatternToServer(true)' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>Yes</span>";
            str += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            str += "<img src='images/canceltopic.jpg' title='Don&#39;t use nickname' onclick='AddNewPatternToServer(false)' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>";
            str += "<span style='font-size:11pt; vertical-align:top;' onclick='AddNewPatternToServer(false)' onmouseover='makeOptional(this)' onmouseout='makeNormal(this)'>No thanks</span>";
            str += "</div>";    
            str += "</div>";    

            str += "<div id='MainWindow_CreationControls'>";
            str += "</div>";
        
            main_window.innerHTML = str;
        }
            
        var textbox_nickname = document.getElementById('TextBox_NickName');
    
        if(textbox_nickname != null)
        {
            textbox_nickname.focus();
        }
    }
    
    else
    {
        PageMethods.AddNewMissingResponses(GetMissingResponsesData(), GetAnswer, GetError, GetTimeout);
        ThankYouStep2();
    }
}

function AddNewPatternToServer(use_nickname)
{
    
    if(use_nickname)
    {
        var textbox_nickname = document.getElementById('TextBox_NickName');
    
        if(textbox_nickname != null)
        {
            NickName = textbox_nickname.value;
        }    
    }

    PageMethods.AddNewMissingResponses(GetMissingResponsesData(), GetAnswer, GetError, GetTimeout);
    ThankYouStep2();
}

function ThankYouStep2()
{
    var i;
    
    for(i=0; i <  MissingResponsesArray.length; i++)
    {
        if(CurrentUnrecognizedSentence == MissingResponsesArray[i])
        {
            
            MissingResponsesArray.splice(i,1);
            LastReceivedContextIndexArray.splice(i,1);
            break;
        }
    }
    
    
    var main_section = document.getElementById('MainWindow_MainSection');
    
    if(main_section != null)
    {
        var str = "<br><br>";
        str += "&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<table>";
        str += "<tr>";
        str += "<td style='width:615px;'>";
        str += "<span style='font-size:20px;'>Thank you for your help!</span>";
        str += "</td>";
        str += "<td rowspan=3>";
        str += "<img src='images/ThankYou2.jpg'/>";
        str += "</td>";
        str += "</tr>";
        str += "<tr>";
        str += "<td>";
        str += "<span style='font-size:14px;'>Your pattern will be added to Jenny's databases within 24h</span>";
        str += "</td>";
        str += "</tr>";
        str += "<tr>";
        str += "<td>";
        str += "<button onclick='CreationForums()' style='width:75px;'>OK</button><br>";
        str += "</td>";
        str += "</tr>";
        str += "<tr>";
        str += "<td colspan=2 valign=top>";
        str += "<hr>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";
        
        main_section.innerHTML = str;
    }
    
    else
    {
        FillMissingResponses();
    }

    //urchinTracker('/mainpage/CreationForums/ThankYou');
}


