var re = /^[\w\s ]+$/;

function checkOpt(count,des,mes)
  {	var i=0;
	var disp;
//alert("alert"+count+des+mes);
	switch(des){
		case 1:
			disp = 'Forum';
			break;
		case 2:
			disp = 'Topic';
			break;
		case 3:
			disp = 'File';
			break;
		case 4:
			disp = 'Package';
			break;
		case 5:
			disp = 'News';
			break;

		case 6:
			disp = 'Diary';
			break;

		case 7:
			disp = 'Release';
			break;
		case 8:
			disp = 'User';
			break;

		case 9:
			disp = 'Folder';
			break;

		case 12:
			disp = 'Banner';
			break;
		case 10:
			disp = 'Project';
			break;
		case 15:
			disp = 'Item';
			break;
		case 13:
			disp = 'category';
			break;
		case 17:
			disp = 'posts';
			break;

		case 18:
			disp = 'Role';
			break;
		case 19:
			disp = 'User';
			break;
		case 20:
			disp = 'List';
			break;

		case 21:
			disp = 'Tracker';
			break;
		case 22:
			disp = 'Artifact';
			break;
		case 23:
			disp = 'Code';
			break;
		case 24:
			disp = 'Template';
			break;
		case 25:
			disp = 'Custom Field';
			break;
		case 26:
			disp = 'Element';
			break;
		case 28:
			disp = 'Connection';
			break;
		case 27:
			disp = 'Repository';
			break;
		case 30:
			disp = 'Content';
			break;

		case 29:
			disp = 'Message';
			break;
		case 31:
			disp = 'Tool';
			break;

		default:
			disp = 'Item';
			break;

	}
	switch(mes){

		case 1:
			mess = 'Edit';
			break;
		case 2:
			mess = 'Browse';
			break;
		case 3:
			mess = 'delete';
			break;
		case 4:
			mess = 'Remove';
			break;
		case 5:
			mess = 'Update';
			break;
		case 6:
			mess = 'Move';
			break;
		case 7:
			mess = 'Join';
			break;
		case 8:
			mess = 'add';
			break;
		case 9:
			mess = 'Send Mail';
			break;

		case 10:
			mess = 'View Subscribers';
			break;

		case 11:
			mess = 'View Permissions';
			break;

		case 12:
			mess = 'Assign Users';
			break;

		case 13:
			mess = 'Clone';
			break;
		case 14:
			mess = 'Undelete';
			break;

		case 55:
			mess = 'Create Customfield';
			break;
		case 56:
			mess = 'Download.csv';
			break;
		case 57:
			mess = 'Copy';
			break;
		case 58:
			mess = 'Add Element';
			break;
		case 59:
			mess = 'View';
			break;
		case 60:
			mess = 'Custom Search';
			break;
		case 15:
			mess = 'Assign roles';
			break;
		case 16:
			mess = 'View lists';
			break;

		case 17:
			mess = 'approve';
			break;

	}


     for(i=1;i<=count;i++)
     {
       if(document.getElementById("opt"+i).checked==true)
         return true;
     }
     document.getElementById('error_message').innerHTML = "Select a "+disp+" to "+mess;
     return false;



  }


function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function special_char_check(str)
{
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
	for (var i = 0; i < str.length; i++) {
  	if (iChars.indexOf(str.charAt(i)) != -1) {
  	alert ("Your Project name has special characters. \nThese are not allowed.\n Please remove them and try again.");
  	return false;
  	}
  }
}
//template url linking
function changeLink()
{

	t_id = document.getElementById('proj_template').value;

	if(t_id>0){
		document.getElementById('tempLink').innerHTML = "Template Details";
	}else{
		document.getElementById('tempLink').innerHTML = "";
	}
        document.getElementById('tempLink').href="/register/template_details.php?tmp_id="+t_id+"&flg=sh";
        document.getElementById('tempLink').target="_blank";

}
function proj_special_char_check(str)
{
	var iChars = "!@#$%^&*()+=[]\\\';,./{}|\":<>?";
	for (var i = 0; i < str.length; i++) {
  	if (iChars.indexOf(str.charAt(i)) != -1) {
  	alert ("Your Project name has special characters. \nThese are not allowed.\n Please remove them and try again.");
  	return false;
  	}
  }
}
function check_project_reg()
{
	var pro;
	pro = document.getElementById("pro_name").value;
	descrip =  document.getElementById("description").value;
/*	pro_intro =  document.getElementById("project_intro").value
	var pro_type = document.getElementById('proj_type').value;
	var pro_visible = document.getElementById('proj_visible').value;
	var pro_template = document.getElementById('proj_template').value;	*/

	specchar=proj_special_char_check(pro);
        if(specchar==0){
                return false;
         }


	if(trim(pro)==''){
		document.getElementById('error_message').innerHTML = "Enter Project Name";
		return false;
	}
/*	if(trim(pro_intro)==''){
		document.getElementById('error_message').innerHTML = "Enter Project Introduction";
		return false;
	}	*/
	if(trim(descrip)==''){
		document.getElementById('error_message').innerHTML = "Enter Project Description";
		return false;
	}
/*	if(pro_type == ''|| pro_type == '--Select--') {
		document.getElementById('error_message').innerHTML = "Select Project type";
		return false;
	}
	if(pro_visible == '' || pro_visible == '--Select--') {

		document.getElementById('error_message').innerHTML = "Select Project Visibility";
		return false;
	}
	if(pro_template == '' || pro_template == '--Select--') {
		document.getElementById('error_message').innerHTML = "Select Project Template";
		return false;
	}	*/

	/*
	if(trim(pro_intro).length >70)
	{
		alert("Please enter Maximum 70 characters");
		return false;
	}

	if(descrip.length>200)
	{
		alert("Maximum 255 characters allowed");
		return false;
	}

	*/
	var oEditor = FCKeditorAPI.GetInstance('advert_value') ;

	// Get the Editor Area DOM (Document object).
	var oDOM = oEditor.EditorDocument ;

	var iLength ;

	// The are two diffent ways to get the text (without HTML markups).
	// It is browser specific.

	if ( document.all ) // If Internet Explorer.
	{
		iLength = oDOM.body.innerText.length ;
	}
	else // If Gecko.
	{
		var r = oDOM.createRange() ;
		r.selectNodeContents( oDOM.body ) ;
		iLength = r.toString().length ;
	}
	if(iLength > 255)
	{
		alert( 'Only 255 characters allowed, Actual Content contains ' + iLength + ' characters' ) ;
		return false;
	}
	if(iLength < 10)
	{
		alert('Advertisement should be minimum 10 characters long');
		return false;
	}

	return true;
}

function check_template_create()
{
	var pro;

	pro = document.getElementById("template_name").value;
	specchar=special_char_check(pro);
         if(specchar==0){
                return false;
         }


	if(trim(pro)==''){
		alert("Please Enter Template Name");
		return false;
	}
return true;
}
function checkempty(theform){
var returnval=true //by default, allow form submission
for (i=0; i<theform.elements.length; i++){

	if (theform.elements[i].type=="text" || theform.elements[i].type=="textarea"  ){

		if (theform.elements[i].value==""){ //if empty field
			specchar=special_char_check(pro);
                         if(specchar==0){
                return false;
         }

			if (theform.elements[i].name != "location_url"){
				alert("Please make sure all fields are entered") //alert error message
				theform.elements[i].focus();
				returnval=false //thisallow form submission
				break //end loop. No need to continue.
			}
		}
	}
}
return returnval
}



