﻿function getUrlParam( name ){  
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    var regexS = "[\\?&]"+name+"=([^&#]*)";  
    var regex = new RegExp( regexS );  
    var results = regex.exec( window.location.href );  
    if( results == null )    
        return "";  
    else    
        return results[1];
}


function DropDups() {
    var Target=document.forms[0]['ctl00_contentMainPlaceHolder_'];
    var TIx1, TValue0, TValue1, TText0, TText1;
    for (TIx1=1; TIx1<Target.options.length; TIx1++) {
        TValue0=Target.options[TIx1-1].value;
        TText0 =Target.options[TIx1-1].text;
        TValue1=Target.options[TIx1].value;
        TText1 =Target.options[TIx1].text;
        if ((TValue1 == TValue0) && (TText1 == TText0)) {
            Target.options[TIx1]=null;
            TIx1-=1;
        }
    }
}


function clearText(obj,str)
{
    if(obj.value==str){
        obj.value='';
    }
    else{
    }
}

            
function addText(obj,str)
{
    if(obj.value == ''){
        obj.value=str;
    }
    else{
    }
}


function showHideColumn(){
    var loc
    var win
    win = window.location;
    loc = win.href;
    
    if(loc.indexOf('admin') != -1)
    {
//        document.getElementById('tdColumn1').style.display = 'none';
//        document.getElementById('tdColumn2').style.display = 'none';
//        document.getElementById('tdColumn3').style.display = 'none';
        document.getElementById('left').style.display = 'none';
    }
}

function cancelWindow(){
    HideUserDetails();
}

function TestFileType( fileName, fileTypes ) {
    if (!fileName) return;
        dots = fileName.split(".")

    //get the part AFTER the LAST period.
    fileType = "." + dots[dots.length-1];

    if(fileTypes.join(".").indexOf(fileType) != -1){
        document.getElementById('titleNm').style.display = '';
        return true;
    }
    else{
        alert("Please only upload files that end in types: \n\n" + (fileTypes.join(" .")) + "\n\nPlease select a new file and try again.");
//        document.getElementById('ctl00_contentMainPlaceHolder_uploadBtn').value='';
       window.aspnetForm.reset();
       document.getElementById('videoUrl').style.display = 'none';
       document.getElementById('fileUrl').style.display = 'none';
       return false;
    }
//    return (fileTypes.join(".").indexOf(fileType) != -1) ?
//    alert('That file is OK!') : 
//    alert("Please only upload files that end in types: \n\n" + (fileTypes.join(" .")) + "\n\nPlease select a new file and try again.");
}

function sortList(lst) 
{ 
    var lb = document.getElementById(lst); 
    arrTexts = new Array(); 
    arrValues = new Array(); 
    arrOldTexts = new Array(); 

    for(i=0; i<lb.length; i++) 
    { 
        arrTexts[i] = lb.options[i].text; 
        arrValues[i] = lb.options[i].value; 

        arrOldTexts[i] = lb.options[i].text; 
    } 

    arrTexts.sort(); 

    for(i=0; i<lb.length; i++) 
    { 
        lb.options[i].text = arrTexts[i]; 
        for(j=0; j<lb.length; j++) 
        { 
            if (arrTexts[i] == arrOldTexts[j]) 
            { 
                lb.options[i].value = arrValues[j]; 
                j = lb.length; 
            } 
        } 
    } 
}


function clearListbox(lb)
{ 
    document.getElementById(lb).options.length = 0; 
} 

function AddItem(Text,Value,Control)
{
    var opt = document.createElement("option");
    document.getElementById(Control).options.add(opt);
    opt.text = Text;
    opt.value = Value;
}

