// JavaScript Document

var cgiPath;
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function keypressevent(event){
	var element = Event.element(event);
	if(!blockNonNumbers(element, event, true, false)) Event.stop(event);
}
function keypressevent_attachment(event){
	var element = Event.element(event);
	if(!blockNonNumbers(element, event, false, false)) Event.stop(event);
}

function blurevent(event){
	var element = Event.element(event);
	if(element.value.length==0)element.value=0;
}

function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;

	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}

	if (isNaN(key)) return true;

	keychar = String.fromCharCode(key);

	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;

	return isFirstN || isFirstD || reg.test(keychar);
}
var f_redirecttoLogin=function (handler,params){
       top.window.location.href= cgipath + params;
}
function f_edit_actionpanel(cgipath,srid,xstac){
	window.location.href = cgipath + 'x/xpstwsrupdate.p?sr_id=' + srid + '&actionpanel=yes&xstac=' + xstac + '&navigate=' + navigate  + '&hidenavigate=' + hidenavigate;
}
function f_edit_assign(cgipath,srid){
	window.location.href = cgipath + 'x/xpstwsrupdate.p?sr_id=' + srid + '&assignee=yes&navigate=' + navigate + '&hidenavigate=' + hidenavigate;
}
function f_edit_normal(cgipath,srid){
	window.location.href = cgipath + 'x/xpstwsrupdate.p?sr_id=' + srid + '&navigate=' + navigate + '&hidenavigate=' + hidenavigate;
}

function f_print_report(cgipath,srid){
	window.open(cgipath + 'x/xsrewreports.p?v-srid=' + srid ,'','','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes');
}

function f_search_sr(cgipath,searchstring){
	$("img_load").style.display="block";
	var myurl = cgipath + 'x/xpstwsearchsrid.p';
	var params='sridtosearch='+ searchstring ;
	var myObj = new javraAJAX(myurl,'post',{parameters: params});
	myObj.sendData();
}
var f_open_searchedsr = function (handler,params){
	var arrParam = params.split(',');
	var success  = arrParam[0];
	var srid     = arrParam[1];
	$("img_load").style.display="none";
	if (success == 'no'){
		$('nosrerr').style.display = "block";
		$('nosrerr').innerHTML = lnosr;
		setTimeout(" $('nosrerr').innerHTML = ''; $('nosrerr').style.display = 'none';" ,3000);
	}
   else{
     srid = srid.replace(/&ndash;/g,'-');
	 $('searchSRno').value = srid;
	 parent.frames['midframe'].location.href = cgipath + 'x/xpstwsrdetail.p?srid=' + srid;
   }

}
function CheckAlpha(myPath,f,currlink){
	//alert(myPath + " ---- " + f + " ---- " + currlink);
	var mykeycode = (window.event) ? event.keyCode : f.keyCode;
	if (mykeycode ==13) {
		if(currlink=="login"){
			validateUser(myPath); // login
		}
		if(currlink=="updatecompany"){
			updatecompany(myPath); // update company
		}
		if(currlink=="newdept"){
			f_newdept(myPath); // new dept
		}
		if(currlink=="updept"){
			f_updept(myPath); // update dept
		}
		if(currlink=="newuser"){
			f_newuser(myPath); // new user
		}
		if(currlink=="changeuser"){
			changeuser(myPath); // change user
		}
		if(currlink=="updateproj"){
			f_updateproj(myPath); // update project
		}
		if(currlink=="newteam"){
			f_newteam(myPath); // new project team
		}

	}
}


function f_search_byassignee(cgipath,projid,assignee){

	  f_search_filled(projid,cgipath,assignee,'assign');
	  window.location.href= cgipath + 'x/xepstwsrsearch.p?action=New&sortn=0&cmbstatus=1000,2000,3000,4000,5000,6000,7000,7500&comproj=' + projid + '&cmbassigne=' + assignee ;

	}

function f_resolvedbyme(cgipath,projid,resolver){

	  f_search_filled(projid,cgipath,resolver,'resolvedby');
	  window.location.href= cgipath + 'x/xepstwsrsearch.p?action=New&sortn=0&cmbstatus=1000,2000,3000,4000,5000,6000,7000,7500,8000&comproj=' + projid + '&resolvedby=' + resolver ;

	}

// validation for login
function validateUser(){
	var uname=$("username").value;
	var upwd=$("password").value;
	if(uname.length==0)	{
		$("errid").innerHTML="* Please enter username !";
		$("username").focus();
		return false;
	}
	if(upwd.length==0)	{
		$("errid").innerHTML="* Please enter password !";
		$("password").focus();
		return false;
	}
	return true;
}


// validation for company information while updating
function f_updatecompany(cgipath,c){
	var stat=0;
	var srsummary="no";
	var srstatus ="no";
	var code=$("code").value;
	var cname=$("cname").value;
	var address=$("address").value;
	var city=$("city").value;
	var state=$("state").value;
	var coun=$("coun").value;
	var zip=$("zip").value;
	var phone=$("phone").value;
	var fax=$("fax").value;
	var email=$("email").value;
	var website=$("website").value;
	var contact=$("contact").value;
	var comtyp =$("comtyp").value;
	var comver=$("comver").value;
	var hctype=$("hctype").value;
	 if ($("srsummary").checked)
	     srsummary = "yes";

	 	if ($("srstatus").checked)
	     srstatus = "yes";

	if(code.length==0)	{
		$("errcode").className="error";
		stat=stat+1;
	}
	else{$("errcode").className="";}

	var returnval=emailfilter.test(email)
	if (returnval==false){
		$("erremail").className="error";
		stat=stat+1;
	}
	else{$("erremail").className="";}

	if(coun.length==0)	{
		$("errcountry").className="error";
		stat=stat+1;
	}
	else{$("errcountry").className="";}

	if(comtyp==0)	{
		$("errcomtype").className="error";
		stat=stat+1;
	}
	else{$("errcomtype").className="";}

	if(stat>0)
	{
		$("errlabel").innerHTML="<span class='error'>* " + updateerror + "</span>";
		return false;
	}
	else{
		$("errlabel").innerHTML="";
	//	$('btn_update').disabled=true;
		var clearCache = new Date();
		cgiPath=cgipath;
		var myurl = cgipath + 'x/xpstwcompanyvalidate.p';
		var params='code='+ code + '&address='+ address + '&city='+ city + '&email='+ email + '&phone='+ phone + '&website='+ website + '&contact='+ contact + '&fax=' + fax+ '&zip=' + zip+ '&state=' + state + '&coun=' + coun +'&v_action=update' + '&cname='+ cname +'&comtyp=' + comtyp + '&comver=' + comver + '&srsummary='+ srsummary + '&srstatus='+ srstatus+ '&hctype='+ hctype + '&cache='+ clearCache;
		var myObj = new javraAJAX(myurl,'get',{parameters: params});
		myObj.sendData();
	}
}
/* no-more longer needed krishna
var f_navcompany = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + updatesuccess + "</td></tr></table></span>";
	setTimeout("window.location.href= cgiPath + 'x/xpstwcompany.p'",1500)
}
*/
var f_navcompany_update = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + updatesuccess + "</td></tr></table></span>";
	 opener.window.location.reload();
   setTimeout("window.close()",1100);
}



// validation for new user
function f_newdept(cgipath,d){
	var stat=0;
	var code=$("code").value;
	var depname=$("name").value;
	var address=$("address").value;
	var phone=$("phone").value;
	var email=$("email").value;
	var city=$("city").value;
	var desc=$("desc").value;
	var zip=$("zip").value;
	var fax=$("fax").value;
	var contact=$("contact").value;
	var v_action = $("action1").value;

	if(code.length==0)	{
		$("errdeptcode").className="error";
		stat=stat+1;
	}
	else{$("errdeptcode").className="";}

	if(depname.length==0)	{
		$("errname").className="error";
		stat=stat+1;
	}
	else{$("errname").className="";}

	if(address.length==0)	{
		$("erradd").className="error";
		stat=stat+1;
	}
	else{$("erradd").className="";}

	var returnval=emailfilter.test(email)
	if (returnval==false){
		$("erremail").className="error";
		stat=stat+1;
	}
	else{$("erremail").className="";}

	if(stat>0)
	{
		$("errlabel").innerHTML="<span class='error'>* " + newerror +"</span>";
		return false;
	}
	else{
		$("errlabel").innerHTML="";
		var clearCache = new Date();
		cgiPath=cgipath;
		var myurl = cgipath + 'x/xpstwdeptvalidate.p';
		var params='code='+ code +'&name='+ depname + '&address='+ address + '&city='+ city + '&phone='+ phone + '&email='+ email + '&zip='+ zip + '&fax='+ fax+ '&desc='+ desc + '&contact='+ contact+ '&v_action=' + v_action +'&cache='+ clearCache;
		var myObj = new javraAJAX(myurl,'get',{parameters: params});
		myObj.sendData();
	}
}

var f_navdept = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>*" + newsuccess + "</td></tr></table></span>";
	setTimeout("window.location.href= cgiPath + 'x/xpstwcompany.p'",1500)
}

function f_existdept(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + exists + " " + $('code').value + " " + "!!!" + "</td></tr></table></span>";
	document.forms.form1.reset();
}

function cleardept(cgiPath){
	window.location.href= cgiPath + 'x/xpstwcompany.p';
}


// validation for update department
 function f_updept(cgipath,b){
 	var stat=0;
	var code=$("code").value;
	var depname=$("name").value;
	var address=$("address").value;
	var phone=$("phone").value;
	var email=$("email").value;
	var city=$("city").value;
	var desc=$("desc").value;
	var zip=$("zip").value;
    var fax=$("fax").value;
	var contact=$("contact").value;
	var v_action = $("action1").value;

  if(code.length==0)	{
		$("errdeptcode").className="error";
		stat=stat+1;
	}
	else{$("errdeptcode").className="";}

	if(depname.length==0)	{
		$("errname").className="error";
		stat=stat+1;
	}
	else{$("errname").className="";}

	if(address.length==0)	{
		$("erradd").className="error";
		stat=stat+1;
	}
	else{$("erradd").className="";}

	var returnval=emailfilter.test(email)
	if (returnval==false){
		$("erremail").className="error";
		stat=stat+1;
	}
	else{$("erremail").className="";}

	if(stat>0)
	{
		$("errlabel").innerHTML="<span class='error'>* " + updateerror + "</span>";
		return false;
	}
	else{
		$("errlabel").innerHTML="";
		$('btn_update').disabled=true;

	  var clearCache = new Date();
	  cgiPath=cgipath;
	  var myurl = cgipath + 'x/xpstwupdatedeptvalidate.p';
	  var params='code='+ code +'&name='+ depname + '&address='+ address + '&city='+ city + '&phone='+ phone+ '&zip='+ zip + '&fax='+ fax + '&email='+ email + '&desc='+ desc + '&contact='+ contact+ '&v_action=' + v_action +'&cache='+ clearCache;

    var myObj = new javraAJAX(myurl,'get',{parameters: params});
	  myObj.sendData();
    }
  }

var f_dept = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + updatesuccess + "</td></tr></table></span>";
	setTimeout("window.location.href= cgiPath + 'x/xpstwcompany.p'",1500)
}


// validation for new user
function f_newuser(cgipath,g){
	var stat=0;
	var user=$("user").value;
	var username=$("uname").value;
	var pwd=$("pass").value;
	var pwd1=$("pass2").value;
	var address=$("address").value;
	var phone=$("phone").value;
	var email=$("email").value;
	var dept=$("dept").value;
	var coun=$("coun").value;
	var city=$("city").value;
	var state=$("state").value;
	var web=$("web").value;
	var fax=$("fax").value;
	var dept=$("dept").value;
	var lang=$('lang').value;
	var xuseladmin=$("xuseladmin").checked;
  var v_action = $("action1").value;

  if(user.length==0)	{
		$("errid").className="error";
		stat=stat+1;
	}
	else{$("errid").className="";}
	if(username.length==0)	{
		$("errname").className="error";
		stat=stat+1;
	}
	else{$("errname").className="";}

	if(pwd.length==0)	{
		$("errpwd1").className="error";
		stat=stat+1;
	}
	else{$("errpwd1").className="";}

	if(pwd1.length==0)	{
		$("errpwd2").className="error";
		stat=stat+1;
	}
	else{$("errpwd2").className="";}

	if ((pwd.length > 0) && (pwd1.length > 0)){
	if (pwd != pwd1){

		$("errpwd1").className="error";
		$("errpwd2").className="error";
		stat=stat+1;
	}
	else{
		$("errpwd1").className="";
		$("errpwd2").className="";
	}
	}
  var returnval=emailfilter.test(email)
	if (returnval==false){
		$("erremail").className="error";
		stat=stat+1;
	  }
	else{$("erremail").className="";}

   if(coun==0)	{
		$("errcoun").className="error";
		stat=stat+1;
	  }
	else{$("errcoun").className="";}

	 if(dept==0)	{
		$("errdept").className="error";
		stat=stat+1;
	  }
	else{$("errdept").className="";}

	if(lang==0)	{
		$("errlang").className="error";
		stat=stat+1;
	  }
	else{$("errlang").className="";}

		if(stat>0)
	{
		$("errlabel").innerHTML="<span class='error'>* " + newerror + "</span>";
		return false;
	}
	else{
		$("errlabel").innerHTML="";

	var clearCache = new Date();
	cgiPath=cgipath;
	var myurl = cgipath + 'x/xpstwnewuservalidate.p';
	var params='user='+ user + '&username='+ username + '&password='+ pwd + '&password1='+ pwd1+ '&address='+ address + '&phone='+ phone + '&email='+ email + '&dept='+ dept + '&lang=' + lang +  '&xuseladmin='+ xuseladmin + '&coun='+ coun + '&city='+ city + '&state='+ state + '&web='+ web + '&fax='+ fax + '&v_action=' + v_action +'&cache='+ clearCache;
	//alert(params);
  var myObj = new javraAJAX(myurl,'get',{parameters: params});
   globevent=$("btnnewuser").onclick;
	$("btnnewuser").onclick=function(){};

	myObj.sendData();
  }
}

var f_nuser = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + newsuccess + "</td></tr></table></span>";
	setTimeout("window.location.href= cgiPath + 'x/xpstwusers.p'",1500)
}

function f_existuser(){
	$("btnnewuser").onclick=globevent;
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + alreadyexist +  " " + $("user").value + " " + "!!!" + "</td></tr></table></span>";
	$('user').value= '';
}

function clearuser(cgiPath){
	window.location.href= cgiPath + 'x/xpstwusers.p';
}