function chectNewsDate(news_date){
var res;
	var req = getXMLHTTP();
    var url = "/plugins/espnews/checknewsdateAjax.php?news_date="+news_date;
    if (req) {
            req.onreadystatechange = function() {
            if (req.readyState == 4) {
                    if (req.status == 200) {
                             document.getElementById('flag_for_news_date').innerHTML = req.responseText;
                    } else {
                            alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                            }
                    }
            }
            req.open("GET", url, true);
            req.send(null);
    }
}



////Add new news validation script//
function validate_addnews(){

if(trim(document.getElementById("summary").value)=='')
{
alert("Please enter news headlines");
return false;
}else if(document.getElementById("summary").value.length < 3 || document.getElementById("summary").value.length > 255)
{

alert("News headlines allows minimum 3 characters and maximum 255 characters only");
return false;
}
if(document.getElementById("news_date").value=='')
{
alert("Please enter news date");
return false;
}
//chectNewsDate(document.getElementById("news_date").value);

if(document.getElementById("loc1").checked==true)
{
var oEditor = FCKeditorAPI.GetInstance('details') ;

// Get the Editor Area DOM (Document object).
var oDOM = oEditor.EditorDocument ;

var iLength ;

// The are two diffent ways to get the text (without HTML markups).
// It is browser specific.

if ( document.all ) // If Internet Explorer.
{
iLength = oDOM.body.innerText.length ;
}
else // If Gecko.
{
var r = oDOM.createRange() ;
r.selectNodeContents( oDOM.body ) ;
iLength = r.toString().length ;
}
if(iLength > 10000)
{
alert( 'Actual news  exceeds : ' + iLength + 'characters' ) ;
return false;
}
if(iLength < 10)
{
alert('News  should be maximum 10 characters long');
return false;
}
var PART2 = oEditor.GetXHTML(true);
if(!PART2){
alert("Please enter summary for news");
return false;
}
}
else
{
if(trim(document.getElementById("url").value)=='')
{
alert("Please enter remote url for news");
return false;
}
}
if(document.getElementById("newsFlag").value != "ok"){
alert("Please choose current or future date");
return false;
}

}
//////////Ends/////////////////


///////////////////////////////////////////////////////// MY Page Validations Starts ////////////////////////////////////////////////////////////////

// Diary & Notes Validations


	function diary_validate()
	{

		// Summary

		if(document.getElementById("summary").value=="")
		{
			document.getElementById('error_message').innerHTML = "Please Enter Summary Name";
			return false;
		}
		if(document.getElementById("summary").value.length < 3 || document.getElementById("summary").value.length > 30)

		{
			document.getElementById('error_message').innerHTML ="Summary allows Minimum 3 characters and maximum 30 characters only";
			return false;
		}


		var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
		for (var i = 0; i < document.getElementById("summary").value.length; i++)
		{
	  	if (iChars.indexOf(document.getElementById("summary").value.charAt(i)) != -1)
		{
	  	document.getElementById('error_message').innerHTML ="Summary has special characters. \n Please remove them and try again.";
	  	return false;
	  	}
	 	}

		// Details

		var oEditor = FCKeditorAPI.GetInstance('details') ;
		var oDOM = oEditor.EditorDocument ;
		var iLength ;

		if (document.all )
		{
		iLength = oDOM.body.innerText.length ;
		}
		else
		{
		var r = oDOM.createRange() ;
		r.selectNodeContents( oDOM.body ) ;
		iLength = r.toString().length ;
		}

		if(iLength > 10000)
		{
		document.getElementById('error_message').innerHTML = "Actual Summary Exceeds : " + iLength + "characters";
		return false;
		}
			if(iLength < 10)
			{
			document.getElementById('error_message').innerHTML = "Details  Should be maximum 10 characters long";
			return false;
			}

			var PART2 = oEditor.GetXHTML(true);
			if(!PART2)
			{
				alert("Please Enter Details");
				return false;
			}

		}


// Mail Validations


		function mail_validate()
		{
			if(document.getElementById("subject").value=="")
			{
				document.getElementById('error_message').innerHTML = "Enter subject Name";
				return false;
			}

			if(document.getElementById("subject").value.length < 3 || document.getElementById("subject").value.length > 30)
			{
				document.getElementById('error_message').innerHTML = "Subject allows Minimum 3 characters and maximum 30 characters only";
				return false;
			}


			var oEditor = FCKeditorAPI.GetInstance('details') ;
			var oDOM = oEditor.EditorDocument ;
			var iLength ;

			if (document.all )
			{
			iLength = oDOM.body.innerText.length ;
			}
			else
			{
			var r = oDOM.createRange() ;
			r.selectNodeContents( oDOM.body ) ;
			iLength = r.toString().length ;
			}

			if(iLength > 10000)
			{
			document.getElementById('error_message').innerHTML = "Actual Message Exceeds : " + iLength + "characters";
			return false;
			}

			if(iLength < 10)
			{
			document.getElementById('error_message').innerHTML = "Message to be entered and should be maximum 10 characters long";
			return false;
			}

			var PART2 = oEditor.GetXHTML(true);
			if(!PART2)
			{
				alert("Please Enter Message");
				return false;
			}

		}



// Community Validations



		function mail_validate()
		{
			if(document.getElementById("subject").value=="")
			{
				document.getElementById('error_message').innerHTML = "Enter subject Name";
				return false;
			}

			if(document.getElementById("subject").value.length < 3 || document.getElementById("subject").value.length > 30)
			{
				document.getElementById('error_message').innerHTML = "Subject allows Minimum 3 characters and maximum 30 characters only";
				return false;
			}
		}


///////////////////////////////////////////////////////// MY Page Validations Ends ////////////////////////////////////////////////////////////////

// Common Validate

///////////////Update news validation//////////////
function validate_news_update(){

if(trim(document.getElementById("summary").value)=='')
{
alert("Please Enter News Headlines");
return false;
}else if(document.getElementById("summary").value.length < 3 || document.getElementById("summary").value.length >255)
{

alert("News Headlines allows Minimum 3 characters and maximum 255 characters only");
return false;
}
if(document.getElementById("news_date").value=='')
{
alert("Please Enter News Date");
return false;

}
if(document.getElementById("loc1").checked==true)
{
var oEditor = FCKeditorAPI.GetInstance('details') ;

// Get the Editor Area DOM (Document object).
var oDOM = oEditor.EditorDocument ;

var iLength ;

// The are two diffent ways to get the text (without HTML markups).
// It is browser specific.

if ( document.all ) // If Internet Explorer.
{
iLength = oDOM.body.innerText.length ;
}
else // If Gecko.
{
var r = oDOM.createRange() ;
r.selectNodeContents( oDOM.body ) ;
iLength = r.toString().length ;
}
if(iLength > 10000)
{
alert( 'Actual News  Exceeds : ' + iLength + 'characters' ) ;
return false;
}
if(iLength < 10)
{
alert('News  Should be maximum 10 characters long');
return false;
}
var PART2 = oEditor.GetXHTML(true);
if(!PART2){
alert("Please Enter Summary For News");
return false;
}
}
else
{
if(trim(document.getElementById("url").value)=='')
{
alert("Please Enter Remote Url for News");
return false;
}
}
if(document.getElementById("newsFlag").value != "ok"){
alert("Please choose current or future date");
return false;
}

}
//////////////////Ends//////////////////////////////////////
////////////Local or Remote show script/////
function option_show()
{
       var tr = document.getElementById("trremot");
       tr.style.display = "none";
}
function option_hide()
{
       var tr = document.getElementById("trremot");
       tr.style.display = "";
}


