/**
*@desc Function to sort and paginate the thumbnails on right panel
*/
function fnSortVideo(intContestId, intCompId,intPairId, stype, rowsperpages, page)
{
    /**
    * @desc Setting default values on sorting
    */ 
    var sorder = document.getElementById('sorder').value;
    if(stype=='sdate')
    {
        if(sorder=='desc')
            document.getElementById('sdate').innerHTML="Date (-)";
        else
            document.getElementById('sdate').innerHTML="Date (+)";
        //reset other options
        document.getElementById('place').innerHTML="Place (+)"; 
        document.getElementById('score').innerHTML="Score (+)";
    }
    else if(stype=='place')
    {
        if(sorder=='desc')
            document.getElementById('place').innerHTML="Place (-)";
        else
            document.getElementById('place').innerHTML="Place (+)";
        //reset other options
        document.getElementById('score').innerHTML="Score (+)"; 
        document.getElementById('sdate').innerHTML="Date (+)";
    }
    else
    {   
        stype='score';  
        if(sorder=='desc')
            document.getElementById('score').innerHTML="Score (-)";
        else
            document.getElementById('score').innerHTML="Score (+)";
        //reset other options
        document.getElementById('place').innerHTML="Place (+)"; 
        document.getElementById('sdate').innerHTML="Date (+)";          
    }
    /*alert(stype);    
    alert(sorder);    */   
    // Call Ajax function
    if(intCompId>0)
    {
        objRegistration.fnLoadPageScorecard(page,intCompId,intPairId,intContestId,stype,sorder,rowsperpages);
    }
    if(sorder!='desc')
    {
        sorder='asc';
        document.getElementById('sorder').value='desc';
    }
    else
    {
        document.getElementById('sorder').value='asc';    
    } 
    //objRegistration.fnSortUScoreVideo($intContestId, intTeamId, stype, sorder, rowsperpages, page);   
}

//Separate function called for oaging to avoind change while sorting function
function fnSortVideoPaging(intContestId, intCompId,intPairId,  stype, sorder, rowsperpages, page)
{ 
   if(intCompId>0)
    {     
        objRegistration.fnLoadPageScorecard(page,intCompId,intPairId,intContestId,stype,sorder,rowsperpages);
    } 
}

function fnEventVideo(intCompId,intPairId, intContestId, rows_per_pages, intSnNo1)
{
    for(i=0;i<=document.getElementById('hiddTotalEvs').value;i++)
    {
        if(i==0) 
        {
            idCont = "idStyle"
        }
        else
        {
            idCont = "idStyle"+i;
        }
        if(i==intSnNo1 && document.getElementById("idDivEv"+i).innerHTML!='')
        {
            document.getElementById(idCont).blur();
            document.getElementById("idLi"+i).style.border="";
            document.getElementById(idCont).style.backgroundColor="";
             
            document.getElementById(idCont).style.backgroundImage='url('+siteUrl+'/images/arrow-blue01.gif)';
            document.getElementById("idDivEv"+i).innerHTML="";
        }
        else if(i==intSnNo1)
        {
            document.getElementById(idCont).blur();  
            document.getElementById("idLi"+i).style.borderColor="red";
            document.getElementById("idLi"+i).style.borderWidth="2px"; 
            document.getElementById("idLi"+i).style.borderStyle="solid";
            document.getElementById(idCont).style.backgroundColor="#CBDAF7";
            
            document.getElementById(idCont).style.backgroundImage='url('+siteUrl+'/images/arrow-blue-dn.png)';
            objRegistration.fnEventVideoScorecard(intCompId,intPairId, intContestId, rows_per_pages, intSnNo1);           
        }
        
        else if(i>0)
        {
            document.getElementById("idLi"+i).style.border="";
            document.getElementById(idCont).style.backgroundColor="";
            document.getElementById(idCont).style.backgroundImage='url('+siteUrl+'/images/arrow-blue01.gif)';
            document.getElementById("idDivEv"+i).innerHTML="";
        } 
    }
     
}

/* Javscript function for comments */

function fnShowReplayBox(id,type,comm_id)
{
    if(type=='hide')
    {
        document.getElementById('reply'+id).innerHTML='';
    }
    else
    {
        document.getElementById('reply'+id).innerHTML='<form action="" method="POST" onsubmit="return fnCheckComment('+id+');"><div style="float:left;padding-left:10px;"><div><textarea name="txtReply" id="comment'+id+'" rows="5" cols="40" onKeyDown="limitText(document.getElementById(\'comment'+id+'\'),document.getElementById(\'countdown'+id+'\'),500);" onKeyUp="limitText(document.getElementById(\'comment'+id+'\'),document.getElementById(\'countdown'+id+'\'),500);"></textarea></div><div><span style="float:left;"><input type="submit" name="add_comment" value="Post Comment" />&nbsp;&nbsp;<input type="Button" name="cancel" value="Cancel" onclick="fnShowReplayBox(\''+id+'\',\'hide\');" /><font style="font-size:12px;font-weight:normal">You have <span id="countdown'+id+'">500</span> characters left.</font><br /><font size="1">(Maximum characters: 500)</font></span></div></div><div id="replyPostVideo" style="float:left; padding-left:5px;text-align:center;"></div> <input type="hidden" name="hdReplyId" value="'+comm_id+'" /></form>';
    }
}
function fnDisplyComm(id,type)
{
    if(type=='more')
    {
        document.getElementById('less'+id).style.display='block';
        document.getElementById('more'+id).style.display='none';
    }
    else if(type=='less')
    {
        document.getElementById('less'+id).style.display='none';
        document.getElementById('more'+id).style.display='block';
    }
}

function limitText(limitField, limitCount, limitNum) 
{
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } else {
        limitCount.innerHTML = limitNum - limitField.value.length;
    }
}
function fnCheckComment(id){
//alert(id+" -----------" +"--------- "+document.getElementById('comment'+id).value);
    if(document.getElementById('comment'+id).value.replace(/^\s+|\s+$/g,"")=="")
    {
        alert("Please enter comments!");
        return false;
    }
}

//Separate function called for applying pagination to comments
function fnPagingComment(intId, strType, intTotalRec,intRowsPerPage, intPage)
{
    document.getElementById('frndComment').innerHTML='<img align="center" src="http://worldwidechamp.com/images/ajax-loader-small.gif" />';
    objRegistration.fnPagingComment(intId, strType, intTotalRec,intRowsPerPage, intPage);  
}