// validation for user information
function changeuser(cgipath,f){
	var stat=0;
	var user=$("user").value;
	var username=$("uname").value;
	var upwd=$("pass").value;
	var cupwd=$("cpass").value;
	var address=$("address").value;
	var phone=$("phone").value;
	var email=$("email").value;
	var coun=$("coun").value;
	var city=$("city").value;
	var state=$("state").value;
	var web=$("web").value;
	var fax=$("fax").value;
	var dept=$("dept").value;
	var lang=$("lang").value;
    var xuseladmin=$("xuseladmin").checked;

  if(username.length==0)	{
		$("errname").className="error";
		stat=stat+1;
	  }
	else{$("errname").className="";}

	if(upwd.length==0)	{
		$("errpass").className="error";
		stat=stat+1;
	  }
	else{$("errpass").className="";}

	if(cupwd.length==0)	{
		$("errcpass").className="error";
		stat=stat+1;
	  }
	else{$("errcpass").className="";}


	if ((upwd.length > 0) && (cupwd.length > 0)){
	if (upwd != cupwd){

		$("errpass").className="error";
		$("errcpass").className="error";
		stat=stat+1;
	}
	else{
		$("errpass").className="";
		$("errcpass").className="";
	}
	}

	var returnval=emailfilter.test(email)
	if (returnval==false){
		$("erremail").className="error";
		stat=stat+1;
	  }
	else{$("erremail").className="";}

   if(coun==0)	{
		$("errcoun").className="error";
		stat=stat+1;
	  }
	else{$("errcoun").className="";}

	 if(dept==0)	{
		$("errdept").className="error";
		stat=stat+1;
	  }
	else{$("errdept").className="";}

	if(lang==0)	{
		$("errlang").className="error";
		stat=stat+1;
	  }
	else{$("errlang").className="";}

	if(stat>0)
	{
		$("errlabel").innerHTML="<span class='error'>* " + updateerror + "</span>";
		return false;
	}
	else{
		$("errlabel").innerHTML="";
		//$('btn_update').disabled=true;
	  var clearCache = new Date();
	  cgiPath=cgipath;
	  var myurl = cgipath + 'x/xpstwuserinfovalidate.p';
	  var params='user='+ user + '&username='+ username +'&password='+$F('pass')+ '&cpassword='+$F('cpass')+ '&address='+ address + '&phone='+ phone + '&email='+ email + '&dept='+ dept + '&lang=' + lang + '&xuseladmin='+ xuseladmin + '&coun='+ coun + '&city='+ city + '&state='+ state + '&web='+ web + '&fax='+ fax + '&cache='+ clearCache;

	  var myObj = new javraAJAX(myurl,'get',{parameters: params});
	  $("btn_update").onclick=function(){};
	  myObj.sendData();
    }
 }

 var f_clearuser = function(){
	$("user").value = "";
	$("uname").value = "";
	$("address").value = "";
	$("phone").value = "";
	$("email").value = "";
	$("dept").value = "";
	$("pass").value = "";
	$("xuseladmin").value = "";
}

var f_navuser = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + updatesuccess + "</td></tr></table></span>";
	setTimeout("window.location.href= cgiPath + 'x/xpstwusers.p'",1500)
}

function f_canceluser() {
	window.location.href= cgiPath + 'x/xpstwusers.p';
}

// update user profile called by click of button "Update" of "xpstwprofile.htm"
function changeprofile(cgipath,h){
	var stat=0;
	var chkd=0;
	var uid=$("userid").value;
	var username=$("user").value;
	var dept=$("dept").value;
	var language=$("language").value;
	var address=$("address").value;
	var phone=$("phone").value;
	var fax=$("fax").value;
	var website=$("website").value;
	var city=$("city").value;
	var state=$("state").value;
	var country=$("country").value;
  	var email=$("email").value;
	var notify=$("notify").checked;
	var mailme=$("mailtoself").checked;
	var recmail=$("recmail").checked;
	var update=$("notupdate").checked;
	var statupdate=$("notstatupdate").checked;
	var reassign=$("notreassign").checked;
	var commented=$("notcommented").checked;	
	
	if(username==""){
		$("erruname").className="error";
		$("errlabel").innerHTML="<span class='error'>" + usermsg + "</span>";
		return false;
	}	
	else {$("erruname").className="";}
		
	/*Mail validation*/
	var returnval=emailfilter.test(email)
	if (returnval==false){
		$("erremail").className="error";
		$("errlabel").innerHTML="<span class='error'>" + emailid + "</span>";
		return false;
	  }
	else{$("erremail").className="";}

	//At least one notification event must be checked if "Receive Mail" is checked.
	if (recmail==true){
		if(update==true||statupdate==true||reassign==true||commented==true){
			chkd=1;
		}
		if (chkd==0){
			$("errmailrec").className="error";
			$("errlabel").innerHTML="<span class='error'>* " + notifyoption +  "</span>";
			return false;
		}
		else{$("errmailrec").className="";}
	}
		 
 	if(stat>0)
	{
		$("errlabel").innerHTML="<span class='error'>* " + updateerror + "</span>";
		return false;
	}
	else{
		$("errlabel").innerHTML="";
		//$('btn_update').disabled=true;
	var clearCache = new Date();
	cgiPath=cgipath;
	var myurl = cgipath + 'x/xpstwprofilevalidate.p';
	var params='userid='+ uid
						+'&username='+encodeURIComponent(username)
						+'&address='+encodeURIComponent(address)
						+'&phone='+ encodeURIComponent(phone)
						+'&email='+email
						+'&language='+language
						+'&fax='+encodeURIComponent(fax)
						+'&website='+encodeURIComponent(website)
						+'&city='+encodeURIComponent(city)
						+'&state='+encodeURIComponent(state)
						+'&country='+country
						+'&notify='+notify
						+'&recmail='+recmail
						+'&update='+update
						+'&statupdate='+statupdate
						+'&reassign='+reassign
						+'&commented='+commented
						+'&mailtoself='+mailme
						+'&mode='+'profile'
						+'&cache='+clearCache;
	var myObj = new javraAJAX(myurl,'get',{parameters: params});
	globevent=$("btn_update").onclick;
	$("btn_update").onclick=function(){};

	myObj.sendData();
}
}
var f_clearoldpwd = function(){
   $("btn_update").onclick=globevent;
  $("errlabel").innerHTML="<span class='error'>* " + oldpwd +  "</span>";
  $("errpass").className="error";
	$("pass").value = "";
	$("pass").focus();
}

// called after successful update of user profile from "xpstwprofilevalidate.p"
var f_navigated = function(){
		$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + updatesuccess + "</td></tr></table></span>";
		setTimeout("window.location.href= cgiPath + 'x/xpstwprofile.p'",1500);
}

// called after successful update of password change from "xpstwprofilevalidate.p"
var f_navpwdupdate = function(){
		$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + pwdsuccess + "</td></tr></table></span>";
		setTimeout("window.location.href= cgiPath + 'x/xpstwprofile.p'",1500);
}

//called by click of button "Update" of "xpstwchangepassword.htm"
function changepwd(cgipath){
	var stat=0;
	var userid=$("uid").value;
	var upwd=$("pass").value;
	var upwd1=$("pass2").value;
	var upwd2=$("pass22").value;
	
	/*first and second passwords do not match*/
	if (upwd1 != upwd2)
		{
		 $("errnewpass").className="error";
		 $("errrenewpass").className="error";
		 $("errpass").className="";
		 $("errlabel").innerHTML="<span class='error'>* " + updateerror + "</span>";
		  return false;
	  }
	else
		{
		 $("errnewpass").className="";
		 $("errrenewpass").className="";
	  }

   /* same new and old passwords */
		if(upwd.length > 0 && upwd1.length > 0)
		  {
	     if (upwd == upwd1)
	      {
		     $("errnewpass").className="error";
		     $("errpass").className="error";
		     $("errlabel").innerHTML="<span class='error'>* " + notmatched + "</span>";
		     return false;
	      }
	     else
	   	  {
		      $("errnewpass").className="";
		      $("errpass").className="";
	      }
    }

   /*if old passwod  not fill and othe filed */
		if(upwd.length == 0 && upwd1.length > 0 && upwd2.length > 0 )
		  {
		     $("errpass").className="error";
		     $("errlabel").innerHTML="<span class='error'>* " + oldpwd + "</span>";
		     return false;
	    }
	     else
	   	  {
		     $("errpass").className="";
	      }

    /*if password filed only field*/
   if(upwd.length!=0)
     {
		  if(upwd1.length == 0 || upwd2.length== 0)
		    {
		     $("errpass").className="error";
		     $("errlabel").innerHTML="<span class='error'>* " + oldonly + "</span>";
		      return false;
		     }
	    else
	     	{
	     	 $("errpass").className="";
	     	 $("errnewpass").className="";
	     	 $("errrenewpass").className="";
	      }
	   }

 if(stat>0)
	{
		$("errlabel").innerHTML="<span class='error'>* " + updateerror + "</span>";
		return false;
	}
	else{
		$("errlabel").innerHTML="";
		//$('btn_update').disabled=true;
		var clearCache = new Date();
		cgiPath=cgipath;
		var myurl = cgipath + 'x/xpstwprofilevalidate.p';
		var params='userid='+ userid +'&password='+  upwd + '&newpassword='+ upwd1 +'&renewpassword='+ upwd2 + '&mode=' + 'pwd' + '&cache='+clearCache;
		var myObj = new javraAJAX(myurl,'get',{parameters: params});
		globevent=$("btn_update").onclick;
		$("btn_update").onclick=function(){};
		myObj.sendData();
	}

}


// js for dashboard left frame
function show_r1(ab){
if(ab!=0){
document.getElementById("r1").style.display="block";
}
else{
document.getElementById("r1").style.display="none";
}
}

function getWindowHeight() {
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function page_height(){
var winHeight =getWindowHeight();
var pg;
pg=winHeight-250;

document.getElementById("left_scroll").style.height=pg+"px";
document.getElementById("left_scroll").style.overflowY="scroll";
}

function f_cancel(){
	window.location.href= cgiPath + 'x/xpstwusers.p';
}

var f_clearpwd = function(){
	$("user").focus();
}

function f_focus(){
	$("user").select();
}

function f_del(me){
	//alert(' ---  '+me);
  var r=confirm("Are you sure you want to delete?")
  if (r==true){
		location.replace(me);
		parent.frames['0'].location.reload();
	}
  else{
    return false;
	}
}



/*krishna*/
function f_callmodules(cmbval,cgipath){

	show_r1(cmbval);
	$('projhiden').value=cmbval;
	$('cmbassigne').length = 0;
	$('cmbcretor').length = 0;
	$('cmbmodule').length = 0;
	$('cmbversion').length = 0;
	$('fixversion').length = 0;
	$('resolvedby').length = 0;
	var myObj = new javraAJAX(cgipath+'x/xepstwfillvalue.p','post',{parameters: "prjval="+cmbval});
	myObj.sendData();
}

function f_view(){
	  window.location.href= '[cgiPath]x/xpstwcompany.p';
	}


	// validation for new project
 function f_newproject(cgipath,e){
 	var stat=0;
	var proj_id=$("proj_id").value;
	var projname=$("projname").value;
	var desc=$("desc").value;
	var comp=$("comp").value;
	var tech=$("tech").value;
	var attach=$("attach").value;
	var v_action = $("action1").value;
	var dmail=$("dmail").checked;

   if(proj_id.length==0)	{
		$("errprojid").className="error";
		stat=stat+1;
	}
	else{$("errprojid").className="";}


  if(projname.length==0)	{
		$("errprojname").className="error";
		stat=stat+1;
	}
	else{$("errprojname").className="";}

  if(comp.length==0)	{
		$("errcomp").className="error";
		stat=stat+1;
	}
	else{$("errcomp").className="";}

	if(tech.length==0)	{
		$("errtech").className="error";
		stat=stat+1;
	}
	else{$("errtech").className="";}

		if(stat>0)
	{
		$("errlabel").innerHTML="<span class='error'>* " + newerror +"</span>";
		return false;
	}
	else{
		$("errlabel").innerHTML="";
		var clearCache = new Date();
		cgiPath=cgipath;
		var myurl = cgipath + 'x/xpstwprojectvalidate.p';
		var params='proj_id='+ proj_id + '&projname='+ projname + '&desc='+ desc + '&comp='+ comp + '&tech='+ tech+ '&attach='+ attach + '&v_action=' + v_action + '&dmail=' + dmail+'&cache='+ clearCache;
		//alert(params);
		var myObj = new javraAJAX(myurl,'get',{parameters: params});
		myObj.sendData();
	}

}

var f_navproj  = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>*" + newsuccess + "</td></tr></table></span>";
	setTimeout("window.location.href= cgiPath + 'x/xpstwprojects.p'",1500)
}

var f_existproj = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + exists + " " + $('proj_id').value + " " + "!!!" + "</td></tr></table></span>";
	//document.forms.form1.reset();
}

var f_oversize = function(){
		$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + oversize + "</td></tr></table></span>";
	  $("attach").value = "";
	   $("attach").focus();
}
function clearproj(cgiPath){
	window.location.href= cgiPath + 'x/xpstwprojects.p';
}


// validation for update  project
 function f_updateproj(cgipath,e){
 	var stat=0;
	var atterr=0;
	var proj_id=$("proj_id").value;
	var projname=$("projname").value;
	var pstat=$("pstat").value;
	var desc=$("desc").value;
	var tech=$("tech").value;
	var attach=$("attach").value;
	var attlimit=$("maxattach").value;
	
	if(parseInt(attach) > parseInt(attlimit))	{
		$("errattach").className="error";
		stat=stat+1;
		atterr=atterr+1;
	}
	else{$("errattach").className="";}
	
  if(proj_id.length==0)	{
		$("errprojid").className="error";
		stat=stat+1;
	}
	else{$("errprojid").className="";}

  if(projname.length==0)	{
		$("errprojname").className="error";
		stat=stat+1;
	}
	else{$("errprojname").className="";}

	if(tech.length==0)	{
		$("errtech").className="error";
		stat=stat+1;
	}
	else{$("errtech").className="";}

	
		if(stat>0){
			if(atterr>0)		{
				$("errlabel").innerHTML="<span class='error'>* " + attachlimit +"</span>";
				return false;
			}
			else	{
				$("errlabel").innerHTML="<span class='error'>* " + uperror +"</span>";
				return false;
			}
		}
	else{
		$("errlabel").innerHTML="";
		var clearCache = new Date();
		cgiPath=cgipath;
		var myurl = cgipath + 'x/xpstwprojupvalidate.p';
		var params='proj_id='+ proj_id + '&projname='+ encodeURIComponent(projname)+ '&pstat='+ pstat + '&desc='+ encodeURIComponent(desc) + '&tech='+ encodeURIComponent(tech)+ '&attach='+        attach + '&cache='+ clearCache;
		var myObj = new javraAJAX(myurl,'get',{parameters: params});
		myObj.sendData();
	    $('btn_save').onclick = function() {};
	}

	}

var f_upproj  = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>*" + upsuccess + "</td></tr></table></span>";
	parent.left_frame.document.location.reload();
	setTimeout("$('errlabel').innerHTML=''",1500);
	window.location.reload(true);

}

/* added by pushpendra */
function f_updateproj_cancel(cgipath){
	document.location.href=cgipath + 'x/xpstwprojects.p';
}
// For Feeder in Dashborad to show Description on MouseOver of each item
function showFeederInfo(feederid,evt)
{
	var parentobj=window.parent.document;
	if(parentobj.getElementById("div_tt"))parentobj.getElementsByTagName("body").item(0).removeChild(parentobj.getElementById("div_tt"));
	if (!evt) var evt = window.event;

   	 var x = Event.pointerX(evt)  ,
      y = Event.pointerY(evt) ;
	   var tooltipdiv=parentobj.createElement("DIV");
	  tooltipdiv.id="div_tt";
	  tooltipdiv.innerHTML=$(feederid).value;
	  tooltipdiv.style.padding="4px";
	  tooltipdiv.style.fontSize="11px";
	  tooltipdiv.style.fontFamily="Arial, Helvetica, sans-serif";
	  tooltipdiv.style.position="absolute";
	  tooltipdiv.style.zIndex="5000";
	  tooltipdiv.style.backgroundColor="#dadada";
	  tooltipdiv.style.border="2px solid #f2f1f1";
	  parentobj.getElementsByTagName("body").item(0).appendChild(tooltipdiv);
	  if(tooltipdiv.offsetWidth>350){
	  	tooltipdiv.style.width="350px";
		tooltipdiv.style.left=(x-360)+"px";
	  }else{
	  	tooltipdiv.style.width=tooltipdiv.offsetWidth+"px";
		tooltipdiv.style.left=(x-tooltipdiv.offsetWidth)+"px";
	  }
	  tooltipdiv.style.top=y+"px";

}