function tr_show()
{
	var tr = document.getElementById("trremot");
   	var tr1 = document.getElementById("trlocal");
	tr.style.display = "none";
	tr1.style.display = "";
}
function tr_hide()
{
   	var tr = document.getElementById("trremot");
    	var tr1 = document.getElementById("trlocal");
	tr.style.display = "";
	tr1.style.display = "none";
}
function tr_hide_both()
{
   	var tr = document.getElementById("trremot");
    	var tr1 = document.getElementById("trlocal");
	tr.style.display = "none";
	tr1.style.display = "none";
}
function tr_options(type)
{
	if(type == 'logo'){
		document.getElementById('loc2').checked = true;
		display = 'none';	browse = 'block';		}
	else{			display = 'block';	browse = 'none';	}
	var tr = document.getElementById("trremot");
	var tr1 = document.getElementById("trlocal");
        var tr2 = document.getElementById("troptions");
        var tr3 = document.getElementById("trbrowse");
	if(display == 'block') {
		if(document.getElementById('loc2').checked){ showremote = '';	showlocal = 'none' }
		else{ showremote = 'none';	showlocal = '';	}
	}else{
		showremote = '';	showlocal = 'none';
	}
	tr.style.display = showremote;
        tr1.style.display = showlocal;
	tr2.style.display = display;
	tr3.style.display = browse;
}

////////////Local or remote show script ends////

/////////////////////////////////////////FOR TOOL TIP/////////////////////////////////

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip
/////////////////////////////////////////////////////FOR TOOL TIP ENDS////////////////////////////////////////

/////////////////////////////////////////Validate Release////////////////////////////////
function validate_release(options) {

 var checklocation = options;

                if(trim(document.getElementById("relname").value)=='')
                {
                alert("Please Enter Release Name");
                return false;
                }else if(document.getElementById("relname").value.length > 30 || document.getElementById("relname").value.length < 3)
                {

                alert("Release Name must be 3 character long and Maximum 30 characters are allowed");
                return false;
                }

                if(document.getElementById("desc").value=='')
                {
                alert("Please Enter Release Description");
                return false;
                }else if(document.getElementById("desc").value.length < 10 || document.getElementById("desc").value.length > 1024)
                {
                alert("Release description must be 10 characters long and maximum 1024 characters are allowed");
                return false;
                }
                if(document.getElementById("is_loc1").checked==true || checklocation == 2)
                {

                if(trim(document.getElementById("url").value)=='')
                {
                alert("Please Enter Remote Url");
                return false;
                }
                else
                {
                url = document.getElementById("url").value;
                var RegExp = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;
                if(!RegExp.test(url))
                {
                  alert("Error: The URL entered is invalid");
                  return false;
                }
                }

                }if(document.getElementById("stat").value=='0')
                {
                alert("Please Select Hidden / visible");
                return false;
                }

		}



function validate_file(options)
{
  var step = options;
 if(step == 1)
 {

    if(document.getElementById("remote").checked==true)
    {
        if(trim(document.getElementById("filess").value)=='')
        {

            alert("Please enter a file name");
            return false;

        }
        if(trim(document.getElementById("url").value)=='')
        {
            alert("Please enter a remote URL");
            return false;
        }
         else
        {
               url = document.getElementById("url").value;
               var RegExp = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;
               if(!RegExp.test(url))
               {
                  alert("Error: The URL entered is invalid");
                  return false;
               }
        }

   }
   else if(document.getElementById("local").checked==true)
   {
       if(document.getElementById("files").value=='')
       {
           alert("Please choose a file to upload");
           return false;
       }
   }
 }
 else if(step == 2 )
 {
var checklocation = document.getElementById("checklocation").value;
    if(checklocation == 'remote')
    {
        if(trim(document.getElementById("filess").value)=='')
        {

            alert("Please enter a file name");
            return false;

        }
        if(trim(document.getElementById("url").value)=='')
        {
            alert("Please enter a remote URL");
            return false;
        }
        else
        {
               url = document.getElementById("url").value;
               var RegExp = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;
               if(!RegExp.test(url))
               {
                  alert("Error: The URL entered is invalid");
                  return false;
               }
        }

    }

 }
       if(document.getElementById("desc").value=='')
       {
          alert("Please enter the file description");
          return false;
       }
      else if(document.getElementById("desc").value.length < 10 || document.getElementById("desc").value.length > 1024)
      {
          alert("The file description must be a minimum of 10 characters and maximum of 1024 characters");
          return false;
      }

      if(document.getElementById("type_id").value=='100')
      {
          alert("Please select a  file type");
          return false;
      }
      if(document.getElementById("selects").value=='100')
      {
	 alert("Please select a processor type");
         return false;
      } 

}

function validate_package(options)

                {
                var checklocation = options;
                if(trim(document.getElementById("packname").value)=='')
                {
                alert("Please Enter Package Name");
                return false;
                }else if(document.getElementById("packname").value.length > 30 || document.getElementById("packname").value.length < 3)
                {
                alert("Package Name must be 3 character long and Maximum 30 characters are allowed");
                return false;
                }
                if(document.getElementById("desc").value=='')
                {
                alert("Please Enter Package Description");
                return false;
                }else if(document.getElementById("desc").value.length < 10 || document.getElementById("desc").value.length > 1024)
                {
                alert("Package description must be 10 characters long and maximum 1024 characters are allowed");
                return false;
                }

                if(document.getElementById("is_loc1").checked==true || checklocation == 2)
                {

                if(trim(document.getElementById("url").value)=='')
                {
                alert("Please Enter Remote Url");
                return false;
                }
               else
               {
                   url = document.getElementById("url").value;
                   var RegExp = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;
                   if(!RegExp.test(url))
                   {
                      alert("Error: The URL entered is invalid");
                      return false;
                   }
               }

               }
        }

/******************************** DOCUMENT VALIDATION***************************************/
function validate_docfolder() {

		if(trim(document.getElementById("foldername").value)=='')
		{
		alert("Please Enter Folder Name");
		return false;
		}else if(document.getElementById("foldername").value.length > 30 || document.getElementById("foldername").value.length < 3)
		{

		alert("Folder Name must be 3 character long and Maximum 30 characters are allowed");
		return false;
		}


		if(trim(document.getElementById("description").value)=='')
		{
		alert("Please Enter Folder Description");
		return false;
		}else if(document.getElementById("description").value.length < 10 || document.getElementById("description").value.length > 300)
		{
		alert("Folder description must be 10 characters long and maximum 300 characters are allowed");
		return false;
		}

		if(document.getElementById("remote").checked==true)
		{

		if(trim(document.getElementById("remoteurl").value)=='')
		{
		alert("Please Enter Remote Location");
		return false;
		}
		}

	        }
