// JavaScript Document  
function showChild(obj_array,img){
   	for(i=0;i<obj_array.length;i++){
		    obj=document.getElementById(obj_array[i]);
			if(obj){
				 if(obj.style.display=='none')
				   {
					 obj.style.display='';
					 image1=new Image();
					 image1.src='images/arrow_down.jpg';
					 document.getElementById(img).src=image1.src;
				   }
				 else
				  {
				    obj.style.display='none';
					 document.getElementById(img).src='images/bullet1.jpg';
				  }
			  }
		}   
 }
 function showHideOption(obj,phase_no){
	   
	    fte_option=Array('no_dev','rate','total_hr');
		general_option=Array('price');
		if(obj.value=='fte'){
		    for(i=0;i<fte_option.length;i++){
		 
			   row_obj=document.getElementById(fte_option[i]+phase_no);
			   row_obj.style.display='';
			 }
			for(j=0;j<general_option.length;j++){
			   
			   row_obj=document.getElementById(general_option[j]+phase_no);
			   row_obj.style.display='none';
			 }
	    }else{
		   for(i=0;i<general_option.length;i++){
			   
			   row_obj=document.getElementById(general_option[i]+phase_no);
			   row_obj.style.display='';
			 }	
		   for(j=0;j<fte_option.length;j++){
			   
			   row_obj=document.getElementById(fte_option[j]+phase_no);
			   row_obj.style.display='none';
			 }	 
	    }		
	 }
	 
  function showHide(obj){
	   
	    fte_option=Array('no_dev','rate','total_hr');
		general_option=Array('price');
		
		if(obj.value=='fte'){
		    for(i=0;i<fte_option.length;i++){
		 
			   row_obj=document.getElementById(fte_option[i]);
			  
			   row_obj.style.display='';
			 }
			for(j=0;j<general_option.length;j++){
			   
			   row_obj=document.getElementById(general_option[j]);
			   row_obj.style.display='none';
			 }
	    }else{
		   for(i=0;i<general_option.length;i++){
			   
			   row_obj=document.getElementById(general_option[i]);
			   row_obj.style.display='';
			 }	
		   for(j=0;j<fte_option.length;j++){
			   
			   row_obj=document.getElementById(fte_option[j]);
			   row_obj.style.display='none';
			 }	 
	    }		
	 }


//functions for invoice multiple select option
function selectAllOptn(obj){
	    for(i=0;i<obj.options.length;i++){
		  obj.options[i].selected=true;   
		}
	 }
	 function findExistance(item_name,to){
   for(p=0;p<to.length;p++){
         
         if(to.options[p].value==item_name) return 1;
	  
	  }
	return 0;     
}
	 
function edit_country(id,Itemvalue)
  {
	  formName=document.frmUpdateCountry;
	  formName.country_name.value=Itemvalue;
	  formName.country_id.value=id;
 }
function initCountryValidation(form_name)
        {
           
			var objForm = document.forms[eval("'"+form_name+"'")];
			objForm.country_name.required =1;
			            			
        }


		
function initInviteValidation(form_name)
        {
           error='Please enter following field(s):\n\n';
			var objForm = document.forms[eval("'"+form_name+"'")];
			flag=0;
			if(objForm.name.value=='') { error+="\nName";
			flag=1;
			}
			
			if(objForm.email.value=='') {error+="\nEmail";
			flag=1;
			}
			if(!isValidEmail(objForm.email.value) && objForm.email.value!=''){
				error+="\nEmail";
			  flag=1;	
		     }
			if(objForm.confirm_email.value=='') {error+="\nConfirm Email";
			flag=1;
			}
			if(!isValidEmail(objForm.confirm_email.value) && objForm.confirm_email.value!=''){
				error+="\nConfirm Email";
			  flag=1;	
		     }
			if(objForm.security_code.value=='') {error+="\nSecurity Code";
			flag=1;
			}
			if(flag==0) return true;
			else { alert(error);return false;}
			  							            			
        }

function isValidEmail(str) {
return (str.lastIndexOf(".") > 2) && (str.indexOf("@") > 0) && (str.lastIndexOf(".") > (str.indexOf("@")+1)) && (str.indexOf("@") == str.lastIndexOf("@"));
}

function initLoginValidation(form_name)
        {
           
			var objForm = document.forms[eval("'"+form_name+"'")];
			objForm.username.required = 1;
			objForm.userpass.required =1;
			
					            			
        }
function initLoginValidation1(form_name)
        {
           
			var objForm = document.forms[eval("'"+form_name+"'")];
			objForm.username.required = 1;
			objForm.userpass.required =1;
			objForm.useroldpass.required =1;
					            			
        }
		

 
 function setFocus(obj)
  {
	obj.focus();
 }

	 
	 
	 
  function popUp(URL,w,h,scroll1) {
	  //h=120;
	  //w=350;
	  //scroll1=0;
	  var left_v = (screen.width-w)/2;
      var top_v = (screen.height-h)/2;
	  settings1 ='height='+h+',';
      settings1 +='width='+w+',';
      settings1 +='top='+top_v+',';
      settings1 +='left='+left_v+',';
      settings1 +='scrollbars='+scroll1+',';
      settings1 +='resizable=no';
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', '" + settings1 + "')");
}

function CheckAll1()

   {
		for (var i=0;i<document.moveform1.elements.length;i++)

      {

         var e = document.moveform1.elements[i];

         if (e.name != "allbox")

            e.checked = document.moveform1.allbox.checked;

      }

   }  
   
   function confirmAlert()
    {
	  if(window.confirm("Are You Sure to execute the command?")){
			         return true;
	    }else{
			  return false;	 
	   }	
   }
   
    function deleteConfirm()
    {
	  if(window.confirm("Are You Sure to delete seleted row(s).")){
			         return true;
	    }else{
			  return false;	 
	   }	
   }
function staConfirm()
    {
	  if(window.confirm("Are you sure to change the status?")){
			         return true;
	    }else{
			  return false;	 
	   }	
   }
   
	function numberOnly(obj) {
  if (isNaN(obj.value)){ 
   alert('Only digit is allowed.');
   obj.value='';
  }
 
}
	
	
     
	