function hideInfo()
{
	var parentobj=window.parent.document;
	if(parentobj.getElementById("div_tt"))
	parentobj.getElementsByTagName("body").item(0).removeChild(parentobj.getElementById("div_tt"));
}

/* New SR */
function f_validate(cgipath,trackbtn){
	var stat=0;
    var srtitle =$("txtsrtitle").value;
	var srdesc=$("txtareadesc").value;
	var srtype=$("cmbsrtype").value;
	var oversize=$("oversize").value;
	$("trackbtn").value=trackbtn;
    $("errdescription").className="";
    $("errsrtitle").className="";

	if ($('cmbsrvar'))
	$("errversion").className="";

	if ($('validateworklog').value == 'check')
      $("errbilla").className="";

  if(srtitle.length==0)	{
		$("errsrtitle").className="error";
		stat=stat+1;
		$("txtsrtitle").value="<" + lreqsrtitle + ">";
		$("txtsrtitle").select();
		$("txtsrtitle").focus();
		return false;
	 }
  else
	  $("errsrtitle").className="";

	 if(srdesc.length==0)	{
	 	$("errdescription").className="error";
	 	 stat=stat+1;
		 $("txtareadesc").value="<" + lreqsrdesc + ">";
		 $("txtareadesc").select();
		 $("txtareadesc").focus();
		return false;
	 	}
    else
    $("errdescription").className="";

    if(srtype==1 )
   {
     if ($('cmbsrvar')){
		var srver=$("cmbsrvar").value;
		if (srver==0){
        $("errversion").className="error";
        stat=stat+1;
		$("cmbsrvar").value='0';
		$("cmbsrvar").focus();
		return false;
		}
		else
        $("errversion").className="";
       }

  }

  if ($('validateworklog').value == 'check')
   {
   	 var billable=$("billable").checked;
   	 var worklog=$("worklog").checked;
     if (billable==true)
      {
    	  if (worklog==false)
    	    {
    		    $("errbilla").className="error";
		         stat=stat+1;
				 $("billable").focus();
				return false;
    	    }
         else
    	    {
    		    $("errbilla").className="";
    	    }
      }
   }
	document.forms.add.action= cgipath + 'x/xpstwsradd-submit.p';
	document.forms.add.submit();
	document.getElementById("btnSubmit1").onclick=function(){};
	document.getElementById("btnSubmit2").onclick=function(){};
}



function f_fillvalue(cgipath,me){

var myObj = new javraAJAX(cgipath+'x/xpstwupdatesrcmbfill.p','post',{parameters: "cmbvalnsr="+me.value});
	myObj.sendData();

}

/*krishna */


function f_fillvalueadd(cgipath,me){

	document.getElementById('cmbassign').innerHTML="";
	document.getElementById('cmbsrvar').innerHTML="";
	document.getElementById('cmbsrmod').innerHTML="";

	var myObj = new javraAJAX(cgipath+'x/xpstwupdatesrcmbfill.p','post',{parameters: "cmbvalnsr="+me.value});
	myObj.sendData();

	setTimeout("f_selectdefassignee();",1000);
}

function   f_selectdefassignee(){
	var defassignee= $('defassignee').value;
	$('cmbassign').value = defassignee;
}

// validation for new project team
// validation for new project team
var projectId="";
function f_newteam(cgipath,projid){
	var stat=0;
  var proj_id=$("proj_id").value;
	var puser=$("user").value;
	var prole=$("userrole").value;
	var dassigne=$("dassigne").checked;
	var action1=$("action1").value;
	projectId=projid;
	 if(puser.length==0)	{
		$("erruser").className="error";
		stat=stat+1;
	}
	else{$("erruser").className="";}

	if(prole.length==0)	{
		$("errusertole").className="error";
		stat=stat+1;
	}
	else{$("errusertole").className="";}
	if(stat>0)
	{
		$("errlabel").innerHTML="<span class='error'>* " + newerror + "</span>";
		return false;
	}
	else{
		$("errlabel").innerHTML="";
		//$('btn_new').disabled=true;
	var clearCache = new Date();
	cgiPath=cgipath;
	var myurl = cgipath + 'x/xpstwprojteamvalidate.p';
	var params='proj_id='+proj_id +'&puser='+puser + '&prole='+prole+ '&dassigne='+dassigne + '&action1='+action1+'&cache='+clearCache;
 // alert(params);
	var myObj = new javraAJAX(myurl,'get',{parameters: params});
	myObj.sendData();
}
}
var f_clear = function(){
	$("errid").innerHTML="* Userid or Password not valid!";
	$("usr").value = "";
	$("pwd").value = "";
	$("usr").focus();
}

var f_navteam = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + newsuccess + "</td></tr></table></span>";
	 setTimeout("window.location.href='" + cgiPath + "x/xpstwprojconfigure.p?proj_id=" + projectId + "'",1500);


}

 var f_existteam = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + exists + " " + $('user').value + " with this role" + "</td></tr></table></span>";
	$("user").value = "";
	$("userrole").value = "";
	$("user").focus();
}

function clearteam(cgiPath,projid){
	 var projectId="";
	projectId=projid;
	window.location.href= cgiPath + 'x/xpstwprojectoverview.p?proj_id='+ projectId;
}
/*delete sr*/
function f_delsr(me){
  var r=confirm("Are you sure you want to delete!!")
  if (r==true){
  	//alert(me);
  	location.reload();
		window.location.href=me;
	}
  else{
    return false;
	}
}

function f_validateupdate(cgipath,trackbtn,dispSRsumm){

	var stat=0;
	var proj = $("cmbproj").value;
    var srtitle =$("txtsrtitle").value;
	var srdesc=$("txtareadesc").value;
	var srtype=$("cmbsrtype").value;
	var bstatus=$("cmbstatus").value;
	var resol=$("cmbresol").value;
	var plandate=$("plandate").value;
	var srbill="";
	$("trackbtn").value=trackbtn;
	$("errsrtitle").className="";
	$("errdescription").className="";
    if ($('cmbbillcode'))
	   srbill=$("cmbbillcode").value;
	if ($('cmbsrvar'))
	$("errversion").className="";

	$("errresolution").className="";
	if (plandate=='yes'){
	$("errready").className="";
	$("errdue").className="";
	}

	if(srtitle.length==0)	{
		$("errsrtitle").className="error";
		stat=stat+1;
		$("txtsrtitle").value="<" + lreqsrtitle + ">";
		$("txtsrtitle").select();
		$("txtsrtitle").focus();
		return false;
	}

	 if(srdesc.length==0)	{
	 	$("errdescription").className="error";
	 	 stat=stat+1;
		 $("txtareadesc").value="<" + lreqsrdesc + ">";
		 $("txtareadesc").select();
		 $("txtareadesc").focus();
		return false;
	 	}

    if(srtype==1 )
   {
      if ($('cmbsrvar')){
		var srver=$("cmbsrvar").value;
		if (srver==0){
        $("errversion").className="error";
        stat=stat+1;
		$("cmbsrvar").value='0';
		$("cmbsrvar").focus();
		return false;
		}
       }
  }

   if(bstatus=='6000' )
   {
     if (resol==0)
      {
        $("errresolution").className="error";
        stat=stat+1;
		$("cmbresol").value='0';
		$("cmbresol").focus();
		return false;

       }
  }

	if (plandate=='yes')
	  {
	  	var srplan=$("srplan").value;
		var srplandt=f_getDate(srplan)
		var sready=$("sready").value;
		var readydt=f_getDate(sready);
		var duedate=$("duedate").value;
		var duedt=f_getDate(duedate);

	     if (srplandt > readydt)
	      {
	       $("errready").className="error";
	       stat=stat+1;
		   $("sready").select();
		   $("sready").focus();
		   return false;
	      }

	    if (readydt > duedt)
	      {
	       $("errdue").className="error";
	       stat=stat+1;
		   $("duedate").select();
		   $("duedate").focus();
		   return false;
	      }
	  }

  if(stat == 0){
  	 $("img_load").style.display="block";
	 var myurl = cgipath + 'x/xpstwsrupdate-ajax.p';
	 if ($('cmbsrvar'))
	    srver=$('cmbsrvar').value;
	else
	    srver='0';
	 var params='sr_id='+$F('sr_id')+'&txtcusref='+encodeURIComponent($F('txtcusref'))+'&txtsrtitle='+encodeURIComponent($F('txtsrtitle'))+'&cmbsrtype='+$F('cmbsrtype')+'&cmbstatus='+$F('cmbstatus')+'&cmbsrpn='+$F('cmbsrpn')+'&cmbsrseverity='+$F('cmbsrseverity')+'&cmbresol='+$F('cmbresol')+'&cmbsrmod='+$F('cmbsrmod')+'&cmbassign='+$F('cmbassign')+'&cmbbillcode=' + srbill +'&cmbsrvar=' +  srver +'&txtareadesc='+encodeURIComponent($F('txtareadesc'))+'&txtlcommit='+encodeURIComponent($F('txtlcommit'))+'&txtenv='+encodeURIComponent($F('txtenv'));

	 if (dispSRsumm==1){
		 params+='&srplan='+$F('srplan')+'&sready='+$F('sready')+'&fixedprice='+$F('fixedprice')+'&duedate='+$F('duedate')+'&estim='+$F('estim')+'&worklog='+$F('worklog')+'&srebill='+$F('srebill')+'&remain='+$F('remain');
		 }

	 var myObj = new javraAJAX(myurl,'post',{parameters: params});
	 myObj.sendData();
	 $('btnSubmit').onclick = function(){};
	 $('btnSubmit1').onclick = function(){};

	}
}


function f_getDate(me)
 {
	var myDate=new Date();
	var arrParam =me.split('/');
  myDate.setFullYear(arrParam[2],arrParam[1]-1,arrParam[0]);
	return (myDate);
 }

function f_del1(me){

  var r=confirm("Are you sure you want to delete!!")
  if (r==true){
		window.location.href=me;
	}
  else{
    return false;
	}
}

function f_trackSubmitcommentadd(cgiPath){

 	if( (xsretidlink == "") && (document.getElementById('reloadstat').value=="yes"))
	    f_closepopupwindow();

	if( (xsretidlink != "") && (document.getElementById('reloadstat').value=="yes")){
		if (confirm("Do you want to add the following SR as linked SR: " + xsretidlink + "?")){
			var myurl = cgipath + 'x/xpstwcommitlinkedsrs.p';
			var params = 'frmcomment=yes&mode=create&srid=' + srid + '&lsrid=' + xsretidlink + '&pid=' + xprenlink ;
			var myObj = new javraAJAX (myurl, 'post', {
			parameters: params
			});
			myObj.sendData();
		}
		else
		    f_closepopupwindow();
	}
}

function f_redirect()
{
  window.location.reload();
}

// added by sharmila for not allowing to delete module and version if module and version is related to any of the SR.
function f_notallow()
{
  alert('Cannot delete. One or more SRs refers to this record.');
}

