function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function toggle_comment()
{
    
      var vis, dis;

        
	vis = document.getElementById("commentbox").style.visibility;
	dis = document.getElementById("commentbox").style.display;

	ratingvis = document.getElementById("ratingpanel").style.visibility;
	ratingdis = document.getElementById("ratingpanel").style.display;
	
	if(ratingvis == "hidden" && ratingdis == "none")
	{
	    if(vis=="hidden" && dis=="none")
	    {     
		    document.getElementById("commentbox").style.visibility = "visible";
		    document.getElementById("commentbox").style.display = "block";
		}
		else if(vis=="visible" && dis=="block")
		{     
		    document.getElementById("commentbox").style.visibility = "hidden";
		    document.getElementById("commentbox").style.display = "none";
		}
		
		return false;
	}
	else if(ratingvis == "visible" && ratingdis == "block")
	{
	    document.getElementById("ratingpanel").style.visibility = "hidden";
		document.getElementById("ratingpanel").style.display = "none";
		document.getElementById("commentbox").style.visibility = "visible";
		document.getElementById("commentbox").style.display = "block";
	}
}

function toggle_rating()
{
       
	var vis, dis;
	
	vis = document.getElementById("ratingpanel").style.visibility;
	dis = document.getElementById("ratingpanel").style.display;
	
	commentvis = document.getElementById("commentbox").style.visibility;
	commentdis = document.getElementById("commentbox").style.display;
	
	if(commentvis=="hidden" && commentdis=="none")
	{
	    if(vis=="hidden" && dis=="none")
	    {
		    document.getElementById("ratingpanel").style.visibility = "visible";
		    document.getElementById("ratingpanel").style.display = "block";
		    return false;
		}
		else
		{
		    document.getElementById("ratingpanel").style.visibility = "hidden";
		    document.getElementById("ratingpanel").style.display = "none"; 
		}
	}
	else if(commentvis=="visible" && commentdis=="block")
	{
		//document.getElementById("ratingpanel").style.visibility = "hidden";
		//document.getElementById("ratingpanel").style.display = "none";
		//alert("no way");
		document.getElementById("commentbox").style.visibility = "hidden";
		document.getElementById("commentbox").style.display = "none";
		document.getElementById("ratingpanel").style.visibility = "visible";
		document.getElementById("ratingpanel").style.display = "block";
	}
}

function check()
{
        document.getElementById("commentbox").style.visibility = "hidden";
		document.getElementById("commentbox").style.display = "none";
}

   
function validateComments()
{
     
     var charlength, txtval;
     txtval = document.getElementById('ctl00_placeHolderContainer_placeHolderMainContent_placeHolderColumn02_txtCommentbox').value;
     charlength = txtval.length;
     if(txtval.length > 1025 || txtval.length < 5)
     {
          alert("Your comment should be minimum of 5 characters, not exceeding 1025 characters.")
          return false;
     }
     else
     {
        return true;
     }

}


function validateArticleComments(ctrlID)
{
     var charlength, txtval;
     txtval = trim(document.getElementById(ctrlID).value);
     charlength = txtval.length;
     
     if(txtval.length > 1025 || txtval.length < 5)
     {
          alert("Your comment should be minimum of 5 characters, not exceeding 1025 characters.")
          return false;
     }
     else
     {
        return true;
     }
     
}
function validateTopicMessage(ctrlID)
{
     var charlength, txtval;
     txtval = trim(document.getElementById(ctrlID).value);
     charlength = txtval.length;
     
     if(txtval.length > 1025 || txtval.length < 5)
     {
          alert("Your message should be minimum of 5 characters, not exceeding 1025 characters.")
          return false;
     }
     else
     {
        return true;
     }
     
}

function validateReplySubject(ctrlID,ctrlMesID)
{

     var charlength, txtval,charlength1,txtval;
     
     txtval = trim(document.getElementById(ctrlID).value);
     charlength = txtval.length;
     
     txtval1= trim(document.getElementById(ctrlMesID).value);
     charlength1 = txtval1.length;
     if((txtval.length > 60 || txtval.length < 5) &&(txtval1.length > 1025 || txtval1.length < 5))
     {
         alert("Please enter the subject and message containing minimum of alteast 5 characterrs.")
         return false;
     }
     
     else if((txtval1.length > 1025 || txtval1.length < 5) &&( txtval.length < 60 || txtval.length > 5))
     {
          alert("Your Message should be minimum of 5 characters, not exceeding 1025 characters.")
          return false;
     }
     else if((txtval.length > 60 || txtval.length < 5) && (txtval1.length < 1025 || txtval1.length > 5))
     {
          alert("Your Subject should be minimum of 5 characters, not exceeding 60 characters.")
          return false;
     }
     else
     {
        return true;
     }
}


function validateTradeDescription(ctrlID)
{
     var charlength, txtval;
     txtval = trim(document.getElementById(ctrlID).value);
     charlength = txtval.length;
     if(txtval.length > 300)
     {
          alert("Description should be between 1-300 in character lenght")
          return false;
     }
     else
     {
        return true;
     }
     
}

function getOtherCityvalue(drpID,txtID)
{   
    var drpBox = document.getElementById(drpID);
    var txtBox = document.getElementById(txtID);       
    
    if(drpBox.options[drpBox.options.selectedIndex].value == "others")
    {           
        txtBox.style.visibility="visible";
    }
    else
    {
       txtBox.style.visibility="hidden";
    }
    
}
function uploadmore()
{
	 var vis, dis;
	
	vis = document.getElementById("uploadmore").style.visibility;
	dis = document.getElementById("uploadmore").style.display;
	
	if(vis=="hidden" && dis=="none")
	{
		document.getElementById("uploadmore").style.visibility = "visible";
		document.getElementById("uploadmore").style.display = "block";
	}
	else if(vis=="visible" && dis=="block")
	{
		document.getElementById("uploadmore").style.visibility = "hidden";
		document.getElementById("uploadmore").style.display = "none";
	}

}