﻿// JScript File


function ViewCode(templateId)
{
    openWin(
        'ViewCode.aspx?Id=' + templateId,
        'viewCode',
        'toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=590,height=425');
}

function ShowUserProfile(userId)
{
    openWin(
        '../forum/pop_up_profile.asp?PF=' + userId,
        'profile',
        'toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=590,height=425');
}

function ShowAuthorProfile(rulebaseId)
{
    openWin(
        'AuthorProfile.aspx?RulebaseId=' + rulebaseId,
        'profile',
        'toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=550,height=325');
}

//Function to open pop up window
function openWin(theURL,winName,features) {
  	window.open(theURL,winName,features);
}

function download()
{
    alert('Thank you for download');
    return false;
}

function deleteme()
{
    var del=confirm('Are you sure you want to delete !');
    return false;
}

function addcomment()
{
    alert('In Actual, will be redirected to FORUM for adding commnets');
    return false;
}

function approve()
{
    alert('Template approved successfully.');
    return false;
}

//Counting Characters In Textbox
function CharCount(textField, displayArea, maxChars)
{
    if (textField.value.length > maxChars)
        {
		    textField.value = textField.value.slice(0, maxChars);
        }
	displayArea.innerHTML =(parseInt(maxChars)-parseInt(textField.value.length));
 }	
 
 
//Clearing All Controls
function fnc_clearall()
{
  
  var controls=document.aspnetForm.elements;
  for(i=0;i<controls.length;i++)
  {
       switch(controls[i].type)
       {
            case "text":
            controls[i].value='';
            break

            case "password":
            controls[i].value='';
            break

            case "select-one":
            controls[i].selectedIndex=0;
            break  

            case "checkbox":
            controls[i].checked=true; 
            break
         
            case "textarea":
            controls[i].value='';
            var rd=document.getElementById('charcount');
            rd.innerHTML=500;
            break 
            case "radio":
            var rbtn0=controls[i].name + "_0";
            var rdbutton0=document.getElementById(String(rbtn0));
            rdbutton0.checked=true;
            break
       }
   }
           return false;
}
          
 //validating All Controls
function Fnc_Validate()
{
  var controls=document.aspnetForm.elements;
  for(i=0;i<controls.length;i++)
      {
       switch(controls[i].type)
          {
               case "select-one":
               if (controls[i].selectedIndex==0)
               {
                   if(i==4)
                    {
                    alert('select any Application');
                    return false;
                     }
                   if(i==5)
                       {
                    alert('select any Language');
                    return false;
                       }
                   if(i==6)
                     {
                    alert('select any Databse');
                      return false;
                      }  
                         
                   }
                    break
                    case "file":
                   if (controls[i].value=='')
                      {
                       alert('select any file');
                       return false;
                      }
                  break
                    
                }
           }
       
      }