function f_openwindow(cgipath,srid){
myWindow=window.open(cgipath + 'x/xpstwcommentadd.p?srid=' +srid,'','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
myWindow.focus()

}
function f_updatesrecomment(cgipath,srid,srcn){
	myWindow=window.open(cgipath + 'x/xpstwcommentadd.p?pagestat=update&srid=' +srid + '&seq=' +srcn,'','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
	myWindow.focus()
}

function f_backfill(me,cgipath){
	if(me!=null){
	  var myObj = new javraAJAX(cgipath+'x/xepstwfillvalue.p','post',{parameters: "srid="+me});
 	  myObj.sendData();
 	document.getElementById('cmbsrtype').innerHTML="";
	document.getElementById('cmbversion').innerHTML="";
	document.getElementById('cmbmodule').innerHTML="";
	document.getElementById('cmbstatus').innerHTML="";
	document.getElementById('cmbprior').innerHTML="";
	document.getElementById('cmbassigne').innerHTML="";
	document.getElementById('cmbcretor').innerHTML="";
  }

}

function f_backfill2(me,cgipath,type,status){

	document.getElementById('comproj').value = me;

	$('resolvedby').length = 0;
	$('cmbassigne').length = 0;
	$('cmbcretor').length = 0;
	$('cmbmodule').length = 0;
	$('cmbversion').length = 0;
	$('fixversion').length = 0;
	$('txtsearch').value = "";
	$('watch').checked = '';
	document.getElementById("cmbprior").selectedIndex = -1;
	document.getElementById("cmbstatus").selectedIndex = -1;
	document.getElementById("cmbsrtype").selectedIndex = -1;
	document.getElementById("cmbseverity").selectedIndex = -1;
	if (type == 'watch'){
		$('watch').checked = 'yes';
	}
	if(me!=null){
	  var myObj = new javraAJAX(cgipath+'x/xepstwfillvalue.p','post',{parameters: "prjval="+ me + "&type=" + type + "&status=" + status });
 	  myObj.sendData();

  }

}


/* reflect search panel according to the project context */
var f_reflectwithsearchpanel = function  (handler,params){
	var arrParam = params.split(',');
	var type = arrParam[0];
	var status = arrParam[1];

	if (status == 'srtype' ){
		var srtype = document.getElementById('cmbsrtype');
		 switch(type)
		{
		case 'bug':
		  srtype.selectedIndex = 0;
		  break;
		case 'task':
		  srtype.selectedIndex = 1;
		  break;
		case 'fr':
		  srtype.selectedIndex = 2;
		  break;
		case 'cr':
		  srtype.selectedIndex = 3;
		  break;
		case 'support':
		  srtype.selectedIndex = 4;
		  break;

		}

	}

	if (status == 'status' ){
		var srstatus = document.getElementById('cmbstatus');
		 switch(type)
		{
		case 'new':
		  srstatus.selectedIndex = 0;
		  break;
		case 'open':
		  srstatus.selectedIndex = 1;
		  break;
		case 'wait':
		  srstatus.selectedIndex = 2;
		  break;
		case 'resol':
		  srstatus.selectedIndex = 5;
		  break;
		case 'progress':
		  srstatus.selectedIndex = 4;
		  break;

		}
	}

	if (status == 'priority' ){
		var srprior = document.getElementById('cmbprior');
		 switch(type)
		{
		case 'noptr':
		  srprior.selectedIndex = 0;
		  break;
		case 'low':
		  srprior.selectedIndex = 1;
		  break;
		case 'medium':
		  srprior.selectedIndex = 2;
		  break;
		case 'high':
		  srprior.selectedIndex = 3;
		  break;
		case 'urgent':
		  srprior.selectedIndex = 4;
		  break;

		}
	}

   if (status == 'resolvedby'){
	   var cmbstatus=$('cmbstatus');
	   for (var i=0; i<cmbstatus.options.length;i++){
	 		cmbstatus.options[i].selected = true;
		 }
   }

   if ((status !='status') && (type != 'watch') && (status != 'resolvedby')){
	   var cmbstatus=$('cmbstatus');
	   for (var i=0; i<cmbstatus.options.length;i++){
		 	if (cmbstatus.options[i].value != '8000')
		 		cmbstatus.options[i].selected = true;
		 }
   }
   handler&&handler();
}

function f_search_filled(me,cgipath,type,status){
  if (type == 'watch') {
      window.top.frames[1].frames[0].f_backfill2(me,cgipath,type,status);
	  window.top.frames[1].frames[0].show_r1(me);
  }
  else{
  parent.frames['left_frame'].f_backfill2(me,cgipath,type,status);
  parent.frames['left_frame'].show_r1(1);
  parent.parent.frames['header'].document.getElementById('btn_xpren').value= me;
  }
  }

function f_fillsearch(me,cgipath){
	parent.frames['left_frame'].f_backfill(me,cgipath);
	parent.frames['left_frame'].show_r1(1);
}
  /*add sr */
  var cgiPath;
function f_trackSubmitsradd(cgiPath){

if ($('oversize').value == 'oversize'){
    $("errtd").innerHTML="<span class='error'>* " + erroversize +"</span>";
  }
 }

function f_opensrdetail(){
	window.location.href= cgipath +'x/xpstwsrdetail.p?srid=' + srid + '&pagestat=noupdate';
}

function f_callsearchfillup(srid,cgipath){
parent.parent.frames['left_frame'].f_backfill(srid,cgipath);

}

// Added by Pushpendra
// start of common functions
function f_closepopupwindow(event){;
	window.close();
	opener.f_redirect();
}


function f_closeajaxpopup(){;
	//alert(event);
	parent.Windows.close('win2', gevent);
	parent.f_redirect();
	gevent=null;
}

function f_cancelPopup(event){
	parent.Windows.close("win2", event)
}
// Added by Pushpendra
// end of common fucntions


// Added by -Pushpendra
// start of functions for adding/editing/deleting affected/fixed versions
function confirm_affversion_delete() {
	var srid=$('srid').value;
	return confirm("Are you sure to delete the affected/fixed version  of SR '" + srid + "'?");
}
function f_add_affversion(cgipath,srid){
myWindow=window.open(cgipath + 'x/xpstwmanageaffversions.p?srid=' +srid,'','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
myWindow.focus()

}
function f_edit_affversion(cgipath,srid,affvid){
myWindow=window.open(cgipath + 'x/xpstwmanageaffversions.p?pagestat=update&srid=' + srid + '&affvid=' + affvid ,'','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
myWindow.focus()

}

function f_validateaffversion()
{
  var err="no";
  $("errlabel").innerHTML="";
  if ($('cmb_version').value==0){
  $("errlabel").innerHTML="<span class='error'>" + lreqfield +"</span>";
  err="yes";
  }
  return (err=="no");
}

function f_saveaffversion(cgipath,mode){
	var srid=$('srid').value;
	var vid=$('cmb_version').value;
	var affvid=$('affvid').value;
	var myurl = cgipath + 'x/xpstwcommitaffversions.p';
	if (mode=="create") {
		var params = 'srid=' + srid + '&mode=' + mode + '&vid=' + vid  ;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
    	myObj.sendData();
		$('btnadd').onclick = function(){};
	}
	if (mode=="update") {
		var params = 'srid=' + srid + '&mode=' + mode + '&vid=' + vid + '&affvid=' + affvid  ;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
    	myObj.sendData();
		$('btnupdate').onclick = function(){};
	}
	if (mode=="delete") {
		var params = 'srid=' + srid + '&mode=' + mode + '&affvid=' + affvid  + '&vid=' + vid  ;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
    	myObj.sendData();
	}

}

function f_duplicateaffversion(){
	$("errlabel").innerHTML="<span class='error'>" + lduplicateaffrec +"</span>";
}
// Added by -Pushpendra
// end of functions for adding/editing/deleting affected/fixed versions

// Added by -Pushpendra
// start of functions for adding/editing/deleting linked srs
function f_clearproject(){
	$('cmb_linkedsrs').length=0;
		$('txt_srtitle').value="";
	var y=document.createElement('option');
	y.text='-----Please Select-----';
	y.value='0';
	var x=document.getElementById("cmb_linkedsrs");
	try
	  {
	  x.add(y,null); // standards compliant
	  }
	catch(ex)
	  {
	  x.add(y); // IE only
	  }
}

function confirm_linkedsrs_delete() {
	var srid=$('srid').value;
	return confirm("Are you sure to delete the linked sr  of SR '" + srid + "'?");
}
function f_add_linkedsrs(cgipath,srid){
myWindow=window.open(cgipath + 'x/xpstwmanagelinkedsrs.p?srid=' +srid,'','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
myWindow.focus()

}
function f_edit_linkedsrs(cgipath,srid,lsrid,lid){
myWindow=window.open(cgipath + 'x/xpstwmanagelinkedsrs.p?pagestat=update&srid=' + srid + '&lsrid=' + lsrid + '&lid=' + lid ,'','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
myWindow.focus()

}

function f_validatelinkedsrs ()
{
  var err="no";
  $("errlabel").innerHTML="";
  if ($('cmb_project').value==0){
  $("errlabel").innerHTML="<span class='error'>" + lreqproject +"</span>";
  $('cmb_project').focus();
  err="yes";
  return;
  }
  if ($('cmb_linkedsrs').value==0){
  $("errlabel").innerHTML="<span class='error'>" + lreqlinkedsrs +"</span>";
  $('cmb_linkedsrs').focus();
  err="yes";
  return;
  }
  if ($('txt_desc').value.length==0){
  $("errlabel").innerHTML="<span class='error'>" + lreqdesc +"</span>";
  $('txt_desc').focus();
  err="yes";
  return;
  }
  return (err=="no");
}
var globevent;//Global event variable used for storing previous event handler

function f_savelinkedsrs(cgipath,mode){
	var srid=$('srid').value;
	var lsrid=$('cmb_linkedsrs').value;
	var lsrdesc=$('txt_desc').value;
	var lid=$('lid').value;
	var myurl = cgipath + 'x/xpstwcommitlinkedsrs.p';
	if (mode=="create") {
		var params = 'srid=' + srid + '&mode=' + mode + '&lsrid=' + lsrid + '&lsrdesc=' + encodeURIComponent(lsrdesc)  ;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
		globevent=$("btnadd").onclick;
		$("btnadd").onclick=function(){};
    	myObj.sendData();

	}
	if (mode=="update") {
		var params = 'srid=' + srid + '&mode=' + mode + '&lsrid=' + lsrid + '&lsrdesc=' + encodeURIComponent(lsrdesc) + '&lid=' + lid;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
		globevent=$("btnupdate").onclick;
		$("btnupdate").onclick=function(){};
    	myObj.sendData();
	}
	if (mode=="delete") {
		var params = 'srid=' + srid + '&mode=' + mode + '&lid=' + lid  ;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
    	myObj.sendData();
	}

}
function f_duplicatelinkedsrs(){
	if($("btnadd"))$("btnadd").onclick=globevent;
	if($("btnupdate"))$("btnupdate").onclick=globevent;
	$("errlabel").innerHTML="<span class='error'>" + lduplicatelinkedsrs +"</span>";
}

function f_viewlinkedsrs(cgipath,lsrid){
	document.location.href=cgipath + 'x/xpstwsrdetail.p?srid=' + lsrid;

}
function f_viewsr(cgipath,srid){
	window.location.href=cgipath + 'x/xpstwsrdetail.p?srid=' + srid;
}
function f_populatelinkedsrs(mode,cgipath){
    $("errlabel").innerHTML="";
	var srid=$('srid').value;
	var lid=$('lid').value;
	var pid=$('cmb_project').value;
	if (mode == "update")
		return;
    if (pid == 0 ) {
		$("errlabel").innerHTML=$("errlabel").innerHTML="<span class='error'>" + lreqproject +"</span>";
	}
    if (pid != 0 && lid) {
        var myurl = cgipath + 'x/xpstwpopulatelinkedsrs.p';

        var myObj = new javraAJAX(myurl, 'post', {
            parameters: 'pid=' + pid + '&srid=' + srid
        });
        myObj.sendData();
    }
}
// start of comment  management functions
function f_validatecomment(commentid)
{
  var err="no";
  $("errcomment" + commentid).innerHTML="";
  if ($('txtcomment' + commentid).value==0){
  $("errcomment" + commentid).innerHTML="<span class='error'>" + lreqcomment +"</span>";
  err="yes";
  }
  return (err=="no");
}

function f_updatecomment(cgipath,xsrcn,commentid,intusr){
	var srid=$('srid').value;
	var comment=$('txtcomment' + commentid).value;
	var visibility ='pub';
	if (intusr =='yes'){
		if($('visibility1'+ commentid).checked)
			visibility = $('visibility1' + commentid).value;
		else
			visibility = $('visibility2' + commentid).value;
	}
	var mode = 'update';
	var myurl = cgipath + 'x/xpstwcommitcomments.p';
	var params = 'srid=' + srid + '&xsrcn=' + xsrcn + '&mode=' + mode + '&comment=' + encodeURIComponent(comment) + '&visibility=' + visibility + '&commentid=' + commentid;
	var myObj = new javraAJAX (myurl, 'post', {
	parameters: params
	});
	globevent=$("btn_update").onclick;
	$("btn_update").onclick=function(){};
	myObj.sendData();

}

function f_deletecomment(cgipath,xsrcn,commentid){
    var srid  = $('srid').value;
    if (confirm("Are you sure to delete the comment  of SR '" + srid + "'?")){
	var mode = 'delete';
	var myurl = cgipath + 'x/xpstwcommitcomments.p';
	var params = 'srid=' + srid + '&xsrcn=' + xsrcn + '&mode=' + mode + '&commentid=' + commentid;
	var myObj = new javraAJAX (myurl, 'post', {
	parameters: params
	});
	myObj.sendData();
	}
}

var globComment;
function f_addcomment(cgipath,intusr){
	var srid=$('srid').value;
	var comment=$('txtcomment').value;
	var visibility = 'pub';
	if (intusr =='yes')
	{
		if(document.getElementById("visibility1").checked)
			visibility = $('visibility1').value;
		else
			visibility = $('visibility2').value;
	}
	var mode = 'create';
	var myurl = cgipath + 'x/xpstwcommitcomments.p';
	var params = 'srid=' + srid + '&mode=' + mode + '&comment=' + encodeURIComponent(comment) + '&visibility=' + visibility  ;
	var myObj = new javraAJAX (myurl, 'post', {
	parameters: params
	});
	globComment=comment;
	globevent=$("btnadd").onclick;
	$("btnadd").onclick=function(){};
	myObj.sendData();
}

var f_add_comment_row = function (handler, params){
	
	var tmpparams=params.split(",");
	var tmplabel="";
	var xscrn  = tmpparams[0];
	var user  = tmpparams[1];
	var cdate  = tmpparams[2];
	var internal  = tmpparams[3];
	var vhost  = tmpparams[4];
	$("btnadd").onclick=globevent;
    var varradio1="checked=checked";
	var varradio2="";
	if(internal=="yes"){
		tmplabel=linternal;
		varradio1="";
		varradio2="checked=checked";
	}
	document.getElementById("top_date").innerHTML=cdate;
	document.getElementById("top_user").innerHTML=user;

	if(document.getElementById("tblcomment"))document.getElementById("tblcomment").style.display="none";
	var divcontainer=document.getElementById("div_comments");
	var rowcount=parseInt(document.getElementById("new_comment_id").value)+1;

	 var varvisibility="<b>Comment Visibility</b>Public <input name=\"visibility"+rowcount+"\" id=\"visibility1" +rowcount+"\" type=\"radio\"   value=\"pub\" "+varradio1+" />Internal Only<input name=\"visibility" +rowcount+"\" type=\"radio\"  id=\"visibility2" +rowcount+"\" value=\"int\" "+varradio2+ " />";

	if (vhost=="no")
	   varvisibility="";
	divcontainer.innerHTML='<div class="sr_div bgwhite" id="divparent_'+rowcount+'"><table cellpadding="0" cellspacing="0" width="100%" border="0"><tr><td colspan="2" class="border_top" height="8"></td></tr><tr><td width="97%"><strong><span id="spanuser_'+rowcount+'">'+user+'</span>, <span id="spandate_'+rowcount+'">'+cdate+'</span> &nbsp;<span id="linternal_'+rowcount+'">'+tmplabel+'</span></strong><br/><div id="comment_'+rowcount+'"></div><div id="divtxt_'+rowcount+'" style="display:none;"><div id="errcomment'+rowcount+'"></div><textarea id="txtcomment'+rowcount+'" rows="12"  class="text_area1" style="height: 120px;width:100%"  onkeypress="msgs.adjustTextarea(this, 120)" oninput="msgs.adjustTextarea(this, 120)" onbeforepaste="msgs.adjustTextarea(this, 120)" autocomplete="off"></textarea><br /> '+varvisibility+' <input type="button" id="btn_update" class="button_bg_inp" value=\''+lsave+'\' onclick=" f_validatecomment(\''+rowcount+'\') && f_updatecomment(\''+cgipath+'\',\''+xscrn+'\',\''+rowcount+'\',\''+vhost+'\');" />&nbsp;<input type="button" id="btn_cancel" value=\''+lcancel+'\'  class="button_bg_inp" onclick="f_hidecomment(\''+rowcount+'\');"  /></div></td><td id="td_icon_'+rowcount+'" valign="top" style="visibility:visible;"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" style="border-bottom:0px;"><img src="/web-xepst/image/edit.gif"  onclick="f_showcomment(\''+rowcount+'\');" style="display:block;" alt="" /></td><td align="center" style="border-bottom:0px;width:20px;"><img src="/web-xepst/image/trash.gif" onclick="f_deletecomment(\''+cgipath+'\',\'' + xscrn+ '\',\'' + rowcount+'\');" style="display:block;" alt=""/></td></tr></table></td></tr><tr><td colspan="2" class="commentseparator">&nbsp;&nbsp;</td></tr></table></div>'+divcontainer.innerHTML;
	document.getElementById("new_comment_id").value=rowcount;
	document.getElementById('frmaddcomments').reset();
	document.getElementById('tbleditcomments').style.display='none';
	document.getElementById('comment_'+rowcount).innerHTML=globComment.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r\n|\r|\n/g,"<br>");

}

var f_update_comment_row = function (handler,params){	var tmplabel="";
	var tmplabel="";
	$('btn_update').onclick=globevent;
	var arrparam=params.split(",");
	document.getElementById("spandate_"+arrparam[0]).innerHTML=arrparam[1];
	document.getElementById('comment_'+arrparam[0]).innerHTML=document.getElementById('txtcomment'+arrparam[0]).value.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r\n|\r|\n/g,"<br>");
	if (arrparam[3] =="yes") {
		tmplabel=linternal;
		document.getElementById('visibility2'+arrparam[0].checked);
		$('linternal_'+arrparam[0]).innerHTML=tmplabel;
	}
	else{
		document.getElementById('visibility1'+arrparam[0].checked);
		$('linternal_'+arrparam[0]).innerHTML=tmplabel;
	}
	$('spanuser_'+arrparam[0]).innerHTML = arrparam[2];
 	f_hidecomment(arrparam[0]);
	document.getElementById("top_date").innerHTML=arrparam[1];
	document.getElementById("top_user").innerHTML=arrparam[2];

}
var f_remove_comment_row = function (handler,params){
	var arrparam=params.split(",");
	document.getElementById("top_date").innerHTML=arrparam[1];
	document.getElementById("top_user").innerHTML=arrparam[3];
	var a=document.getElementById("divparent_"+ arrparam[0]);
	if(a){
		(a.parentNode).removeChild(a);
	}
	if (arrparam[2] == 'no'){
    	document.getElementById('tblcomment').style.display='block';
	}
}

function f_hidecomment(vari){
$("errcomment" + vari).innerHTML="";
document.getElementById('divtxt_'+vari).style.display='none';
document.getElementById('comment_'+vari).style.display='block';
document.getElementById('td_icon_'+vari).style.visibility='visible';

}

function f_showcomment(vari){
document.getElementById('divtxt_'+vari).style.display='block';
document.getElementById('comment_'+vari).style.display='none';
window.setTimeout("document.getElementById('txtcomment"+vari+"').focus();",10);
document.getElementById('txtcomment'+vari).value=document.getElementById('comment_'+vari).innerHTML.replace(/<br>/g,"\n").replace(/<BR>/g,"\n").replace(/<BR>/g,"\n").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">");
document.getElementById('td_icon_'+vari).style.visibility='hidden';
}
// end of comment  management functions

// Added by -Pushpendra
// end of functions for adding/editing/deleting linked srs

// Added by -Pushpendra
// start of functions for adding/editing/deleting changed list

function f_validatechangelistextension(){

	var filePath=$('file_prog').value;
	//alert(filePath);
	var ext = filePath.substring(filePath.lastIndexOf('.')+1).toLowerCase();
	$("errlabel").innerHTML="";
	//alert(ext);
	if((ext!='p') && (ext !='xml')){
/*	$('cmb_ftype').value='0'; */
	$("errlabel").innerHTML="<span class='error'>" + lfileexterror +"</span>";
	return false;
	}
/*	if (ext == 'p')
	$('cmb_ftype').value='.p file';
	else
	$('cmb_ftype').value='xml'; */
	return true;
}

function confirm_changelist_delete(srid) {
	return confirm("Are you sure to delete the changed list  of SR '" + srid + "'?");
}
function f_add_changelist(cgipath,srid){
myWindow=window.open(cgipath + 'x/xpstwmanagechangelist.p?srid=' +srid,'','width=850,height=500','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
myWindow.focus()

}
function f_edit_changelist(cgipath,srid,clid){
myWindow=window.open(cgipath + 'x/xpstwmanagechangelist.p?pagestat=update&srid=' + srid + '&clid=' + clid ,'','width=850,height=500','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
myWindow.focus()

}

function f_validatechangelist()
{
  var err="no";
  $("errlabel").innerHTML="";
  if ($('file_prog').value==0){
  $("errlabel").innerHTML="<span class='error'>" + lreqfile +"</span>";
  err="yes";
  return;
  }
  if ($('txt_summary').value==0){
  $("errlabel").innerHTML="<span class='error'>" + lreqsummary +"</span>";
  err="yes";
  return;
  }
  if ($('chlistref').value.length > 20){
  $("errlabel").innerHTML="<span class='error'>" + lchlistref +"</span>";
  err="yes";
  return;
  }
  return (err=="no");
}
function f_savechangelist(cgipath,mode){
	var srid=$('srid').value;
	var file=$('file_prog').value;
	var summary=$('txt_summary').value;
	var chlistref=$('chlistref').value;
	var changedate=$('changedate').value;
	var clid=$('clid').value;
	var myurl = cgipath + 'x/xpstwcommitchangelist.p';

	if (mode=="create") {
		var params = 'srid=' + srid + '&mode=' + mode + '&file=' + encodeURIComponent(file) + '&summary=' + encodeURIComponent(summary) + '&chlistref=' + chlistref + '&changedate=' + changedate;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
    	myObj.sendData();
		$('btnadd').onclick = function(){};
	}
	if (mode=="update") {
		var params = 'srid=' + srid + '&clid=' + clid + '&mode=' + mode + '&file=' + encodeURIComponent(file) + '&summary=' + encodeURIComponent(summary) + '&chlistref=' + chlistref + '&changedate=' + changedate;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});

    	myObj.sendData();
	    $('btnupdate').onclick = function(){};
	}
}
function f_deletechangelist(cgipath,srid,clid){
	var myurl = cgipath + 'x/xpstwcommitchangelist.p';
	var params = 'mode=delete&srid=' + srid + '&clid=' + clid  ;
	var myObj = new javraAJAX (myurl, 'post', {
    parameters: params
    });
    myObj.sendData();
}


// Added by -Pushpendra
// end of functions for adding/editing/deleting changed list


// Added by -Pushpendra
// start of functions for adding/editing/deleting attachement

function f_add_attachment(cgipath,srid){
//myWindow=window.open(cgipath + 'x/xpstwmanageattachment.p?srid=' +srid,'','width=500,height=300','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
//myWindow.focus()
win2(cgipath + 'x/xpstwmanageattachment.p?srid=' +srid,500,290,"Add Attachment");
return false;
}

function win2(vurl,vwidth,vheight,vtitle)
{
  var win = new Window({id: "win2", className: "dialog", title: vtitle, width:vwidth, height:vheight, url:vurl,minimizable: false,maximizable: false});
  //win.getContent().innerHTML = "<h1>Constraint inside page !!</h1>constraint: {top: 30, bottom:10}<br><a href='#' onclick='Windows.getWindow(\"win2\").maximize()'>Maximize me</a>";

  win.setDestroyOnClose();
  win.showCenter(true);
  //win.setConstraint(true, {left:0, right:0, top: 0, bottom:0})
  win.toFront();

}

function windiv(divid)
{
  var win = new Window({id: "win3", className: "dialog", title: "", width:500, height:290, wiredDrag: true,minimizable: false,maximizable: false});

  win.getContent().innerHTML = document.getElementById(divid).innerHTML;

  win.setDestroyOnClose();
  win.showCenter(true);
  win.toFront();

}

function f_edit_attachment(cgipath,srid,aid){
//myWindow=window.open(cgipath + 'x/xpstwmanageattachment.p?pagestat=update&srid=' + srid + '&aid=' + aid ,'','width=500,height=300','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
//myWindow.focus()
win2(cgipath + 'x/xpstwmanageattachment.p?pagestat=update&srid=' + srid + '&aid=' + aid,500,290,"Edit Attachment");
return false;
}
function f_validateattachment(){
  var err="no";
  $("errlabel").innerHTML="";
  if($('aid').value == 0 ){
	  if ($('file_prog').value==0){
	  $("errlabel").innerHTML="<span class='error'>" + lreqfile +"</span>";
	  err="yes";
	  return;
	  }
  }
  return (err=="no");
}

var gevent;
function f_saveattachment(cgipath,event){
	var mode=$('mode').value;
	var file=document.getElementById('file_prog').value;
	if (mode=="create"){
	$('frm_attachment').action=cgipath + 'x/xpstwmanageattachment.p';
	$('frm_attachment').submit();

	$('btnadd').onclick=function(){};
	}
	if (mode=="update") {
		gevent=event
		var srid=$('srid').value;
		var desc=$('txt_desc').value;
		var aid=$('aid').value;
		var myurl = cgipath + 'x/xpstwcommitattachment.p';
		var params = 'srid=' + srid + '&aid=' + aid + '&mode=' + mode + '&desc=' + encodeURIComponent(desc)  ;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
		globevent=$("btnadd").onclick;
     	$("btnadd").onclick=function(){};
    	myObj.sendData();

	}
}
function f_deleteattachment(cgipath,srid,aid){
	var myurl = cgipath + 'x/xpstwcommitattachment.p';
	var params = 'mode=delete&srid=' + srid + '&aid=' + aid  ;
	var myObj = new javraAJAX (myurl, 'post', {
    parameters: params
    });
    myObj.sendData();
}
function confirm_attachment_delete(file) {
	return confirm("Are you sure to delete the '" + file + "'?");
}

function f_closeWindow(event){

  if (closepopup == "yes" )
  	f_closeajaxpopup(event);
if (closepopup == "no" ){
 if (errortype == "file")
 	$("errlabel").innerHTML="<span class='error'>" + lfsizeinvalid +"</span>";
 if (errortype == "upload")
 	$("errlabel").innerHTML="<span class='error'>" + luploadfailed +"</span>";

if (errortype == "srclosed")
 	$("errlabel").innerHTML="<span class='error'>" + lsrclosederror +"</span>";

}
}

function f_filedelerror(){
	$("errattach").innerHTML="<span class='error'>" + lfiledelerror +"</span>";
}
function f_srclosederror(){
	$("btnadd").onclick=globevent;
	$("errlabel").innerHTML="<span class='error'>" + lsrclosederror +"</span>";


}

// Added by -Pushpendra
// end of functions for adding/editing/deleting attachement

// Added by -Pushpendra
// start of functions for adding/editing/deleting project versions
function confirm_projversion_delete(pid) {
	return confirm("Are you sure to delete the version  of Project '" + pid + "'?");
}
function f_add_projversion(cgipath,pid){
//myWindow=window.open(cgipath + 'x/xpstwmanageprojversion.p?pid=' + pid,'','width=505,height=295','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
//myWindow.focus()
var v_url=cgipath + 'x/xpstwmanageprojversion.p?pid=' + pid;
win2(v_url,505,286,"Add Project Version");
return false;
}
function f_edit_projversion(cgipath,pid,vid){
//myWindow=window.open(cgipath + 'x/xpstwmanageprojversion.p?pagestat=update&pid=' + pid + '&vid=' + vid ,'','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
//myWindow.focus()
var v_url=cgipath + 'x/xpstwmanageprojversion.p?pagestat=update&pid=' + pid + '&vid=' + vid;
win2(v_url,505,286,"Edit Project Version");
return false;
}
function f_validateverstatus(cgi){
	var myurl = cgi + 'x/xpstwvalidateverstatus.p';
	var xstac = $('cmbverstat').value;
	var xprvn = $('vid').value;
	var params = 'xstac=' + xstac + '&xprvn=' + xprvn;
	var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
    myObj.sendData();
}
var f_versionprompt = function (handler, params){
	var arrParam = params.split(',');
	var statustrack = arrParam[0];
	var current = arrParam[1];
	var next = arrParam[2];
	var status = arrParam[3];

	if (statustrack == '')
		$('stattrack').value ='';

	if (statustrack =='currentexist'){
			if (confirm("Version" + current + " is already the Current Release, if you continue it's status will be changed to Released. Continue?")){
		    	$('stattrack').value = statustrack;
			}
			else{
				$('cmbverstat').value = status;
				$('stattrack').value ='';
			}

	}

	if (statustrack =='nextncurrentexist'){
			if (confirm(next + " is Next Release, and " + current + " is Current Release, if you continue then " + current + " will be set to Released and " + next + " will be set to Current?")){
		    	$('stattrack').value = statustrack;
			}
			else{
				$('cmbverstat').value = status;
				$('stattrack').value ='';
			}
	}

		if (statustrack =='nextexist'){
			if (confirm("Version " + next + " is already the Next Release, if you continue it's status will be changed to Current Released. Continue?")){
		    	$('stattrack').value = statustrack;
			}
			else {
				$('cmbverstat').value = status;
				$('stattrack').value ='';
			}
	}
}
function f_validateprojversion()
{
  var err="no";
  $("errlabel").innerHTML="";
  if ($('txt_version').value==0){
  $("errlabel").innerHTML="<span class='error'>" + lreqversion +"</span>";
  err="yes";
  return;
  }
  return (err=="no");
}
function f_saveprojversion(cgipath,mode){
	var pid=$('pid').value;
	var version=$('txt_version').value;
	var desc=$('txt_desc').value;
	var vid=$('vid').value;
	var release=$('reldate').value;
	var status=$('cmbverstat').value;
	var stattrack=$('stattrack').value;

	var myurl = cgipath + 'x/xpstwcommitprojversion.p';
	if (mode=="create") {
		var params = 'pid=' + pid + '&mode=' + mode + '&version=' + version + '&desc=' + encodeURIComponent(desc) + '&release=' + release + '&status=' + status  ;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
		globevent=$("btnadd").onclick;
		$("btnadd").onclick=function(){};

    	myObj.sendData();
	}
	if (mode=="update") {
		var params = 'pid=' + pid + '&vid=' + vid + '&mode=' + mode + '&version=' + version + '&desc=' + encodeURIComponent(desc) + '&release=' + release + '&status=' + status + '&stattrack=' + stattrack ;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
		globevent=$("btnupdate").onclick;
		$("btnupdate").onclick=function(){};

    	myObj.sendData();
	}
}
function f_deleteprojversion(cgipath,pid,vid){
	var myurl = cgipath + 'x/xpstwcommitprojversion.p';
	var params = 'mode=delete&pid=' + pid + '&vid=' + vid  ;
	var myObj = new javraAJAX (myurl, 'post', {
    parameters: params
    });
    myObj.sendData();
}
function f_duplicateprojversion(){
	if($("btnadd"))$("btnadd").onclick=globevent;
	if($("btnupdate"))$("btnupdate").onclick=globevent;
	$("errlabel").innerHTML="<span class='error'>" + lduplicateprojversion +"</span>";
}
function f_invalidversionmask(){
	if($("btnadd"))$("btnadd").onclick=globevent;
	if($("btnupdate"))$("btnupdate").onclick=globevent;
	$("errlabel").innerHTML="<span class='error'>" + linvalidversionmask +"</span>";
}

// Added by -Pushpendra
// end of functions for adding/editing/deleting project versions


// Added by -Pushpendra
// start of functions for adding/editing/deleting project modules
function confirm_projmodule_delete(pid) {
	return confirm("Are you sure to delete the module  of Project '" + pid + "'?");
}
function f_add_projmodule(cgipath,pid){
	//myWindow=window.open(cgipath + 'x/xpstwmanageprojmodule.p?pid=' + pid,'','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
	//myWindow.focus()
	var v_url=cgipath + 'x/xpstwmanageprojmodule.p?pid=' + pid;
	win2(v_url,505,260,"Add Project Module");
	return false;
}
function f_edit_projmodule(cgipath,pid,mid){
	//myWindow=window.open(cgipath + 'x/xpstwmanageprojmodule.p?pagestat=update&pid=' + pid + '&mid=' + mid ,'','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
	//myWindow.focus()
	var v_url=cgipath + 'x/xpstwmanageprojmodule.p?pagestat=update&pid=' + pid + '&mid=' + mid;
	win2(v_url,505,260,"Edit Project Module");
	return false;
}

function f_validateprojmodule()
{
  var err="no";
  $("errlabel").innerHTML="";
  if ($('txt_module').value==0){
  $("errlabel").innerHTML="<span class='error'>" + lreqmodule +"</span>";
  err="yes";
  return;
  }
  return (err=="no");
}
function f_saveprojmodule(cgipath,mode){
	var pid=$('pid').value;
	var module=$('txt_module').value;
	var desc=$('txt_desc').value;
	var mid=$('mid').value;
	var myurl = cgipath + 'x/xpstwcommitprojmodule.p';
	if (mode=="create") {
		var params = 'pid=' + pid + '&mode=' + mode + '&module=' + encodeURIComponent(module) + '&desc=' + encodeURIComponent(desc)  ;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
		globevent=$("btnadd").onclick;
		$("btnadd").onclick=function(){};
    	myObj.sendData();
	}
	if (mode=="update") {
		var params = 'pid=' + pid + '&mid=' + mid + '&mode=' + mode + '&module=' + encodeURIComponent(module) + '&desc=' + encodeURIComponent(desc)  ;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
		globevent=$("btnupdate").onclick;
		$("btnupdate").onclick=function(){};
    	myObj.sendData();
	}
}
function f_deleteprojmodule(cgipath,pid,mid){
	var myurl = cgipath + 'x/xpstwcommitprojmodule.p';
	var params = 'mode=delete&pid=' + pid + '&mid=' + mid  ;
	var myObj = new javraAJAX (myurl, 'post', {
    parameters: params
    });
    myObj.sendData();
}
function f_duplicateprojmodule(){
	if($("btnadd"))$("btnadd").onclick=globevent;
	if($("btnupdate"))$("btnupdate").onclick=globevent;
	$("errlabel").innerHTML="<span class='error'>" + lduplicateprojmodule +"</span>";
}

// Added by -Pushpendra
// end of functions for adding/editing/deleting project modules

// Added by -Pushpendra
// start of function for adding/editing/deleting team members.

function confirm_teammember_delete(pid) {
	return confirm("Are you sure to delete the team member  of Project '" + pid + "'?");
}

function f_add_teammember(cgipath,pid){
//	myWindow=window.open(cgipath + 'x/xpstwmanageprojteam.p?pid=' + pid,'','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
//	myWindow.focus()
	var v_url=cgipath + 'x/xpstwmanageprojteam.p?pid=' + pid;
	win2(v_url,505,150,"Add Team Member");
	return false;
}

function f_edit_teammember(cgipath,pid,user,role){
	//myWindow=window.open(cgipath + 'x/xpstwmanageprojteam.p?pagestat=update&pid=' + pid + '&user=' + user+ '&role=' + role ,'','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
	//myWindow.focus()
	var v_url=cgipath + 'x/xpstwmanageprojteam.p?pagestat=update&pid=' + pid + '&user=' + user+ '&role=' + role;
	win2(v_url,505,150,"Edit Team Member");
	return false;

}

function f_validateteammember()
{
  var err="no";
  $("errlabel").innerHTML="";
  if ($('cmb_user').value==0){
  $("errlabel").innerHTML="<span class='error'>" + lrequser +"</span>";
  err="yes";
  return;
  }

  if ($('cmb_role').value==0){
  $("errlabel").innerHTML="<span class='error'>" + lreqrole +"</span>";
  err="yes";
  return;
  }

  return (err=="no");
}
function f_saveteammember(cgipath,mode){
	var pid=$('pid').value;
	var ouser=$('user').value;
	var orole=$('role').value;
	var user=$('cmb_user').value;
	var role=$('cmb_role').value;
	var defassignee;
	if ($('defassignee').checked ==  true )
    	defassignee='yes';
	else
	    defassignee='no';

	var myurl = cgipath + 'x/xpstwcommitprojteam.p';
	if (mode=="create") {
		var params = 'pid=' + pid + '&mode=' + mode + '&user=' + user + '&role=' + role + '&defassignee=' + defassignee;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
		globevent=$("btnadd").onclick;
		$("btnadd").onclick=function(){};
    	myObj.sendData();
	}
	if (mode=="update") {
		var params = 'pid=' + pid + '&mode=' + mode + '&ouser=' + ouser + '&orole=' + orole + '&user=' + user + '&role=' + role + '&defassignee=' + defassignee;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
		globevent=$("btnupdate").onclick;
		$("btnupdate").onclick=function(){};
    	myObj.sendData();
	}
}
function f_deleteteammember(cgipath,pid,user,role){
	var myurl = cgipath + 'x/xpstwcommitprojteam.p';
	var params = 'mode=delete&pid=' + pid + '&user=' + user + '&role=' + role  ;
	var myObj = new javraAJAX (myurl, 'post', {
    parameters: params
    });
    myObj.sendData();
}

function f_duplicateteammember(){
	if($("btnadd"))$("btnadd").onclick=globevent;
	if($("btnupdate"))$("btnupdate").onclick=globevent;
	$("errlabel").innerHTML="<span class='error'>" + lduplicateteammember +"</span>";
}
function f_norole(){
	if($("btnadd"))$("btnadd").onclick=globevent;
	if($("btnupdate"))$("btnupdate").onclick=globevent;
	$("errlabel").innerHTML="<span class='error'>" + lnorole +"</span>";
}

function f_nodefassignee(){
	if($("btnadd"))$("btnadd").onclick=globevent;
	if($("btnupdate"))$("btnupdate").onclick=globevent;
	$("errlabel").innerHTML="<span class='error'>" + lnodefassignee +"</span>";
}

function f_extuser(){
	if($("btnadd"))$("btnadd").onclick=globevent;
	if($("btnupdate"))$("btnupdate").onclick=globevent;
	$("errlabel").innerHTML="<span class='error'>" + lextuser +"</span>";
}
var f_existassign = function(handler,params){
	if($("btnadd"))$("btnadd").onclick=globevent;
	if($("btnupdate"))$("btnupdate").onclick=globevent;
	//alert(params);
	var arrParam = params.split(',');
	var mode=arrParam[0];
	var cdefassignee=arrParam[1];
	var pid=$('pid').value;

	var user=$('cmb_user').value;

	var role=$('cmb_role').value;


	var myurl = cgipath + 'x/xpstwcommitprojteam.p';

	if (confirm("Do you want to change Default Assignee? Current Default Assignee is - " + cdefassignee)) {

		 if (mode=="create") {
		 var param = 'mode=create&changeassigne=yes&defassignee=yes&pid=' + pid + '&user=' + user + '&role=' + role ;
	     var myObj = new javraAJAX (myurl, 'post', {
         parameters: param
		  });
	    myObj.sendData();
		 }

		 if (mode=="update"){
			 var ouser=$('user').value;
			 var orole=$('role').value;
			 var param = 'mode=update&changeassigne=yes&defassignee=yes&pid=' + pid + '&ouser=' + ouser + '&orole=' + orole + 		             '&user=' + user + '&role=' + role ;
	     	 var myObj = new javraAJAX (myurl, 'post', {
         	 parameters: param
		  	 });
	    	 myObj.sendData();
		 }
	 }
	 else {
		$('defassignee').checked = false;
	 }


}
var  f_assigndel = function(handler,params){
     if($("btnadd"))$("btnadd").onclick=globevent;
	 if($("btnupdate"))$("btnupdate").onclick=globevent;
	 if (confirm("SR is assigned to this user. Do You want to Delete?")) {

		 var arrParam = params.split(',');
		 var pid=arrParam[0];
		 var user=arrParam[1];
		 var role=arrParam[2];
		 var myurl = cgipath + 'x/xpstwcommitprojteam.p';
		 var param = 'mode=delete&delpermit=yes&pid=' + pid + '&user=' + user + '&role=' + role ;
	     var myObj = new javraAJAX (myurl, 'post', {
         parameters: param
		  });
	    myObj.sendData();
	 }
	 else
	 	return;
}

var f_redirectnrefresh = function(handler,params){
	if (params == 'yes')
		parent.left_frame.document.location.reload();

	window.location.reload();

}

var f_closepopupwindownrefresh = function(handler,params){

	parent.Windows.close('win2', gevent);
	parent.f_redirect();
	if (params == 'yes')
		parent.parent.left_frame.document.location.reload();
	gevent=null;

}
// Added by -Pushpendra
// end of function for adding/editing/deleting team members.


// Added by -Pushpendra
// start of function for adding/editing/deleting notifications recipients.

function  f_disableuserandroles(){
	$('cmb_user').disabled="disabled";
	$('cmb_usergroup').disabled="disabled";
	$('cmb_projrole').disabled="disabled";
}
function f_displayuser(){
	$('cmb_user').disabled="";
	$('cmb_usergroup').disabled="disabled";
	$('cmb_projrole').disabled="disabled";
}

function f_displayusergroup(){
	$('cmb_user').disabled="disabled";
	$('cmb_usergroup').disabled="";
	$('cmb_projrole').disabled="disabled";
}

function f_displayprojroles(){
	$('cmb_user').disabled="disabled";
	$('cmb_usergroup').disabled="disabled";
	$('cmb_projrole').disabled="";
}

function f_add_recipient(cgipath,pid){
	//myWindow=window.open(cgipath + 'x/xpstwmanagerecipient.p?pid=' + pid,'','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes');
	//myWindow.focus();
	var v_url=cgipath + 'x/xpstwmanagerecipient.p?pid=' + pid;
	win2(v_url,505,248,"Add Recipient");
	return false;
}


var disableplaning = function(handler, params){

	var v_internal = "<tr><td  valign='top'>" + internal + "</td><td colspan='2' valign='top'> <input type='checkbox'id='chkint' class='text_box' name='chkint' value='yes' /></td></tr>";
	var h_internal = "<tr><td  valign='top'>" + internal + "</td><td colspan='2' valign='top'> <input type='checkbox' id='chkint' name='chkint'class='text_box' value='yes' checked='checked' disabled='disabled' /></td></tr>";
	var v_estim ="<tr><td rowspan='2'>" + lestim + "&nbsp;(" + linhours  + ")</td><td><input name='estim' type='text' class='text_box' id='estim'  onkeypress='keypressevent(event);' onblur='blurevent(event);' /></td></tr>";
	var h_planed = "<table><tr><td>" + srplan + "</td><td><input name='srplan' type='text'class='text_box' id='srplan'  onclick= \" displayCalendar(this,'dd/mm/yyyy',this,null,null,null); return false;\"/></td><td></td></tr><tr><td>" + sready+ "</td><td><input name='sready' type='text' class='text_box' id='sready'  onclick= \" displayCalendar(this,'dd/mm/yyyy',this,null,null,null); return false;\"/></td></tr><tr><td>" + duedate + "</td><td> <input name='duedate' type='text' class='text_box' id='duedate' onclick= \"displayCalendar(this,'dd/mm/yyyy',this,null,null,null); return false;\"/></td></tr>";
	var h_worklog = "<tr><td>" + awlog + "</td><td><input type='checkbox'id='worklog' class='text_box' name='worklog' value='yes' checked='checked'/></td></tr>";
	var v_worklog = "<tr><td valign='top'>" + awlog + "</td><td colspan='2' valign='top'><input type='checkbox'id='worklog' class='text_box' name='worklog' value='yes' checked='checked' disabled='disabled' /></td></tr>";
	var h_billable = "<tr><td valign='top' id='errbilla'>" + billable + "</td><td><input type='checkbox' class='text_box' id='billable' name='billable' value='yes'/></td></tr>";
	var h_fixedprz = "<tr><td>" + fixedprice + "</td><td><input name='fixedprice' type='text' class='text_box' id='fixedprice' onkeypress='keypressevent(event);' onblur='blurevent(event);' /></td></tr><tr>&nbsp;</tr>";
	var arrParam=params.split(',');
	var security=arrParam[0];
	var assignee=arrParam[1];

	$('cmbassign').value=assignee;
	$("security").style.display="block";
	if (security =='HCPTL')
	{
	 $('validateworklog').value = 'check';
	 //alert($('validateworklog').value);
	 $("planded").innerHTML= "<table>" + h_planed  + "</table>";
	 $("pricetime").innerHTML= "<table><tr>&nbsp</tr>" + h_fixedprz  + v_estim + "</table>";
	 $("planstatus").innerHTML= "<table>" + h_internal + h_worklog + h_billable + "</table>";
	}
	else if (security =='NHCPTL')
	{
	 $('validateworklog').value = 'check';
	 $("planded").innerHTML= "<table>" + h_planed  + "</table>";
	 $("pricetime").innerHTML= "<table><tr>&nbsp</tr>" + h_fixedprz  + v_estim + "</table>";
	 $("planstatus").innerHTML= "<table>" + v_internal + h_worklog + h_billable + "</table>";
	}
	else if (security == 'HCPTM')
	{
	 $("planded").innerHTML= "";
	 $("pricetime").innerHTML= "<table><tr>&nbsp</tr>" + v_estim + "</table>";
	 $("planstatus").innerHTML= "<table>" + h_internal + v_worklog + "</table>";
	}
  else if (security =='NHCPTM')
  {
   $("planded").innerHTML= "";
   $("pricetime").innerHTML= "<table><tr>&nbsp</tr>" + v_estim + "</table>";
   $("planstatus").innerHTML= "<table>" + v_internal + v_worklog + "</table>";
  }
else
	{
	 $("planded").innerHTML= "";
	 $("pricetime").innerHTML= "";
	 $("planstatus").innerHTML= "";
	 $("security").style.display="none";
	}
}


function f_validaterecipient()
{
  var err="no";
  $("errlabel").innerHTML="";
  if ($('cmb_event').value==0){
  $("errlabel").innerHTML="<span class='error'>" + lreqevent +"</span>";
  err="yes";
  return;
  }
  return (err=="no");
}
function f_saverecipient(cgipath,mode){
	var key = '';
	var pid=$('pid').value;
	var eventname=$('cmb_event').value;

	for (var i=0; i < document.frm_recipient.rad_recipient.length; i++)
   	{
   	if (document.frm_recipient.rad_recipient[i].checked)
      {
      var recipient= document.frm_recipient.rad_recipient[i].value;
      }
   	}

	if (recipient == 'user'){
		key=$('cmb_user').value;

	if (key == ''){
		$("errlabel").innerHTML="<span class='error'>" + lrequser +"</span>";
		return;
		}
	}

    if (recipient == 'projrole'){
		key=$('cmb_projrole').value;
	if (key == ''){
		$("errlabel").innerHTML="<span class='error'>" + lreqrole +"</span>";
		return;
		}
	}

	if (recipient == 'group'){
		key=$('cmb_usergroup').value;
	if (key == ''){
		$("errlabel").innerHTML="<span class='error'>" + lrequsergrp +"</span>";
		return;
		}
	}

	var myurl = cgipath + 'x/xpstwcommitrecipient.p';
	var params = 'pid=' + pid + '&mode=' + mode + '&event=' + eventname + '&key=' + key + '&type=' + recipient  ;

	var myObj = new javraAJAX (myurl, 'post', {
	parameters: params
	});
	globevent=$("btnadd").onclick;
	$("btnadd").onclick=function(){};
	myObj.sendData();
}

function f_deleterecipient(cgipath,pid,rid){
	var myurl = cgipath + 'x/xpstwcommitrecipient.p';
	var params = 'mode=delete&pid=' + pid + '&rid=' + rid  ;
	var myObj = new javraAJAX (myurl, 'post', {
    parameters: params
    });
    myObj.sendData();
}

function confirm_recipient_delete(pid) {
	return confirm("Are you sure to delete the recipient  of Project '" + pid + "'?");
}

function f_duplicaterecipient(){
	$("btnadd").onclick=globevent;
	$("errlabel").innerHTML="<span class='error'>" + lduplicaterecipient +"</span>";
}
// Added by -Pushpendra
// end of function for adding/editing/deleting notifications recipients.


//called by "xpstwprofile.htm"
function f_enable(me){
if ($("recmail").checked)
  {
  $("notupdate").disabled='';
  $("notstatupdate").disabled='';
  $("notreassign").disabled='';
  $("notcommented").disabled='';  
  }
else
  {
    $("notupdate").checked="";
	$("notstatupdate").checked="";
	$("notreassign").checked="";
    $("notcommented").checked="";  
    $("notupdate").disabled='disabled';
	$("notstatupdate").disabled='disabled';
    $("notreassign").disabled='disabled';
	$("notcommented").disabled='disabled';
  }
}

//called by "Reset" button click of "xpstwprofile.htm"
function f_reset(){
	if ($("rec").value=="yes"){
		$("notupdate").disabled='';
  	$("notstatupdate").disabled='';
  	$("notreassign").disabled='';
	}
	else{
		$("notupdate").disabled="disabled='disabled'";
  	$("notstatupdate").disabled="disabled='disabled'";
  	$("notreassign").disabled="disabled='disabled'";
	}
	$("erruname").className="";
	$("erremail").className="";
	$("errlabel").className="";
	$("errmailrec").className="";
	$("errlabel").innerHTML="";
}


/*xpstwnotifymelist.htm*/

function f_watchCloseWindows(cgiPath){
if (redirect=='yes'){
 $("errlabel").innerHTML="<span class='error'>" + updatesuccess +"</span>";
  opener.window.location.reload();
  setTimeout("window.close()",1100);
 }
}

function f_open_notify_add(){
  myWindow=window.open(cgipath + 'x/xpstwnotifymeadd.p?type=frmadd','','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
  myWindow.focus()
}

function f_open_notify_update(){
  myWindow=window.open(cgipath + 'x/xpstwnotifymeadd.p?type=frmupdate','','width=500,height=350','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
  myWindow.focus()
}

function f_update_watchlist(me){
myWindow=window.open(me,'','width=400,height=200','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes');
myWindow.focus()
}
/* start-added by pushpendra
 for tracking hidden variable for storing project id  in order to track if it's coming from project page
 so that that the selected project can be automatically selected in the project combo in sr add page.
*/
function f_addsr(cgipath){
	var xpren =$('btn_xpren').value;

	if (xpren == 0)
		$('a_sr').href=cgipath + 'x/xpstwselectproject.p';
	else
	    $('a_sr').href=cgipath + 'x/xpstwselectproject.p?xpren=' + xpren;

}

function f_selectedproj(cgipath){
	var xpren = $('cmbproj').value;
	document.location.href=cgipath + 'x/xpstwsradd.p?xpren=' + xpren;
}
function f_reset_xpren(){
	$('btn_xpren').value='0';
}

function f_set_xpren(xpren,xprec,frametrack){
	parent.parent.frames['header'].document.getElementById('btn_xpren').value=xpren;
	if (frametrack == 'project')
		parent.frames['left_frame'].document.getElementById('searchSRno').value = xprec;
    if (frametrack == 'search')
		$('searchSRno').value = xprec;

	}

function f_set_xpren_insearch(){

	var xpren =$('comproj').value;
	parent.parent.frames['header'].document.getElementById('btn_xpren').value=xpren;

}
/* end-added by pushpendra */

function f_redirect1(me)
{
 window.location.href= me;
}

/*krishna to add watchlist in xpstwsrdetail.htm*/
function f_confirmsrwatchmsg(){
alert('SR added in your Watch List');
}


function f_company_create(cgipath,c){
	var stat=0;
	var srsummary="no";
	var srstatus ="no";
	var code=$("code").value;
	var cname=$("cname").value;
	var address=$("address").value;
	var city=$("city").value;
	var state=$("state").value;
	var coun=$("coun").value;
	var zip=$("zip").value;
	var phone=$("phone").value;
	var fax=$("fax").value;
	var email=$("email").value;
	var website=$("website").value;
	var contact=$("contact").value;
	var comtyp =$("comtyp").value;
	var comver=$("comver").value;
	var hctype=$("hctype").value;
	 if ($("srsummary").checked)
	     srsummary = "yes";

	 	if ($("srstatus").checked)
	     srstatus = "yes";

	if(code.length==0)	{
		$("errcode").className="error";
		stat=stat+1;
	}
	else{$("errcode").className="";}

	var returnval=emailfilter.test(email)
	if (returnval==false){
		$("erremail").className="error";
		stat=stat+1;
	}
	else{$("erremail").className="";}

	if(coun.length==0)	{
		$("errcountry").className="error";
		stat=stat+1;
	}
	else{$("errcountry").className="";}

	if(comtyp==0)	{
		$("errcomtype").className="error";
		stat=stat+1;
	}
	else{$("errcomtype").className="";}

	if(stat>0)
	{
		$("errlabel").innerHTML="<span class='error'>* " + updateerror + "</span>";
		return false;
	}
	else{
		$("errlabel").innerHTML="";
	//	$('btn_update').disabled=true;
		var clearCache = new Date();
		cgiPath=cgipath;
		var myurl = cgipath + 'x/xpstwcompanyvalidate.p';
		var params='code='+ code + '&address='+ address + '&city='+ city + '&email='+ email + '&phone='+ phone + '&website='+ website + '&contact='+ contact + '&fax=' + fax+ '&zip=' + zip+ '&state=' + state + '&coun=' + coun +'&v_action=add' + '&cname='+ cname +'&comtyp=' + comtyp + '&comver=' + comver + '&srsummary='+ srsummary + '&srstatus='+ srstatus+ '&hctype='+ hctype + '&cache='+ clearCache;
		alert(params);
		var myObj = new javraAJAX(myurl,'get',{parameters: params});
		myObj.sendData();
	}
}

var f_navcompany_new = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td><img src='/web-xepst/image/updated.gif'></td><td>* " + errcreate + "</td></tr></table></span>";
	 opener.window.location.reload();
   setTimeout("window.close()",1100);
}

var f_dupCompany = function(){
	$("errlabel").innerHTML="<span class='error'><table><tr><td></td><td>* " + errduplicate + "</td></tr></table></span>";
}

function f_fillcompanytype(me,cgipath){
	 var pagestat = $('pagestat').value;
	 var code = $('code').value;
	 var param;
	if(me=='HCC')
	  {
		  $('hctype').value="";
		}
	if(me!="0")
	{
	  param ='pagestat='+ pagestat + '&code='+ code + '&type=' + me;
	  var myObj = new javraAJAX(cgipath+'x/xpstwupdatecompanyfilltype.p','post',{parameters: param});
	  myObj.sendData();
	}
}
var f_company_type = function()
{
	 $('hctype').value="";
	 var r=confirm("Host Company already defined ! This action will set existing host company to non-host and may create instability. Proceed ?");
	  if (r==true)
	  {
	  	$('hctype').value='HHC';
	  }
	else
		{
			$('comtyp').value='HCC';
			$('hctype').value="";
		}
}

var f_company_type1 = function()
{
	 $('hctype').value="";
	 var r=confirm("Host Company already defined ! This action will set existing host company to non-host and may create instability. Proceed ?");
	  if (r==true)
	  {
	  	$('hctype').value='HHC';
	  }
	else
		{
			$('comtyp').value='HHC';
			$('hctype').value="";
		}
}
var f_company_type2 = function()
 {
 	 $('hctype').value="";
 }


// Added by -Pushpendra
// start of function for adding/editing/deleting departments.

function confirm_dept_delete(cid) {
	return confirm("Are you sure to delete the department  of Company '" + cid + "'?");
}

function f_add_dept(cgipath,cid){
myWindow=window.open(cgipath + 'x/xpstwmanagedept.p?comp_id=' + cid,'','width=500,height=435','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
myWindow.focus()

}

function f_edit_dept(cgipath,cid,dip){
myWindow=window.open(cgipath + 'x/xpstwmanagedept.p?pagestat=update&comp_id=' + cid + '&dept_id=' + dip ,'','width=500,height=435','directories=yes','titlebar=yes','scrollbars=yes','fullscreen=yes')
myWindow.focus()

}

function f_validatedept()
{
	var err="no";
	var dept=$("dept").value;
	var depname=$("name").value;
	var address=$("address").value;
	var email=$("email").value;

  if(dept.length==0)	{
		$("errdept").className="error";
		err="yes";

	}
	else{$("errdept").className="";}

	if(depname.length==0)	{
		$("errname").className="error";
		err="yes";
	}
	else{$("errname").className="";}

	if(address.length==0)	{
		$("erradd").className="error";
		err="yes";
	}
	else{$("erradd").className="";}

	var returnval=emailfilter.test(email)
	if (returnval==false){
		$("erremail").className="error";
		err="yes";
	}
	else{$("erremail").className="";}

	if(err!="no")
	{
		$("errlabel").innerHTML="<span class='error'>* " + lmandatory + "</span>";
		return;
	}

   return (err=="no");
}
function f_savedept(cgipath,mode){
	var comp_id=$('comp_id').value;
    var name=$('name').value;
	var address=$('address').value;
	var city=$('city').value;
    var zip=$('zip').value;
	var email=$('email').value;
	var tel=$('phone').value;
	var fax=$('fax').value;
	var contact=$('contact').value;
	var desc=$('desc').value;

	var myurl = cgipath + 'x/xpstwcommitdept.p';
	if (mode=="create") {
		var dept=$('dept').value;
		var params = 'comp_id=' + comp_id + '&mode=' + mode + '&dept=' + dept + '&name=' + name + '&address=' + address +
		             '&city=' + city + '&zip=' + zip + '&email=' + email + '&tel=' + tel + '&fax=' + fax + '&contact=' + contact +                     '&desc=' + desc ;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
    	myObj.sendData();
	}
	if (mode=="update") {
		var dept=$('dept_id').value;
		var params = 'comp_id=' + comp_id + '&mode=' + mode + '&dept=' + dept + '&name=' + name + '&address=' + address +
		             '&city=' + city + '&zip=' + zip + '&email=' + email + '&tel=' + tel + '&fax=' + fax + '&contact=' + contact +                     '&desc=' + desc ;
		var myObj = new javraAJAX (myurl, 'post', {
        parameters: params
    	});
    	myObj.sendData();
	}
}
function f_delete_dept(cgipath,cid,dept){
	var myurl = cgipath + 'x/xpstwcommitdept.p';
	var params = 'mode=delete&comp_id=' + cid + '&dept=' + dept ;
	var myObj = new javraAJAX (myurl, 'post', {
    parameters: params
    });
    myObj.sendData();
}

function f_duplicatedept(){
	$("errlabel").innerHTML="<span class='error'>" + lduplicatedept +"</span>";
}


// Added by -Pushpendra

// end of function for adding/editing/deleting departments.

// end of function for adding/editing/deleting departments.

/* validate phone and fax numbers - by pushpendra*/
function f_validate_number(cgipath,number,err,obj){
	document.getElementById(err).innerHTML ="";
	var myurl = cgipath + 'x/xpstwvalidatenumber.p';
	var params = 'number=' + number + '&objectid=' + obj + '&errid=' + err ;
	var myObj = new javraAJAX (myurl, 'post', {
    parameters: params
    });
    myObj.sendData();
}

var f_invalidnumber= function (handler,params){
	var arrParam =params.split(',');
	var errid=arrParam[0];
	var objid=arrParam[1];
	document.getElementById(errid).innerHTML ="<span class='error'>" + linvalidnumber +"</span>";
	document.getElementById(objid).focus();
}

function f_controlLoginMsg(){
    if (invalidlogin == ''){
	if ((url.substring(url.lastIndexOf('login.p') + 7 )) != '' ){
		if((url.substring(url.lastIndexOf('?url=') + 5 ) == '') || (reportprog == '')) {
			$('errid').innerHTML=lplzlogin;
		}
		else if(reportprog != '') {
			$('errid').innerHTML=lplzlogin;
			$('reportprog').value = reportprog;
		}
		else
			$('errid').innerHTML='';
	}
	else
	$('errid').innerHTML='';
	}
}

function populateResolution(cmbval, cgipath){
	var myurl = cgipath + 'x/xpstwpopulateresolution.p';

	var myObj = new javraAJAX(myurl, 'post', {
		parameters: 'srtype=' + cmbval });
	myObj.sendData();

}

function f_displaySRTitle(cmbval, cgipath){
	 var myurl = cgipath + 'x/xpstwdisplaysrtitle.p';
     var myObj = new javraAJAX(myurl, 'post', {
         parameters: 'srid=' + cmbval });
     myObj.sendData();
}

function f_enableproj(cgi){
 	$('projname').disabled = false;
	if ($('statsecurity').value == 'enable' )
		$('pstat').disabled = '';
 	$('desc').disabled = false;
 	$('tech').disabled = false;
 	$('attach').disabled = false;
 	//$('btn_save').style.display = "block";
 	//$('btn_cancel').style.display = "block";
	$('tr_buttons').style.display = "";
//	$('btn_edit').style.display = "none";
 	}
function f_disable_proj(){
    $('form1').reset();
    $('projname').disabled = true;
	if ($('statsecurity').value == 'enable' ){
		$('pstat').disabled = 'disabled';
	}
 	$('desc').disabled = true;
 	$('tech').disabled = true;
 	$('attach').disabled = true;
 	//$('btn_save').style.display = "none";
 	//$('btn_cancel').style.display = "none";
	$('tr_buttons').style.display = "none";
 	//$('btn_edit').style.display = "block";
	$("errtech").className="";
	$("errattach").className="";
	$("errprojname").className="";
	$("errlabel").innerHTML="";
}


var preme ;
var oBGColor;
var oTColor;
/*used for highlight row color*/



/*used for highlight row color*/
function highlightMe(me,backClr,textClr){
	if(typeof(preme)!='undefined') {
		preme.bgColor=oBGColor;
		try{cngtxtColor(preme,oTColor);}catch(e){;}
	}
	oBGColor = me.bgColor;
	oTColor = me.style.color;
	me.bgColor=backClr;
	try{cngtxtColor(me,textClr);}catch(e){;}
	preme = me;
}

function cngtxtColor(tr_obj,tr_color){
    tr_obj.style.color=tr_color;
}
/*used for highlight row color*/

var globattr;
/* by yuvraj for collopsing/expanding the left frame */
function createElem(){
	  var tx=midframe.document.getElementsByTagName("body").item(0);
	  var topy=getPageSize().windowHeight;
	  var vname=(document.getElementById('bodyfs').getAttribute('cols')=="0,*")?"expand_arrow.png":"collapse_arrow.png";
	  var imgframe=midframe.document.createElement("IMG");
	  imgframe.id="imgCollapsible";
	  imgframe.src="/web-xepst/image/"+vname;
	  imgframe.style.left="0px";
	  imgframe.style.top=(topy/2)+"px";
	  imgframe.style.position="fixed";
	  imgframe.style.zIndex=999;
	  tx.appendChild(imgframe);
	  midframe.document.getElementById("imgCollapsible").onclick = function(){

		var a=this.src;
		var k=a.split("/");
		if(k[k.length-1]=="collapse_arrow.png"){
			globattr=(document.getElementById('bodyfs').getAttribute('cols'));
			document.getElementById('bodyfs').setAttribute('cols', '0,*', 0);
			this.src=this.src.replace(k[k.length-1],"expand_arrow.png");
		}else{
			document.getElementById('bodyfs').setAttribute('cols', globattr, 0);
			this.src=this.src.replace(k[k.length-1],"collapse_arrow.png");
		}
	  };
}

function getPageSize(parent){
    parent = parent || document.body;
    var windowWidth, windowHeight;
    var pageHeight, pageWidth;
    if (parent != document.body) {
      windowWidth = parent.getWidth();
      windowHeight = parent.getHeight();
      pageWidth = parent.scrollWidth;
      pageHeight = parent.scrollHeight;
    }
    else {
      var xScroll, yScroll;

      if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
      } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
      } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
      }


      if (self.innerHeight) {  // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
      } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
      } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
      }

      // for small pages with total height less then height of the viewport
      if(yScroll < windowHeight){
        pageHeight = windowHeight;
      } else {
        pageHeight = yScroll;
      }

      // for small pages with total width less then width of the viewport
      if(xScroll < windowWidth){
        pageWidth = windowWidth;
      } else {
        pageWidth = xScroll;
      }
    }
    return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight};
  };