/*********************************ENDS******************************************************/


/*****************************************DOCUMENT FILES****************************************/
function validate_notes(){
	if(trim(document.getElementById("titles").value)=='')
	{
	alert("Please Enter Document Name");
	return false;
	}else if(document.getElementById("titles").value.length < 3 || document.getElementById("titles").value.length > 30)
	{

	alert("Document Name allows Minimum 3 characters and maximum 30 characters only");
	return false;
	}
	if(document.getElementById("description").value=='')
	{
	alert("Please Enter News Date");
	return false;

	}

var oEditor = FCKeditorAPI.GetInstance('note_content') ;

// Get the Editor Area DOM (Document object).
var oDOM = oEditor.EditorDocument ;

var iLength ;

// The are two diffent ways to get the text (without HTML markups).
// It is browser specific.

if ( document.all ) // If Internet Explorer.
{
iLength = oDOM.body.innerText.length ;
}
else // If Gecko.
{
var r = oDOM.createRange() ;
r.selectNodeContents( oDOM.body ) ;
iLength = r.toString().length ;
}
if(iLength > 10000)
{
alert( 'Actual News  Exceeds : ' + iLength + 'characters' ) ;
return false;
}
if(iLength < 10)
{
alert('Notes  Should be maximum 10 characters long');
return false;
}
var PART2 = oEditor.GetXHTML(true);
if(!PART2){
alert("Please Enter Notes For Document");
return false;
}
}
/************************************ENDS*************************************************************/

/***********************************LINK validation function**********************************/
function validate_link() {

		if(trim(document.getElementById("titles").value)=='')
		{
		alert("Please Enter Document Name");
		return false;
		}else if(document.getElementById("titles").value.length > 30 || document.getElementById("titles").value.length < 3)
		{

		alert("Document Name must be 3 character long and Maximum 30 characters are allowed");
		return false;
		}


		if(trim(document.getElementById("description").value)=='')
		{
		alert("Please Enter Document Description");
		return false;
		}else if(document.getElementById("description").value.length < 10 || document.getElementById("description").value.length > 300)
		{
		alert("Document description must be 10 characters long and maximum 300 characters are allowed");
		return false;
		}


		if(trim(document.getElementById("userfile").value)=='')
		{
		alert("Please Enter Link URL");
		return false;
		}

	        }
/*************************************************************************************************/


/* Category and Subcategory Display Start  */

