function select_tprofile()
{
    document.getElementById("tp").style.display = '';
    document.getElementById("bp").style.display = 'none';
}
function select_bprofile()
{
    document.getElementById("tp").style.display = 'none';
    document.getElementById("bp").style.display = '';
}
function addphoto(maxval) 
{
    for (i=0;i<maxval;i++) 
    {
        if (document.getElementById("photo"+i).style.display == 'none') 
        {
            document.getElementById("photo"+i).style.display = '';
            break;
        }
    }
}
function removephoto(idx) 
{
    document.getElementById("pgi"+idx).value = "";
    document.getElementById("pgt"+idx).value = "";
    document.getElementById("photo"+idx).style.display = 'none';
}
function addvideo(maxval) 
{
    for (i=0;i<maxval;i++) 
    {
        if (document.getElementById("video"+i).style.display == 'none') 
        {
            document.getElementById("video"+i).style.display = '';
            break;
        }
    }
}
function removevideo(idx) 
{
    document.getElementById("vgi"+idx).value = "";
    document.getElementById("vgt"+idx).value = "";
    document.getElementById("video"+idx).style.display = 'none';
}
function link_action(itemid, lid, act, msg366, msg367)
{
    var msg, acturl;
    
    if (act == 1)
    {
        msg = msg366;
        acturl = "index.php?option=com_jvse&Itemid="+itemid+"&task=approvelink&lid="+lid;
    }
    else if (act == 0)
    {
        msg = msg367;        
        acturl = "index.php?option=com_jvse&Itemid="+itemid+"&task=rejectlink&lid="+lid;
    }
    else
        return;
        
    if (confirm(msg))
    {
        document.location.href = acturl;
        return;
    }
}
function close_me(murl)
{
    window.opener.location=murl; 
    window.close();                
}
function countleft(field, count, max) 
{ 
    if (field.value.length > max) 
        field.value = field.value.substring(0, max); 
    else 
        count.value = max - field.value.length; 
}
function confirm_link_delete(itemid, lid, msg)
{
    if (confirm(msg))
    {
        document.location.href = "index.php?option=com_jvse&Itemid="+itemid+"&task=deletelink&lid="+lid;
        return;
    }
}
function confirm_delete(itemid, pid, msg)
{
    if (confirm(msg))
    {
        document.location.href = "index.php?option=com_jvse&Itemid="+itemid+"&task=delprofile&pid="+pid;
        return;
    }
}
function confirm_deletephoto(msg, url)
{
    if (confirm(msg))
    {
        document.location.href = url;
        return;
    }
}
function confirm_deletevideo(msg, url)
{
    if (confirm(msg))
    {
        document.location.href = url;
        return;
    }
}
function showlinks(sby, sord)
{
    document.slf.sby.value = sby;    
    document.slf.sord.value = sord;
    document.slf.submit();
}
function check_newtestimonial(obj, msg)
{
    if ((obj.revcomm.value == '') || (obj.revtitle.value == '') || (obj.revname.value == '') || (obj.revemail.value == '')) 
    {
        alert(msg);
        return false;
    }
    
    if ((obj.rating != null) && (obj.rating.value == 0))
    {
        alert(msg);
        return false;        
    }
        
    return true;
}
function check_recform(obj, msg)
{
    if ((obj.w_name.value == '') || (obj.w_email.value == '') || (obj.w_url.value == '') || (obj.w_reason.value == ''))
    {
        alert(msg);
        return false;
    }
    
    return true;
}
function check_scatform(obj, msg)
{
    if ((obj.s_name.value == '') || (obj.s_desc.value == '') || (obj.s_by.value == ''))
    {
        alert(msg);
        return false;
    }
    
    return true;
}
function check_tafform(obj, msg)
{
    if ((obj.sender_name.value == '') || (obj.friend_email.value == '') || (obj.comments.value == ''))
    {
        alert(msg);
        return false;
    }
    
    return true;
}
function check_cls(obj, msg)
{
    if (obj.w_url.value == '')
    {
        alert(msg);
        return false;
    }
    
    return true;
}
function jvld_checkaddform_fields_payinfo(obj, msg1)
{
    if ((obj.refid.value == '') || (obj.payeremail.value == '')) 
    {
        alert(msg1);
        return false;
    }
    
    return true;
}
function jvld_checkaddform_fields_basicinfo(obj, msg1, msg2, maxscat, destid, urloptional)
{
    if (urloptional == 0) 
    {
        if (obj.url.value == '') 
        {
            alert(msg1);
            return false;
        }
    }
        
    if (obj.email.value == '')
    {
        alert(msg1);
        return false;
    }
    
    if (obj.pcat.value == 0) {
        alert(msg2);
        return false;        
    }

    if (maxscat > 0)
        var listbox = document.getElementById(destid);
        for(var count=0; count < listbox.options.length; count++) {
            listbox.options[count].selected = true;
    }

    return true;
}
function jvld_checkaddform_fields_prefinfo(obj, msg1)
{
    if (obj.agreement.checked == 0) 
    {
        alert(msg1);
        return false;
    }

    return true;
}
function jvld_checkaddform2_fields_basicinfo(obj, msg1, msg2, maxscat, destid)
{
    if ((obj.url.value == '') || (obj.email.value == '') || (obj.rlink.value == '')) 
    {
        alert(msg1);
        return false;
    }
    
    if (obj.pcat.value == 0) {
        alert(msg2);
        return false;        
    }
    
    if (maxscat > 0)
        var listbox = document.getElementById(destid);
        for(var count=0; count < listbox.options.length; count++) {
            listbox.options[count].selected = true;
    }    
    
    return true;
}
function jvld_checkaddform2_fields_prefinfo(obj, msg1)
{
    if (obj.agreement.checked == 0) 
    {
        alert(msg1);
        return false;
    }

    return true;
}
function jvld_checkcsponsor_fields_payinfo(obj, msg1)
{
    if ((obj.refid.value == '') || (obj.payeremail.value == '')) 
    {
        alert(msg1);
        return false;
    }
    
    return true;
}
function jvld_checkad_fields_payinfo(obj, msg1)
{
    if ((obj.refid.value == '') || (obj.payeremail.value == '')) 
    {
        alert(msg1);
        return false;
    }
    
    return true;
}
function jvldClearText(field){
    if (field.defaultValue == field.value) 
        field.value = '';
    else if (field.value == '') 
        field.value = field.defaultValue;
}
function jvldmoveright(maxlen, srcid, destid, maxmsg) {
    var src = document.getElementById(srcid);
    var dest = document.getElementById(destid);
    
    if (maxlen > 0) {
        if (dest.options.length >= maxlen) {
            alert(maxmsg);
            return;
        }
    }
    
    var destlen = dest.options.length;
    for(var count=0; count < src.options.length; count++) { 
        if(src.options[count].selected == true) {
            if (src.options[count].value == 0) {
                break;
            }
            
            var option = document.createElement("option");
            option.text = src.options[count].text;
            option.value = src.options[count].value;
            dest.add(option, null);
            break;
        }
    }
}
function jvldmoveleft(destid) {
    var dest = document.getElementById(destid);  
    for(var count=0; count < dest.options.length; count++) { 
        if(dest.options[count].selected == true) {
            dest.remove(count);
            break;
        }
    }    
}

var copytoclip=1;
function HighlightAll(theField, msg) 
{
    var tempval=eval("document."+theField);
    tempval.focus();
    tempval.select();

    if (document.all&&copytoclip==1)
    {
        therange=tempval.createTextRange();
        therange.execCommand("Copy");
        window.status=msg;
        setTimeout("window.status=''",1800);
    }
}