/* by yuvraj for collopsing/expanding the left frame */


/*Supporting File for auto growing  textarea*/

/* ------------------------------------------------------------------------
 * msg.js
 * Copyright (c) 2004-2007 37signals, LLC. All rights reserved.
 * ------------------------------------------------------------------------ */

var msgs = {
  beforeRemoveAttachment: function(id) {
    Element.show('spin_' + id)
  },

  afterRemoveAttachment: function(id) {
    new Effect.Fade('attachment_' + id,
      {duration: 0.5,
       afterFinish: function() { Element.remove('attachment_' + id) }})
  },

  adjustTextarea: function(textarea, collapsed) {
    var lines = textarea.value.split("\n");
    var count = lines.length;
    lines.each(function(line) { count += parseInt(line.length / 70); });

    var rows = parseInt(collapsed / 20);

    if (count > rows) {
      textarea.style.height = (collapsed * 2) + 'px';
    }

    if (count <= rows) {
      textarea.style.height = collapsed + 'px';
    }
  },

  commentEditCountdown: function(comment, cutoff) {
    var diff = cutoff - new Date().getTime();
    if(isNaN(diff) || diff <= 0) {
      $(comment).down('.editable_until').hide();
    } else {
      var minutes = Math.round(diff / 60000);
      $(comment).down('.editable_minutes').update(minutes);
      setTimeout(msgs.commentEditCountdown.curry(comment, cutoff), 60000);
    }
  },

  submitter: {
    prepare: function(form) {
      if(!validateField('post_title', 'Every message must have a title')) {
        return false;
      }

      $('buttons', 'please_wait').each(Element.toggle);
      msgs.submitter.fixAction(form);
      return true;
    },

    prepareComment: function(form) {
      if(!validateField('commentBody', 'Every comment must have a body')) {
        return false;
      }
      $('buttons', 'please_wait').each(Element.toggle);
      msgs.submitter.fixAction(form);
      return true;
    },

    fixAction: function(form) {
      var needs_upload = false;
      $$('#attachment_fields input').each(function(field) {
         if (field.value.match(/^\s*$/) == null) needs_upload = true;
      })

      if (!needs_upload) form.action = form.action.replace(/\/upload\//, "/");
    },

    cancelPreview: function() {
      $('Preview').hide();
      $('post_form_container').show();
      $('preview_button').down().disabled = false;
      $('preview_button').show();
      $('edit_button').hide();
      $('post_body').focus();
    },

    submit: function(form) {
      if (msgs.submitter.prepare(form)) { form.submit(); }
    }
  },

  notifier: {
    toggle: function() {
      this.visible() ? this.hide() : this.show()
    },

    visible: function() {
      return Element.visible('NotifyBlock')
    },

    show: function() {
      visible = this.visible()

      new Effect.BlindDown('NotifyBlock', {duration: 0.2})
      Element.hide('Notify_link')
      $('notify_everyone').checked = false

      return visible
    },

    hide: function() {
      visible = this.visible()

      new Effect.BlindUp('NotifyBlock', {duration: 0.2})
      Element.show('Notify_link')

      return visible
    },

    all: function() {
      if($('notify_everyone').checked) this.hide()
    }
  },

  milestoner: {
    updateCompletionCheckboxVisibility: function() {
      if($('post_milestone_id').selectedIndex == 0) {
        $('completion_option').hide();
      } else {
        $('completion_option').show();
      }
    }
  },

  formatGuide: {
    toggle: function() {
      this.visible() ? this.hide() : this.show()
    },

    visible: function() {
      return Element.visible('formatting_guide')
    },

    show: function() {
      visible = this.visible()

      new Effect.BlindDown('formatting_guide', {duration: 0.2})
      Element.activate('formatting_guide_link', true)

      return visible
    },

    hide: function() {
      visible = this.visible()

      new Effect.BlindUp('formatting_guide', {duration: 0.2})
      Element.activate('formatting_guide_link', false)

      return visible
    }
  }
}
/*Supporting File for auto growing  textarea*/

function f_addtowatch(srid){
	var myurl = cgipath + 'x/xpstwcommitwatchlist.p';
	var params = 'mode=add&srid=' + srid ;
	var myObj = new javraAJAX (myurl, 'post', {
    parameters: params
    });
    myObj.sendData();

}

function f_removefromwatch(srid){
	if (confirm("Do you want to remove this SR from the watchlist ?")){
	var myurl = cgipath + 'x/xpstwcommitwatchlist.p';
	var params = 'mode=remove&srid=' + srid ;
	var myObj = new javraAJAX (myurl, 'post', {
    parameters: params
    });
    myObj.sendData();
	}

}

var f_setremove_watch= function (handler,params){

	$('btn3').onclick = function(){
							f_removefromwatch(srid);
						};
	$('btn3').title = lremovewatch;
	$('btn3label').innerHTML = lremovewatch;
	alert("SR added to your watchlist");
}


var f_setadd_watch= function (handler,params){

	$('btn3').onclick = function(){
							f_addtowatch(srid);
						};
	$('btn3').title = laddwatch;

	$('btn3label').innerHTML = laddwatch;
}

function f_delete_sr(cgipath,srid){
	if (confirm("Are you sure to delete the SR '" + srid + "'?")){

    var myurl = cgipath + 'x/xpstwsrdelete.p';
	var params = 'srid=' + srid ;
	var myObj = new javraAJAX (myurl, 'post', {
    parameters: params
    });
    myObj.sendData();
	}
}

function f_redirect_aftersrdel(){
	document.location.href = cgipath + 'x/xpstwdash-mframe.p';
}

//replace "&ndash;" with "-" . This has to be done as there was problem passing '-' as input
var f_redirectSRdetail = function(handler,params) {
	$("img_load").style.display="none";
	var arr = params.split(",");
	var srid = arr[0];
	var comm = arr[1];
	var srdesc = arr[2];
	srid = srid.replace(/&ndash;/g,'-');
	window.location.href = cgipath + 'x/xpstwsrdetail.p?srid=' + srid + '&pagestat=srupdate' + '&lcomment=' + comm + '&srdesc=' + srdesc + '&navigate=' + navigate + '&hidenavigate=' + hidenavigate;
}


function f_trackSRlink(cgiPath) {
	var xpren = $('hidxpren').value;
	parent.parent.frames['header'].document.getElementById('btn_xpren').value=xpren;
	if(xsretidlink != ""){
		if (confirm("Do you want to add the following SR as linked SR: " + xsretidlink + "?")){
			var myurl = cgiPath + 'x/xpstwcommitlinkedsrs.p';
			var params = 'frmcomment=no&mode=create&srid=' + srid + '&lsrid=' + xsretidlink ;
			var myObj = new javraAJAX (myurl, 'post', {
			parameters: params
			});
			myObj.sendData();
		}
	}
}

var f_setsearchlistheight = function (handler,params){
	var arrParam = params.split(',');
	var assignee = arrParam[0];
	var creator  = arrParam[1];
	var module   = arrParam[2];
	var version  = arrParam[3];
	var fixversion = arrParam[4];
	var versionedproj = arrParam[5];
	if (versionedproj == 'yes') // if versioned project then disable version and affected version.
		versionedproj = false;
	else
	    versionedproj = true;

	$('cmbassigne').size = assignee;
	$('resolvedby').size = assignee;
	$('cmbcretor').size = creator;
	$('cmbmodule').size = module;
	$('cmbversion').size = version;
	$('fixversion').size = fixversion;
	$('cmbversion').disabled = versionedproj;
	$('fixversion').disabled = versionedproj;
	handler&&handler();
}


/* Script for Progress Bar*/

  function drawPercentBar(width, percent, color, background)
  {
    var pixels = width * (percent / 100);
    if (!background) { background = "none"; }

    document.write("<div style=\"position: relative; line-height: 1em; background-color: "

                   + background + "; border: 1px solid black; width: "
                   + width + "px\">");
    document.write("<div style=\"height: 1.5em; width: " + pixels + "px; background-color: "
                   + color + ";\"></div>");
    document.write("<div style=\"position: absolute; text-align: center; padding-top: .25em; width: "
                   + width + "px; top: 0; left: 0\">" + percent + "%</div>");

    document.write("</div>");
  }

/*Script to fire onclick searchSR  on enter key*/

function f_checkentered(event,varele){
	event = event || window.event;
	var asc = document.all ? event.keyCode : event.which;
	if(asc==13){
		varele.onclick();
		Event.stop(event);
	}
}

/*Function to set windows title dynamically*/

function f_setWinTitle(vartitle){
	window.top.document.title=vartitle;
}
/* Function to load the project automatically in the search project combo if user has only single project */
function f_load_defaultproj_in_search(cgi){
    var defxpren = $('loaddefproj').value;
	if (defxpren != ''){
	    $('comproj').value = defxpren;
		f_callmodules(defxpren,cgi);
	}
}
/*Function load the project  as per company*/
function f_load_projectlist(me)
{
	var active_stat = "";
	if($('active').checked)
	  active_stat = 'yes';

var clearCache = new Date();
	cgiPath=cgipath;
	var myurl = cgipath + 'x/xpstwloadprojlist.p';
	var params='active=' + active_stat + '&allproj='+ me +'&cache='+clearCache;
	var myObj = new javraAJAX(myurl,'get',{parameters: params});
	myObj.sendData();
}

function f_load_active(){
	document.getElementById('projlist').innerHTML="";
	var active_stat = "";
	var company="";
	if($('active').checked)
	  {
	   active_stat = 'yes';
	   $('active').value = 'yes'
	  }
   else
   	$('active').value = ''

	 if($('company').value!=null)
	   company =$('company').value;
	document.getElementById('projlist').innerHTML="";
var clearCache = new Date();
	cgiPath=cgipath;
	var myurl = cgipath + 'x/xpstwloadprojlist.p';
	var params='active=' + active_stat + '&allproj='+ company +'&cache='+clearCache;
	var myObj = new javraAJAX(myurl,'get',{parameters: params});
	myObj.sendData();

}
/*enable/disable for xpstwworklogreport.htm*/
function f_disable(){
  if($('prht').checked)
    {
      $('project').disabled="true";
      $('estmtime').disabled="true";
	    $('module').disabled="true";
	    $('custreference').disabled="true";
	    $('srsummery').disabled="true";
	    $('worksummery').disabled="true";
	    $('srid').disabled="true";
	    $('billcode').disabled="true";
	    $('distance').disabled="true";

     }
  else if($('emp').checked)
    {
     $('worksummery').disabled="true";
     $('srid').disabled="true";
	   document.getElementById("project").disabled=false;
	   document.getElementById("estmtime").disabled=false;
	   document.getElementById("module").disabled=false;
	   document.getElementById("custreference").disabled=false;
	   document.getElementById("srsummery").disabled=false;
	   $('billcode').disabled="true";
	   $('distance').disabled="true";
    }
	else
	 {
	  $('project').disabled=false;
    $('estmtime').disabled="true";
	  document.getElementById("worksummery").disabled=false;
	  document.getElementById("custreference").disabled=false;
	  document.getElementById("srid").disabled=false;
	  document.getElementById("module").disabled=false;
	  document.getElementById("srsummery").disabled=false;
	  document.getElementById("billcode").disabled=false;
	  document.getElementById("distance").disabled=false;
	 }
}
function f_disable_projlist()
{
 if($('allproj').checked)
 {
  f_load_active();
  document.getElementById("projlist").disabled=true;
  document.getElementById("fsrid").disabled=true;
  document.getElementById("tsrid").disabled=true;
  $('allproj').value = 'yes'

 }
else
	{
  document.getElementById("projlist").disabled=false;
  document.getElementById("fsrid").disabled=false;
  document.getElementById("tsrid").disabled=false;
   $('allproj').value = ''
   }
 }


function f_srtype_selected()
{
 f_hrtype_selected();
 f_projlist_selected();
if (srlist.length>0)
{
 var tmplist =srlist.split(",");
 var srtype=$('srtype');
    for (var i=0; i<srtype.options.length;i++)
	   {
		   for (var j=0; j<tmplist.length;j++)
		   {
		    if (srtype.options[i].value==tmplist[j])
		     $('srtype').options[i].selected= true;
			}
		 }
 }
}

function f_hrtype_selected()
{
if (hrlist.length>0)
{
 var tmplist =hrlist.split(",");
 var hourtype=$('hourtype');
    for (var i=0; i<hourtype.options.length;i++)
	   {
		   for (var j=0; j<tmplist.length;j++)
		   {
		    if (hourtype.options[i].value==tmplist[j])
		     $('hourtype').options[i].selected= true;
			}
		 }
 }
}

function f_projlist_selected()
{
if (xprojlist.length>0)
{
 var tmplist =xprojlist.split(",");
 var projlist=$('projlist');
    for (var i=0; i<projlist.options.length;i++)
	   {
		   for (var j=0; j<tmplist.length;j++)
		   {
		    if (projlist.options[i].value==tmplist[j])
		     $('projlist').options[i].selected= true;
			}
		 }
 }
}

function f_lookup(){
  var id= "";
  var cnt= 0;
 var projlist=$('projlist');
    for (var i=0; i<projlist.options.length;i++)
	   {
     	 if ($('projlist').options[i].selected)
		   {
		     cnt = cnt + 1;
			 id = $('projlist').options[i].value;
		   }
		 }
 if (cnt==1)
   {
   $('pren').value = id;
   document.getElementById("fsrid").disabled=false;
   document.getElementById("tsrid").disabled=false;
   }
  else
  	{
    $('pren').value ="";
    document.getElementById("fsrid").disabled=true;
    document.getElementById("tsrid").disabled=true;
    }
}

var f_defaut_message = function()
  {
  	$("message").innerHTML="The parameters are saved and will be the default for you the next time";
	  setTimeout("$('message').innerHTML='';",3000)
  }

function f_module(){
if ($('module').checked)
 {
  $('module').value = 'yes';
  $('module1').value = 'yes';

 }
else
	{
   $('module').value = '';
   $('module1').value = '';
  }
}

function f_worksummery(){
if ($('worksummery').checked)
 {
   $('worksummery').value = 'yes';
   $('worksummery1').value = 'yes';

  }
else
	{
   $('worksummery').value = '';
   $('worksummery1').value = '';
  }
}

function f_srid(){
if ($('srid').checked)
  {
  $('srid').value = 'yes';
  $('srid1').value = 'yes';
}
else
	 {
    $('srid').value = '';
    $('srid1').value = '';
  }
}

function f_srsummery()
{
  if ($('srsummery').checked)
    {
     $('srsummery').value = 'yes';
     $('srsummery1').value = 'yes';
    }
else
	{
   $('srsummery').value = '';
   $('srsummery1').value = '';
  }
}

function f_custreference()
{
  if ($('custreference').checked)
  {
   $('custreference').value = 'yes';
   $('custreference1').value = 'yes';
  }
else
	{
    $('custreference').value = '';
    $('custreference1').value = '';
  }
}

function f_project()
{
 if ($('project').checked)
  {
   $('project').value = 'yes';
   $('project1').value = 'yes';
  }
else
	{
   $('project').value = '';
   $('project1').value = '';
  }
}

function f_estmtime(){
if ($('estmtime').checked)
 {
  $('estmtime').value = 'yes';
  $('estmtime1').value = 'yes';

 }
else
	{
   $('estmtime').value = '';
   $('estmtime1').value = '';
  }
}

function f_withnosrid(){
if ($('withnosrid').checked)
$('withnosrid').value = 'yes';
else
 $('withnosrid').value = '';
}
function f_confirm_msg()
{
  if(errmsg=='yes')
   {
    $('message').innerHTML = 'The parameters are saved and will we be the default for you the next time';
    setTimeout("$('message').innerHTML = '';" ,2000);
  }
}

function f_billcode(){
if ($('billcode').checked)
 {
  $('billcode').value = 'yes';
  $('billcode1').value = 'yes';
 }
else
	{
   $('billcode').value = '';
   $('billcode1').value = '';
  }
}

function f_distance(){

if ($('distance').checked)
 {
  $('distance').value = 'yes';
  $('distance1').value = 'yes';
 }
else
	{
   $('distance').value = '';
   $('distance1').value = '';
  }
}
/*fill hidden value for srtid */
function f_fill_hidden(me){
 if (me =='fsrid1')
 $('fsrid1').value = $('fsrid').value;
 else
  $('tsrid1').value = $('tsrid').value;
}

function f_changeuserpwd(cgipath){
	document.location.href=cgipath + 'x/xpstwchangepassword.p';
}

function f_resetpw(){
	$("errpass").className="";
	$("errnewpass").className="";
	$("errrenewpass").className="";
	$("errlabel").innerHTML="";
	document.getElementById("pass").focus();
}