﻿// JScript File

function ValidateTags(txtField,txtWhichType)
{
var Isvalid=true;
var val=document.getElementById(txtField)
if (val.value=='')
    {
    alert('Invalid Url');
    Isvalid=false;
    }
else
    {
    var vals=document.getElementById(txtWhichType).value;

    if(vals=='2')
        {
        var insertingText=' [[Video="'+val.value+'"]] ';
        insertText(document.getElementById('txtReply'),insertingText);
        }
    else if(vals=='3')
        {
        var insertingText=' [[Audio="'+val.value+'"]] ';
        insertText(document.getElementById('txtReply'),insertingText);
        }
    else if(vals=='1')
        {
        var insertingText=' [[Img="'+val.value+'"]] ';
        insertText(document.getElementById('txtReply'),insertingText);
        }
    else if(vals=='4')
        {
        var insertingText=' [[url="'+val.value+'"]] ';
        insertText(document.getElementById('txtReply'),insertingText);
        }
}

return Isvalid;
}

function SetHiddenValue(txtWhichType, val)
{
    document.getElementById(txtWhichType).value=val;
}


function focusPopupText()
{
    var txt=document.getElementById('txtGetUrl');

    if (txt.value!='')
    {
        txt.value='';
        txt.focus();
    }
    else
        txt.focus();
}

function AddEmotions(text)
{
    insertText(document.getElementById('txtReply'),text);
}

function insertText(element, text)
 { 
    // Put focus on the element so IE doesn't insert the text in 
    // another part of the page. 
    element.focus();         
 
    // IE supports document.selection. 
    if (document.selection) { 
        // Create a textRange object. 
        var range = document.selection.createRange();         
 
        // Add text to the textRange text property. 
        range.text += text;         
 
        // Scroll inserted text into view. 
        range.scrollIntoView();         
 
        return; 
    }         
 
    // Find the end of the current selection. If there is no text 
    // selected then selectionEnd is the location of the cursor. 
    var position = element.selectionEnd;         
 
    // Insert text after the end of the selection. 
    var beforeText = element.value.substring(0, position); 
    var afterText = element.value.substring(position, 
        element.value.length 
    );         
 
    element.value = beforeText +' '+ text +' '+ afterText;         

    // Select inserted text, element already has focus. 
//    element.setSelectionRange(position, position + text.length); 
}

function HideModalPopup()
{
    document.getElementById('GetInput').style.display='none';
}