function getCat1(strURL) {

		var req = getXMLHTTP();

		if (req) {

			req.onreadystatechange = function() {
				if (req.readyState == 4) {

					if (req.status == 200) {

						document.getElementById('sub1').innerHTML=req.responseText;


					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
		}

	}
	function getCat2(strURL) {

		var req = getXMLHTTP();

		if (req) {

			req.onreadystatechange = function() {
				if (req.readyState == 4) {

					if (req.status == 200) {

						document.getElementById('sub2').innerHTML=req.responseText;


					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
		}

	}

function getCat3(strURL) {

		var req = getXMLHTTP();

		if (req) {

			req.onreadystatechange = function() {
				if (req.readyState == 4) {

					if (req.status == 200) {

						document.getElementById('sub3').innerHTML=req.responseText;


					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
		}

	}
/* Project Visibiility Display */
function getProj_Type(strURL) {


		var req = getXMLHTTP();

		if (req) {

			req.onreadystatechange = function() {
				if (req.readyState == 4) {

					// only if "OK"
					if (req.status == 200) {

						document.getElementById('p_visible').innerHTML=req.responseText;



					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
		}

	}

/* Category and Subcategory Display End*/

/* Template Visibiility Display  Start*/
function confirm_delete()
{
input_box=confirm("Click OK to confirm or Cancel");
if (input_box==true)

{
// Output when OK is clicked
return true;
}

else
{
// Output when Cancel is clicked
return false;
}
}
function getTmp_Type(strURL) {


		var req = getXMLHTTP();

		if (req) {

			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {

						document.getElementById('tmp_visible').innerHTML=req.responseText;


					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
		}

	}

/* Template Visibiility Display  End */


/* Project Logo Fille show  button*/

function showImage() {

img1.style.display ="block";
}
function showPhoto1() {
img1.style.display = "block";
}

function showPhoto2() {
img2.style.display = "block";
}

/* Project Logo Fille show  button*/



/******Project Introduction and Description text validation***********/

function ismaxlength(obj,head){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)

}
/******Project Introduction and Description text validation***********/

/*swap images script by yaaman*/
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function sourceRedirect(Theform){
var flag=0;
	for (i=0; i<Theform.elements.length; i++){
		if (Theform.elements[i].type=="radio"){

			if(Theform.elements[i].checked==true){
				window.location = Theform.elements[i].value;
				flag=1;
				break;
			}
		}

	}
	if(flag==0){
		document.getElementById('error_message').innerHTML ="Please select a File";
	}

}
/*********************************************************REGISTRATION VALIDATION******************************/

function register_validation() {

if(trim(document.getElementById("firstname").value)==''){
alert("Enter Your First Name");
return false;
}
if(trim(document.getElementById("lastname").value)==''){
alert("Enter Your Last Name");
return false;
}
if(trim(document.getElementById("username").value)==''){
alert("Enter Your Username");
return false;
}
if(trim(document.getElementById("email").value)==''){
alert("Enter Your Email ID");
return false;
}
var email=document.getElementById("email").value;
$emailvalid =/^([0-9a-z]+)([-._a-z0-9]+)@([-._a-z0-9]+)(\.[a-z]{2,3}$)/;
if($emailvalid.test(email) != true){
alert("Email address appears to be invalid");
return false;
}

var pass=document.getElementById("password").value;
var pass1=document.getElementById("password1").value;
if(pass==''){
alert("Enter Your Password");
return false;
}

if(pass1==''){
alert("Retype Your Password");
return false;
}
if(pass!=pass1){
alert("Password and Retype password does not match");
return false;
}
if(document.getElementById("city").value==''){
alert("Enter Your City");
return false;
}


var s=s_gi('jscjasperforge');
s.linkTrackVars='eVar2,events';
s.linkTrackEvents='event1';
s.events='event1';
s.eVar2='User Registration Complete';
s.tl(this,'o','User Registration Complete');
}

var xmlHttp

function available()
{
var str =document.getElementById("username").value;

if (str.length==0)
  {
  document.getElementById("result").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="availableusername.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("result").innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;

}



/* get monitor button for forum topics*/

function getMonitor(strURL) {


		var req = getXMLHTTP();

		if (req) {

			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {

						document.getElementById('monitdiv').innerHTML=req.responseText;


					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
		}



	}

/* project home custom content */
function customvalidate() {

	var d=document.customcontent;


          if(d.titlecus.value=="")
          {
                alert('Please enter section title !');
                d.titlecus.focus();
                return false;
          }
          if(d.homecontent.value=="")
          {
                alert('Please enter home content !');
                d.homecontent.focus();
                return false;
          }
          if(d.homecontent.value.length>500)
          {
                alert('Home text content too large !');
                d.homecontent.focus();
                return false;
          }


        return true;
}
function  commentvalcheck() {

        var oEditor = FCKeditorAPI.GetInstance('cmtvalue') ;

        var oDOM = oEditor.EditorDocument ;

        var iLength ;

        if ( document.all ) {

             iLength = oDOM.body.innerText.length ;

         } else {

             var r = oDOM.createRange() ;

             r.selectNodeContents( oDOM.body ) ;

             iLength = r.toString().length ;

         }

        if(iLength > 5000) {

             alert( 'Actual Comment  Exceeds : ' + iLength + 'characters' ) ;

             return false;

        }

        if(iLength < 1) {

             alert('Please Enter Valid Comment');

             return false;

        }

        var PART2 = oEditor.GetXHTML(true);

        if(!PART2){

             alert('Please Enter Comment');

             return false;

         }

          return true;
 }



function limitlength(obj, length){

var maxlength=length

if (obj.value.length>maxlength)

obj.value=obj.value.substring(0, maxlength)

}
function  validatepstfck() {
        var d=document.addnewpst;
        var oEditor = FCKeditorAPI.GetInstance('pcontent') ;

        var oDOM = oEditor.EditorDocument ;

        var iLength ;
	if(d.ptitle.value=="") {

                alert('Please enter post title !');
                d.ptitle.focus();
                return false;
          }
	if(d.selectcat.value=="") {

                alert('You must select a category to publish.!');
                d.selectcat.focus();
                return false;
          }

        if ( document.all ) {

             iLength = oDOM.body.innerText.length ;

         } else {

             var r = oDOM.createRange() ;

             r.selectNodeContents( oDOM.body ) ;

             iLength = r.toString().length ;

         }

        if(iLength > 5000) {

             alert( 'Actual Post  Exceeds : ' + iLength + 'characters' ) ;

             return false;

        }

        if(iLength < 1) {

             alert('Please Enter Valid Post');

             return false;

        }

        var PART2 = oEditor.GetXHTML(true);

        if(!PART2){

             alert('Please Enter Post');

             return false;

         }

          return true;
 }
function analytics_valid()
{
	if(document.getElementById('codename').value==''){
	document.getElementById('error_message').innerHTML ="Please enter a codename";
	return false;
	}else if(document.getElementById('codename').value.length<3 || document.getElementById('codename').value.length>25 ){document.getElementById('error_message').innerHTML ="Please enter a codename greater than 3 ";return false;}
	if(document.getElementById('content').value==''){
	document.getElementById('error_message').innerHTML ="Please enter a content";
	return false;
	}
}

function attachmentLink(slink)
{
  document.getElementById('attachLink').href=slink;
}
function forum_valid()
{
	if(document.getElementById('forum_name').value==''){
		document.getElementById('error_message').innerHTML ="Please enter a forumname";
	return false;
	}else if(trim(document.getElementById('forum_name').value)=='')
	{
		document.getElementById('error_message').innerHTML ="Please enter a forumname";
	return false;
	}else if(document.getElementById('forum_name').value<5)
	{
		document.getElementById('error_message').innerHTML ="Please enter a forumname greater than five";
	return false;
	}
	var ret=forum_special_char_check(document.getElementById('forum_name').value);
	if(ret!=0)
	{
		document.getElementById('error_message').innerHTML ="Special characters are not allowed.Please remove it and try again";
	return false;

	}
if(document.getElementById('forum_desc').value==''){
		document.getElementById('error_message').innerHTML ="Please enter a description";
	return false;
	}else if(trim(document.getElementById('forum_desc').value)=='')
	{
		document.getElementById('error_message').innerHTML ="Please enter a description";
	return false;
	}
	ret=forum_special_char_check(document.getElementById('forum_desc').value);
	if(ret==1)
	{
		document.getElementById('error_message').innerHTML ="Special characters are not allowed.Please remove it and try again";
	return false;

	}
	}

function tracker_changelink(slink)
{
	document.getElementById("editlink").href=slink+'&action=3';
	document.getElementById("dellink").href=slink+'&action=5';
	document.getElementById("viewlink").href=slink;

}
function scm_changelink(scmlink,tarlink,option)
{
	if(option==1)
	{
		document.getElementById("viewcommits").href=scmlink;
	}else{
	document.getElementById("edit_scm").href=tarlink+'&edit_scm=y';
	document.getElementById("del_scm").href=tarlink+'&del_scm=y';
	document.getElementById("viewcommits").href=scmlink;
	}

}
function scm_harshcheck(actionlist)
{
	var myRegExp = '#';
	var string1 = document.getElementById(actionlist).href;
	var matchPos1 = string1.search(myRegExp);

	if(matchPos1!=-1){
		document.getElementById('error_message').innerHTML = "Select a repository ";
	}else {
		window.location = string1;
	}

}
function disable_all(){
document.getElementById("linkon").disabled=true;
document.getElementById("linkoff").disabled=true;
document.getElementById("link").disabled=true;
document.getElementById("linktooltab").className="toolsyesrono"
document.getElementById("linktabto").className="toolsyesrono"
}
function enable_all(){
document.getElementById("linktooltab").className="toolsonrooff"
document.getElementById("linkon").disabled=false;
document.getElementById("linkoff").disabled=false;
document.getElementById("link").disabled=true;
}
function disable_link(){

document.getElementById("link").disabled=true;
document.getElementById("linktooltab").className="toolsonrooff"
document.getElementById("linktabto").className="toolsyesrono"
}
function enable_link() {
document.getElementById("link").disabled=false;
document.getElementById("linktooltab").className="toolsonrooff"
document.getElementById("linktabto").className="toolsonrooff"
}
function forum_special_char_check(str)
{
	var iChars = "!@#$%^&*()+=-[]\\\';/{}|\":<>?";
	var flag=0;
	for (var i = 0; i < str.length; i++) {
  	if (iChars.indexOf(str.charAt(i)) != -1) {

  	flag=1;
  	}
  }
	return flag;
}
function scm_publish(link,revs,age,auth)
{
	document.getElementById("pub_scm").href='/scm/publish.php?pub='+link+'&rev='+revs+'&age='+age+'&auth='+auth;
}

function search_validate() {
var search1=document.getElementById("word").value;
var cc=document.getElementById("word").value.length;
if(search1=='') {
document.getElementById('error_message_side').innerHTML = "Enter Your Search Words<br>";
return false;
}
if(cc < 3) {
document.getElementById('error_message_side').innerHTML = "Search must be at least three characters<br>";
return false;
}
/*var datefrom=document.getElementById("datefrom").value;
var dateto=document.getElementById("dateto").value;

if(datefrom!='' || dateto!=''){

if(datefrom==''){
document.getElementById('error_message_side').innerHTML = "Enter From Date to search<br>";
return false;
}
if(dateto==''){
document.getElementById('error_message_side').innerHTML = "Enter To Date to search<br>";
return false;
}


}*/
}

function search_validate_home() {
var search1=document.getElementById("word").value;
var cc=document.getElementById("word").value.length;
if(search1=='') {
document.getElementById('error_message_side').innerHTML = "Enter Your Search Words<br>";
return false;
}
if(cc < 3) {
document.getElementById('error_message_side').innerHTML = "Search must be at least three characters<br>";
return false;
}
if(document.getElementById("searchtype").value==1) {
document.getElementById('error_message_side').innerHTML = "Select Search Scope<br>";
return false;
}

}

function docsvalidate(){
if(document.getElementById('docname').value==''){
		document.getElementById('error_message').innerHTML ="Please enter a Document Name";
	return false;
	}
if(document.getElementById('userfile').value==''){
		document.getElementById('error_message').innerHTML ="Please Upload a valid File";
	return false;
	}
if(document.getElementById('description').value==''){
		document.getElementById('error_message').innerHTML ="Please enter a Description";
	return false;
	}

}
function scm_publishcheck(actionlist)
{
	var myRegExp = '#';
	var string1 = document.getElementById(actionlist).href;
	var matchPos1 = string1.search(myRegExp);
	if(matchPos1!=-1){
		document.getElementById('error_message').innerHTML = "Select a Folder to publish ";
	return false;
	}
	window.location.href=string1;

}

function tracker_validate()
{

   var ret=forum_special_char_check(document.getElementById('tracker_name').value);
	if(ret!=0)
	{
		document.getElementById('error_message').innerHTML ="Special characters are not allowed.Please remove it and try again";
	return false;

	}
	}

function textLimit(field,maxlen) {
 if(field.value.length > maxlen){
 while(field.value.length > maxlen){
 field.value=field.value.replace(/.$/,'');
 }
 alert('Quote exceeds more than 210 characters');
 }
}

function feedback_validate()
{
	if(document.feedback.fid2623.value=="")
		{
		alert("Enter First Name");
		document.feedback.fid2623.focus();
		return false;
		}
	if(document.feedback.fid262.value=="")
		{
		alert("Enter Last Name");
		document.feedback.fid262.focus();
		return false;
		}

	var email=document.feedback.fid26222.value;
	$emailvalid =/^([0-9a-z]+)([-._a-z0-9]+)@([-._a-z0-9]+)(\.[a-z]{2,3}$)/;
	if($emailvalid.test(email) != true){
	alert("Email address appears to be invalid");
	return false;
	}

	if(document.feedback.fid2622222.value=="")
		{
		alert("Enter Area of JasperForge ");
		document.feedback.fid2622222.focus();
		return false;
		}
	if(document.feedback.textarea.value=="")
		{
		alert("Enter issue to report");
		document.feedback.textarea.focus();
		return false;
		}
        if(document.feedback.fid262222242.value=="")
		{
		alert("Enter the text shown in image");
		document.feedback.fid262222242.focus();
		return false;
        	}
}

function textarea_show(texid)
{
	document.getElementById(texid).style.display="block";
}
function textarea_hide(texid)
{
	document.getElementById(texid).style.display="none";
}

function beforefrm_search()
{
var str_words;
var str_user;
str_words=document.getElementById('words').value;
str_user = document.getElementById('uname').value;
str_words=trim(str_words);
str_words=ltrim(str_words);
str_words=rtrim(str_words);
str_user=trim(str_user);
str_user=ltrim(str_user);
str_user=rtrim(str_user);
if(str_words=='' && str_user=='')
{
      document.getElementById('error_message').innerHTML="Enter Key word for Search";
      return false;

}else if(str_words!='') {
              var str=str_words;
              var iChars = "()[]\\\'\"";
              for (var i = 0; i < str.length; i++) {
              if (iChars.indexOf(str.charAt(i)) != -1) {
              document.getElementById('error_message').innerHTML="special characters are not allowed";
              return false;
                                                        }
                                                      }

}else if(str_user!='') {
              var str=str_user;
              var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
              for (var i = 0; i < str.length; i++) {
              if (iChars.indexOf(str.charAt(i)) != -1) {
              document.getElementById('error_message').innerHTML="special characters are not allowed";
              return false;
                                                        }
                                                      }

      }



}

function account_validation() {

if(trim(document.getElementById("firstname").value)==''){
alert("Enter Your First Name");
return false;
}
if(trim(document.getElementById("lastname").value)==''){
alert("Enter Your Last Name");
return false;
}

if(document.getElementById("city").value==''){
alert("Enter Your City");
return false;
}
if(document.getElementById("ccode").value=='BL'){
alert("Country should not be blank");
return false;
}
if(document.getElementById("stateSelect").value==''){
alert("Enter your state");
return false;
}

var s=s_gi('jscjasperforge');
s.linkTrackVars='eVar2,events';
s.linkTrackEvents='event1';
s.events='event1';
s.eVar2='User Registration Complete';
s.tl(this,'o','User Registration Complete');
}

////Add new about tab validation script//
function validate_addabout(section){
	switch (section) {
		case 1:
			section = ' About ';
			break;
		case 2:
			section = ' Footer ';
			break;
        }
	if(trim(document.getElementById("summary").value)=='')
	{
		document.getElementById('error_message').innerHTML = "Please Enter Page Title";
		return false;
	}else if(document.getElementById("summary").value.length < 3 || document.getElementById("summary").value.length > 20)
	{
		document.getElementById('error_message').innerHTML = "Title allows Minimum 3 characters and maximum 20 characters only";
		return false;
	}
	if(document.getElementById("loc1").checked==true)
	{
		var oEditor = FCKeditorAPI.GetInstance('details') ;
		// Get the Editor Area DOM (Document object).
		var oDOM = oEditor.EditorDocument ;
		var iLength ;

		// The are two diffent ways to get the text (without HTML markups).
		// It is browser specific.
		if ( document.all ) // If Internet Explorer.
		{
			iLength = oDOM.body.innerText.length ;
		}else // If Gecko.
		{
			var r = oDOM.createRange() ;
			r.selectNodeContents( oDOM.body ) ;
			iLength = r.toString().length ;
		}
		if(iLength > 100000)
		{
			document.getElementById('error_message').innerHTML = 'Content Should be maximum 10000 characters long which Exceeds : ' + iLength + 'characters';
			return false;
		}
		if(iLength < 10)
		{
			document.getElementById('error_message').innerHTML = 'Content  Should be minimum 10 characters long';
			return false;
		}
		var PART2 = oEditor.GetXHTML(true);
		if(!PART2){
			document.getElementById('error_message').innerHTML = "Please Enter Summary For News";
			return false;
		}
	}else
	{
		if(trim(document.getElementById("url").value)=='')
		{
			document.getElementById('error_message').innerHTML = "Please Enter Remote Url for "+ section +" item";
			return false;
		}
	}
}

function CheckProjectName(strURL) {
var pname = document.getElementById('project_name_id').value;
var sname = document.getElementById('short_name_id').value;
strURL = strURL+'?projectname='+pname+'&shortname='+sname;
	var req = getXMLHTTP();
	if (req) {
		req.onreadystatechange = function() {
		if (req.readyState == 4) {
			if (req.status == 200) {
				document.getElementById('project_error').innerHTML=req.responseText;
			} else {
				alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}
		}
		req.open("GET", strURL, true);
		req.send(null);
	}

}
function getCity(strURL) {

		var req = getXMLHTTP();

		if (req) {

			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						document.getElementById('citydiv').innerHTML=req.responseText;
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
		}

	}


function showModuleVersions(moduleId) {
	var req = getXMLHTTP();
	var url = "listVersion.php?cr_moduleId="+moduleId;
	if (req) {
		req.onreadystatechange = function() {
		if (req.readyState == 4) {
			if (req.status == 200) {
				document.getElementById('showModuleVersionsDiv').innerHTML=req.responseText;

			} else {
				alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}
		}
		req.open("GET", url, true);
		req.send(null);
	}

}



function sumitAssociateModule(){
document.associateForm.action="associateModule.php";
document.associateForm.submit();
}

function showAddCommentsBox(){
	document.getElementById('show_hide_news_form_div').style.display = 'block';
}

function hideAddCommentsBox(){
	document.getElementById('show_hide_news_form_div').style.display = 'none';
}



function deleteNewsComments(action,commentId) {
	var req = getXMLHTTP();
	document.getElementById("showPreviewDiv").style.display="none";
    if (confirm("Are you sure you want to delete this comment?")) {
       var url = "do_news_commets_ajaxactions.php?comment_id="+commentId+"&action="+action;
			if (req) {
				req.onreadystatechange = function() {
				if (req.readyState == 4) {
					if (req.status == 200) {
						document.getElementById('showCommentsDiv').innerHTML=req.responseText;
						return true;
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
						}
					}
				}
				req.open("GET", url, true);
				req.send(null);
			}

    } else {
       return false;
    }
}

function moderateNews(id){
	var req = getXMLHTTP();
	var url = "/plugins/espnews/moderateNews.php?id="+id;
	if (req) {
		req.onreadystatechange = function() {
		if (req.readyState == 4) {
			if (req.status == 200) {
				document.getElementById('div_id_'+id).innerHTML=req.responseText;
				return true;
			} else {
				alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}
		}
		req.open("GET", url, true);
		req.send(null);
	}
}

//////////Ends/////////////////


function checkprojectype(input,arrayData)
{
for (i=0; i<arrayData.length; i++)
    {

   	if (arrayData[i] == input)
	{
        	document.getElementById("projecttype").checked = true;
		document.getElementById("priv").innerHTML='<input type="hidden" name="private" value="checkbox">';
	        document.getElementById("projecttype").disabled = false;
   	}
   	else
   	{
       		document.getElementById("projecttype").disabled = false;
   	}

    }
}


function previewComments(){
	var commentsText = nicEditors.findEditor('commentsText').getContent();//document.addCommentsForm.comment.value;
 	if(commentsText == '' || commentsText == '<br>'){
		alert("Comments should not be empty");
		return false;
	}
		document.getElementById("showPreviewDiv").style.display="block";
		document.getElementById("showPreviewCommentsDisplayDiv").innerHTML=commentsText;
}
function hideCommentPreview(){
		document.getElementById("showPreviewDiv").style.display="none";
}

function previewEditComments(id){
	var commentsText = nicEditors.findEditor('editedCommentsText').getContent();//document.addCommentsForm.comment.value;
	 	if(commentsText == '' || commentsText == '<br>'){
		alert("Comments should not be empty");
		return false;
	}
		document.getElementById("showEditPreviewDiv_"+id).style.display="block";
		document.getElementById("showEditPreviewCommentsDisplayDiv_"+id).innerHTML=commentsText;
}
function hideEditCommentPreview(id){
		document.getElementById("showEditPreviewDiv_"+id).style.display="none";
}

function checkCommentsEmpty(){
	document.getElementById("showPreviewDiv").style.display="none";
 	var commentsText = nicEditors.findEditor('commentsText').getContent();//document.addCommentsForm.comment.value;
 	if(commentsText == '' || commentsText == '<br>'){
		alert("Comments should not be empty");
		return false;
	}

}

function checkEditCommentsEmpty(){
	document.getElementById("showPreviewDiv").style.display="none";
 	var commentsText = nicEditors.findEditor('editedCommentsText').getContent();//document.addCommentsForm.comment.value;
 	if(commentsText == '' || commentsText == '<br>'){
		alert("Comments should not be empty");
		return false;
	}

}

function checkUserCount(count){
	for(i=1;i<=count;i++){
		if(document.getElementById('opt'+i).checked==true){
			if(document.getElementById('rolecount'+i).value > 0){
				if(confirm('This role contains some users!, Do you want to continue?')){
					return true;
				}else	return false;
			}
		}
	}
}

function availableUser()
{
var str =document.getElementById("user_name").value;

if (str.length==0)
  {
  document.getElementById("result").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="../account/availableusername.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function checkNullValue(val)
{
var searchstr = document.getElementById(val).value;

if(searchstr == "" || searchstr == "Search")
  {
    return false;
  }
else
  {
    return true;
  }
}

function checkNullValueFordiffs(last,first)
{
  if(document.getElementById('r1'))
  {
   var diff1 = document.getElementById('r1').value;
   var diff2 = document.getElementById('r2').value;
   
   if((diff1!="") && (diff2!=""))
   {
   if(diff1>last || diff1<first){
     alert('The Revision you have entered is not valid. Please specify a valid Revision to proceed.');
     return false;
   }
   if(diff2>last || diff2<first){
     alert('The Revision you have entered is not valid. Please specify a valid Revision to proceed.');
     return false;
   }

     return true;
   }
   else{
     alert('Please specify a valid Revision to execute the diff command.');
     return false;
   }
  }

  if(document.getElementById('tr1')){
    var diff1 = document.getElementById('tr1').value;
    var diff2 = document.getElementById('tr2').value;
    if((diff1!="") && (diff2!=""))
    {
      if(diff1>last || diff1<first){
        alert('The Revision you have entered is not valid. Please specify a valid Revision to proceed.');
        return false;
      }

      if(diff2>last || diff2<first){
        alert('The Revision you have entered is not valid. Please specify a valid Revision to proceed.');
        return false;
      }

      return true;
    }
    else{
      alert('Please specify a valid Revision to execute the diff command.');
      return false;
    }
  }
}

function checkReportStats(){
var from_date = document.getElementById('stats_date_from').value;
var to_date = document.getElementById('stats_date_to').value;
var current_date = document.getElementById('currentDate').value;
var fr=compareDatesForStats(from_date,current_date,0);
var to=compareDatesForStats(to_date,current_date,0);
var ft=compareDatesForStats(from_date,to_date,1);
if(fr==false || to==false || ft ==false)
{
    alert('Please choose a date prior to '+current_date);
    return false;
}

if(from_date == ''){
        alert("Please choose the from date");
        return false;
}
if(to_date == ''){
        alert("Please choose the to date");
        return false;
}


return true;
}


function compareDatesForStats(compDate,curDate,cp){
var splitCompDate = new Array();
var splitCurDate = new Array();
var cp =cp;
splitCompDate = compDate.split('-');
splitCurDate = curDate.split('-');
        if(splitCompDate[0]<splitCurDate[0]){
                return true;
        }else if(splitCompDate[0] == splitCurDate[0]){
                        if(splitCompDate[1]<splitCurDate[1]){
                                return true;
                        }else if(splitCompDate[1] == splitCurDate[1]){
                                                if(splitCompDate[2]<splitCurDate[2]){
                                                return true;
                                                }else if(cp==1)
                                                {
                                                    if(splitCompDate[2] == splitCurDate[2])
                                                    {
                                                    return true;
                                                    }

                                                }
                                                else {
                                                        return false;
                                                }
                        }else{
                                return false;
                        }
        }else{
                return false;
        }


}
function checkNullValue(val)
{
var searchstr = document.getElementById(val).value;

if(searchstr == "" || searchstr == "Search")
  {
    return false;
  }
else
  {
    return true;
  }
}

function downloadCheck()
{
	var dload;

	dload = document.getElementById("project_downloads").value;
	if(isNaN(dload)){
		alert("Please Enter Numeric Value ");
		return false;
	}

	return true;
}

function check_usersessionfrm(type) {		

        var req = getXMLHTTP();
        var url = "/plugins/espforum/forumUtils.php";
        if (req) {
                req.onreadystatechange = function() {
                if (req.readyState == 4) {
                        if (req.status == 200) {
			     var res = trim(req.responseText);
			     if(res == 'fail')
			     { 
                                  document.getElementById('frmsession_expired').style.display = 'block';
			          document.addtopics.add_topic.disabled = true;
				  document.addtopics.add_topic_monit.disabled = true;
				  document.addtopics.cancel.disabled = true;
			     }
			     else
			     {
			          document.addtopics.topic_inputtype.value = type;
                                  document.addtopics.submit(); 
			     }





                        } else {
                                alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                                }
                        }
                }
                req.open("GET", url, true);
                req.send(null);
       }

}

function changeCatprojectsList(page,cat_id,subcat_id,count) {

  var sort = $('sort_id').value;
  var group_name = $('gp_name').value;
  
  var url = "/plugins/admin/listcategory_projects_ajax.php";
  $('loading_div_id').style.display = "block";
  $('project_list_display_div_id').style.display = "none";
  $('loading_div_id').innerHTML = "<img src='/themes/openbravo/images/ajax-loader.gif'>";
  new Ajax.Request(url, {
      method: 'post',
      parameters: { page: page, sort: sort, cat_id:cat_id, subcat_id:subcat_id,count:count,group_name:group_name },
      onSuccess: catprojectSuccess,
      onFailure: function() {
      alert("There was an error with the connection");
    }
  });
}

function listCatSearchprojectList(page,cat_id,subcat_id) {

  var sort = $('sort_id').value;
  var group_name = $('gp_name').value;
  var url = "/plugins/admin/listcategory_projects_ajax.php";
  $('loading_div_id').style.display = "block";
  $('project_list_display_div_id').style.display = "none";
  $('loading_div_id').innerHTML = "<img src='/themes/openbravo/images/ajax-loader.gif'>";
  new Ajax.Request(url, {
      method: 'post',
      parameters: { page: page, sort: sort, cat_id:cat_id, subcat_id:subcat_id,group_name:group_name },
      onSuccess: catprojectSuccess,
      onFailure: function() {
      alert("There was an error with the connection");
    }
  });

}

function catprojectSuccess(transport) {
  var response = transport.responseText;

  $('loading_div_id').style.display = "none";
  $('project_list_display_div_id').style.display = "block";
  $('project_list_display_div_id').innerHTML = response;
}

function deleteModuleList(user_id, module_id, module_name) {

    deleteModule = function(r) {

       if (r) {
           var url = "/my/module_list_ajax.php";
           $('module_cell').innerHTML = "<img src='/themes/openbravo/images/ajax-loader.gif'>";
           new Ajax.Request(url, {
              method: 'post',
               parameters: { user_id: user_id, module_id: module_id },
               onSuccess: deleteModuleSuccess,
               onFailure: function() {
               alert("There was an error with the connection");
             }
           });
       }
   }

   jConfirm("Are you sure to delete module '"+ module_name +"' ?", "Confirmation Dialog", deleteModule);
}

function deleteModuleSuccess(transport) {
  var response = transport.responseText;

  $('module_cell').innerHTML = response;
}

function showdetails(elmnt)
{
var limit = $('limit').value;
var imgstatus = $('infostatus').value;
if(imgstatus == 'on')
{
   var type = "block";
   $('infostatus').value = 'off';
   $('d1').style.display = 'none';
   $('d2').style.display = 'block';
}
else
{
   var type = "none";
   $('infostatus').value = 'on';
   $('d1').style.display = 'block';
   $('d2').style.display = 'none';
}


    for(i=0;i<limit;i++)
    {
        document.getElementById(elmnt+i).style.display=type;
    }

}


function showimage(elmnt)
{
var limit = $('limit').value;
var imgstatus = $('imagestatus').value;
if(imgstatus == 'on')
{
   var type = "block";
   $('imagestatus').value = 'off';
   $('img1').style.display = 'none';
   $('img2').style.display = 'block';
}
else
{
   var type = "none";
   $('imagestatus').value = 'on';
   $('img1').style.display = 'block';
   $('img2').style.display = 'none';
}

    for(i=0;i<limit;i++)
    {
        document.getElementById(elmnt+i).style.display=type; 
    }

}

function showfilters(elmnt)
{
    visible = (document.getElementById(elmnt).style.display!="none")
    if (visible)
    {
         document.getElementById(elmnt).style.display = "none";
         $('f1').style.display = 'block';
         $('f2').style.display = 'none';
    }
    else
    {
         $('f1').style.display = 'none';
         $('f2').style.display = 'block';
         document.getElementById(elmnt).style.display = "block";
    }

}

function getPublicModulesList(page,limit,sort) {
  var limit = $('limit').value;
  var sord = $('sorder').value;

  if($('sorder').value == 1)
      $('sorder').value = 0;
  else
     $('sorder').value = 1;

  var url = "/plugins/module/module_public_list.php";
  $('load_module_dynamic').innerHTML = " <div style='padding-top: 150px;'><center><img src='/themes/openbravo/images/ajax-loader.gif'></center></div>";
  new Ajax.Request(url, {
      method: 'post',
      parameters: { page: page, limit: limit, list_frm_svr: 'YES', sorder:sord, sort:sort },
      onSuccess: modulelistProcess,
      onFailure: function() {
      alert("There was an error with the connection");
    }
  });
}

function getPublicModulesSearch(page,limit) {
  var limit = $('limit').value;
  var inex  = $('inex').value;
  var searchname  = $('searchname').value;
  var url = "/plugins/module/module_public_list.php";
  if(searchname != '')
  {
      $('load_module_dynamic').innerHTML = "<div style='padding-top: 150px;'><center><img src='/themes/openbravo/images/ajax-loader.gif'></center><div>";
      new Ajax.Request(url, {
          method: 'post',
          parameters: { page: page, limit: limit, inex: inex, searchname: searchname, list_frm_svr: 'YES' },
          onSuccess: modulelistProcess,
          onFailure: function() {
          alert("There was an error with the connection");
          }
      });
  }
  else
  {
      alert('Enter Your Search Key');
      return false;
  }
}


function modulelistProcess(transport) {
  var response = transport.responseText;
  $('load_module_dynamic').innerHTML = response;
}
function privatecheck()
{

 if(document.project_register.projecttype.checked==false) 
   document.getElementById("priv").innerHTML='';
 else
   document.getElementById("priv").innerHTML='<input type="hidden" name="private" value="checkbox">';
}
