/* FUNCTION LIST FOR CG */

		//GLOBAL DECLARATION
		
		var D=document;
		
		var TEMP=new Array();

	
	/* if(document.all){
		 	
			// Nothing Specified
		}
		else{
		    //alert('This site only can access in IE');
			
			if(document.location.href.indexOf('?')<0){
			document.location.href="login.php?err=2";
			}
		}
		*/
		

        // Getting a elements selected index
		
		function select_index(element)
		{
		   return element.selectedIndex;
		}


	 	//Selecting a Text Against a List Box - option text 
		function select_match(text,element)
		{
			
			   for(var ei=0;ei<element.length;ei++)
        			 {
		
						if(element.options[ei].text==text)
							{
							   element.selectedIndex=ei;
							   return ei;
							   ei=ele_len+1;
							}				 
					 }	
		}
		
		
		//Selecting a Text Against a List Box - option value
		function select_match_value(value,element)
		{	
     		   for(var ei=0;ei<element.length;ei++)
    			  {
						if(element.options[ei].value==value)
							{
							   element.selectedIndex=ei;
							   element.options[ei].selected=true;
							   return ei;
							   ei=ele_len+1;
							}				 
				 }	
		}




		//Selecting a Text Against a List Box - option label
		function select_match_value_or_text(value,text,element)
		{
   				   var value_flag=0;
      
				   for(var ei=0;ei<element.length;ei++)
				     {
							if(element.options[ei].value==value)
								{
                					value_flag=1;              
					 			    element.selectedIndex=ei;
								    return ei;
								    ei=ele_len+1;
								}				 
     				}
     
				   if(value_flag==0){ select_match(text,element); }
		}
		

        //Selecting a Text Against a series of list box. except the current 
		// 1 -> value to be matched
		// 2 -> element prefix
		// 3 -> Number of element
		// 4 -> Expect cuurent elememnt
		function select_match_value_series(value,element_id_prefix,element_count,current_element)
		{	
                
				for(var i=1;i<=element_count;i++)
				{
					  if(document.getElementById(element_id_prefix+i).id!=current_element.id)
					  {
						  		  select_match_value(value,document.getElementById(element_id_prefix+i));
					  }
				}

		}
		
		
		function select_all_match_value_series(value,element_id_prefix,element_count,current_element)
		{	
                
				for(var i=1;i<=element_count;i++)
				{
					  if(document.getElementById(element_id_prefix+i).id)
					  {
						  		  select_match_value(value,document.getElementById(element_id_prefix+i));
					  }
				}

		}

        
		//Cheking a text against a select box
		function check_select_match(text,element)
		{
			
			   for(var ei=0;ei<element.length;ei++)
        			 {
		
						if(element.options[ei].text==text)
							{
							   return 1;
							   
							}				 
					 }
			  
			  return 0;	 
		}
	
		//Getting a list box's selected index value
		function select_index_value(element)
		{
		     return element.options[element.selectedIndex].value;
		}
		
		
		

        //Getting a list box's selected index title
		function select_index_text(element)
		{
		   return element.options[element.selectedIndex].text;
		} 
		 

        //Getting a list box's selected index label	
		function select_index_label(element)
		{
		   return element.options[element.selectedIndex].label;
		}
		
		//Getting a list box's selected index title
		function select_index_title(element)
		{
		   return element.options[element.selectedIndex].title;
		}
				
			
	   // Assigning a list box's selected index value to an element
		function select_index_value_pass(element,target)
		{
		   target.value=select_index_value(element);
		}

		
		// Getting select option label title & pass it to another element
		function select_index_text_pass(element,target)
		{
		   target.value=element.options[element.selectedIndex].text;
		}


		// Assigning a list box's selected index label to an element
		function select_index_label_pass(element,target)
		{		
		   target.value=select_index_label(element);
 		}
		
		// Getting select option label title & pass it to another element
		function select_index_title_pass(element,target)
		{
		   target.value=select_index_title(element);
		}


		//Function removing all
		function remove_all(element)
		{
		    // Element Length
		    var e_len=element.length;
			
			for(var ei=1;ei<=e_len;ei++)  {	   element.options.remove(1);    }
	    }
   
   
		// Function for removing options from a select box expect from it's first value   
		function remove_e_first(element)
	    {
		 	//Element Length
		    var e_len=element.length;
			
			for(var ei=1;ei<=e_len;ei++) {	   element.options.remove(1);    }
		}


		// Function for removing all the options in a select box   
		function remove_full(element)
		{
     	 	//Element Length
		    var e_len=element.length;
			
			 for(var ei=0;ei<=e_len;ei++) {	   element.options.remove(0);  }
			   
		}


		///////////////////////////////////////////////CLEAR_FOCUS ELEMENT ./////

           function clear_focus(element)
                      {
                                   element.value='';
                                   element.focus();
                      }

		  //ELEMENT BASED           
          
          function label_pass(sender,reciever)
          {
             document.getElementById(reciever).value=sender.label;
             
          }
          





////////////////////////////////////////////////Delete Check

function d_check(c_count,element_prefix)
{
        c_count=c_count+1;
		var del_items='';
		var d_flag=0;
		
		
	 	for(i=1;i<=c_count;i++)
		  {   
             
			 
			 var e_id="c"+i;
			 
			 if(D.getElementById(e_id).status==true)
			 	{
					del_items+='\n\t  '+D.getElementById(element_prefix+i).innerHTML;
					d_flag=1;
				}	 
			
		  
		  }
	 
		if(d_flag==0)
		 {
			 window.alert("Please Check the element to delete ");
			 return false;
		 }
		 
		 
          var conform=window.confirm('Are Sure want to delete the following items \n' +del_items);
          
          if(conform==true)
          {
                      var conform=window.confirm('Are Sure very sure to delete the following items \n' +del_items);
          }
          
          return conform;
          


return true;

}
////////////////////////////////////////////////////////////////END OF DELETE JOB ///////////////////////////////////////////


        /////////////////    RADIO BOX   ////////////////////////////

         
		// Radio Apply 
		function radio_apply(element_id,effect)
		{
        		D.getElementById(element_id).checked=effect;
        } 
        

		//Prefilling a Radio Box( Named in a series manner(1..2)) against a given value
		function radio_fill(count,element_prefix,fill_value)
		{
        		
				for(var ri=1;ri<=count;ri++)
		           {
	                    D.getElementById(element_prefix+ri).checked=(D.getElementById(element_prefix+ri).value==fill_value)?true:false;
                    
    	                if(D.getElementById(element_prefix+ri).checked==true)
        	            { ri=count+1;}
        		   }
		}


        //Clearing a Radio Box/Check Box Selection's ( Named in a series manner(1..2)) 
		function clear_check(count,element_prefix)
		{	
        
				for(var ri=1;ri<=count;ri++)
		           {
        	            D.getElementById(element_prefix+ri).checked=false;
		           }	
		}

    


		//Prefilling a Check Box Group ( Named in a series manner(1..2)) against a given value set (value terminated by comma(,) )
		function check_fill(count,element_prefix,fill_value)
		{
        	    // Getting Into Array 
				
						var check_values=fill_value.split(',');

				// Getting Length
						
						var cv_length=check_values.length;
				
				
		        for(var ci=1;ci<=count;ci++)
         		  {
                				
					  var elem=D.getElementById(element_prefix+ci);
				  
					  for(var vi=0;vi<check_values.length;vi++)
                  		{
		                      		
									elem.checked=(elem.value==check_values[vi])?true:false;
        		              
							  if(elem.checked==true)
                		      { 
							  		vi=cv_length+1;
							  } 
							  
                        }
           		  }
				  
				  
       	}

         
		// MULTIPLE SELECT  
		 

		//Applying a effect(true,false) to a multiple select box
	    function select_all_effect(element,effect,taker_id)
		{
				
	    		for(i=0;i<element.options.length;i++)
					{
						element.options[i].selected=effect;
					}
  			
		}
		
		
		//Applying a effect(true,false) to a multiple select box and getting the HTML values into ana HTML element concanted by ","
		
		function select_all_effect_get_element_text(element,effect,taker)
		{
			   
			  
			   var taker_string='';
			   
	    		for(var i=0;i<element.options.length;i++)
					{
						element.options[i].selected=effect;
						
						if(element.options[i].id)
						{
							taker.value+=document.getElementById(element.options[i].id).innerHTML+',';
						}
					}
		}



		// Selecting options in a multiple select box against a value set ( terminated by comma(,) )
		   // * Options named in a element_id + suffix of unique id
		function select_multiple_index(element_id,values)
		{
	    		  //window.alert(element_id+'....'+document.getElementById(element_id).id);
				  var element=document.getElementById(element_id);
				  select_all_effect(element,false);
		
		          var selected_values=values.split(',');
                  
				  for(var smi=0;smi<selected_values.length;smi++)
					{
			     			 
							   document.getElementById(element_id+'_'+selected_values[smi]).selected=true;
			  		}
	    }


	// JavaScript Document


	// In this function performed the text  is going UP while press the up_button

			// parameter- pass the select_box ID  
  

	function select_up(txt) {   				 // function start 
					
		var element=document.getElementById(txt);
		var current_index=element.selectedIndex;

		if(current_index==-1) {
			 window.alert('Please Select...')
           }

		if(current_index==0) {        				 // if statement start 
			 window.alert('No More....');
           } 										// if statement end

           else {                    				// else start
			
				var temp_value=element.options[current_index-1].value;
				 
				var temp_text=element.options[current_index-1].text;

				element.options[current_index-1].value=element.options[current_index].value;
				element.options[current_index-1].text=element.options[current_index].text;
				element.options[current_index].value=temp_value;
				element.options[current_index].text=temp_text;
					
				} 									//else end 
	
     }												// function end
				



	// In this function performed the text  is going DOWN while press the down_button  

		// parameter- pass the select_box ID 

	function select_down(txt) {		//function start

		var s_len = document.getElementById(txt);

		var element=document.getElementById(txt);

		var current_index=element.selectedIndex;

		if(current_index==-1)  {
											
			window.alert('Please Select...')

		}

		if(current_index == s_len.length-1){ 		// if start			
														
			window.alert('No More....');
		}											// if end 

			else {

				var temp_value=element.options[current_index+1].value;
				var temp_text=element.options[current_index+1].text;

				element.options[current_index+1].value=element.options[current_index].value;
				element.options[current_index+1].text=element.options[current_index].text;

				element.options[current_index].value=temp_value;
				element.options[current_index].text=temp_text;

   				}					           	 //else end 
	}											// function end
         


		 
		//Applying selection to multiple select box from a "DATASET" value
			//  * DATASET Row terminator [R]
			//	* DATASET Column terminator [C]
			//	* First column represents the  ELEMENT ID " SELCT MULTIPLE BOX -> ID"
			//	* Second column represents the " Values to be selected "
        
	
		
		
		function comm_extra_preset(value_set)
		{
			
		   var row_count=0;   	   
				   
		   
		   window.alert(" Please Press Enter to Continue ");
		   	
			 var data_row=value_set.split("[R]");
			 
			 data_row.pop();
           			 
			 
			 for(var di=0;di<data_row.length;di++)
			  {
			 	
				 row_count++;
					
				 var data_column=data_row[di].split("[C]");	                			
				 
				 if(data_column[1]!='')
					 {
					 
						 if(data_column[1].indexOf(',')<0)
							 {
							    // window.alert('....'+E_TYPE(data_column[0])+'..'+data_column[0]);
								 
								 if(E_TYPE(data_column[0])=="select-one")
								 {
								    select_match_value(data_column[1],document.getElementById(data_column[0]));
								 }
								 else if(E_TYPE(data_column[0])=="text")
								 {
									 E_V_PASS(data_column[0],data_column[1]);
								 }
								 else if( (E_TYPE(data_column[0])=="hidden") && (data_column[1].indexOf('[D]')!=-1) )
								 {
									
									var date_info=data_column[1].split('[D]');									
									/*window.alert(date_info[0]);
									window.alert(date_info[0].substring(0,4));
									window.alert(date_info[0].substring(4,6));
									window.alert(date_info[0].substring(6,8));*/	
									
									// Filling Year
									var year_element=data_column[0].replace(/row_/g,'year_');
									var year=new Number(date_info[0].substring(0,4));
									select_match_value(year,document.getElementById(year_element));
																			   
								   // Filling Month
									var month_element=data_column[0].replace(/row_/g,'month_');
									var month=new Number(date_info[0].substring(4,6));
									select_match_value(month,document.getElementById(month_element));										   
									 
									// Filling Date
									var date_element=data_column[0].replace(/row_/g,'date_');
									var date=new Number(date_info[0].substring(6,8));
									select_match_value(date,document.getElementById(date_element));	
									
									E_V_PASS('row_'+row_count,data_column[1]);
									 
								 }
								 
								 
				
							 }
						 else
							 {
							 	        // repalcing usual row_digt to sel_mul_digit for internal engine
									 	var sel_mul=data_column[0].replace(/row_/g,'sel_mul_')
										select_multiple_index(sel_mul,data_column[1]);
										
										E_V_PASS('row_'+row_count,data_column[1]);
							 }
					 } // End avail of data checking
			  } // End of For
		} // End of Function
 

		
		//Applying selection to multiple select box from a "DATASET" value
			//  * DATASET Row terminator [R]
			//	* DATASET Column terminator [C]
			//	* First column represents the  ELEMENT ID " SELCT MULTIPLE BOX -> ID"
			//	* Second column represents the " Values to be selected "


		function dataset_from_select(element)
		{
       		 var data_row=element.options[element.selectedIndex].value.split("[R]");
			 
	   		 data_row.pop();

			 for(var di=0;di<data_row.length;di++)
			  {
			 	 var data_column=data_row[di].split("[C]");		
                 
				 if(data_column[1]!='')
					 {
					 
						 if(data_column[1].indexOf(',')<0)
							 {
							    
								 
								 if( (E_TYPE(data_column[0])=="select-one") || (E_TYPE(data_column[0])=="select-multiple"))
								 {
									 select_match_value(data_column[1],document.getElementById(data_column[0]));
									 fireEvent(document.getElementById(data_column[0]),'change');
								 }
								 
								 else if(E_TYPE(data_column[0])=="radio")
								 {
									 
									  radio_apply(data_column[0],true);
									  fireEvent(document.getElementById(data_column[0]),'click');
									 
								 }
								 
								 else if (E_TYPE(data_column[0])=="text")
								 {
									// select_match_value(data_column[1],document.getElementById(data_column[0]));
									 E_V_PASS(data_column[0],data_column[1]);
									 
									
									 
									 if(data_column[0].indexOf('range')!=-1)
									 {
										range_field_builder(); 
									 }
									 else
									 {
										 date_field_builder(); 
									 }
									 
								 }
								 
								 
							 }
						 else
							 {
							 		//Enable element
									select_multiple_index(data_column[0],data_column[1]);
									fireEvent(document.getElementById(data_column[0]),'change');
															
									
							 }
					 } // End avail of data checking
			  } // End of For
		} // End of Function

        
		
		//Firing A event
		function fireEvent(element,event)
		{
				
			    if (document.createEventObject)
				{
			        // dispatch for IE
				       var evt = document.createEventObject();
				       return element.fireEvent('on'+event,evt)
    			}
			    else
				{
			        // dispatch for firefox + others
			        var evt = document.createEvent("HTMLEvents");
			        evt.initEvent(event, true, true ); // event type,bubbling,cancelable
			        return !element.dispatchEvent(evt);
    			}
			}


		//////////////////////////////////////////Page heading
		
		// Drawing a page heading with a defined page style  
		function page_heading(heading)
		{
		    document.write('<table width="100%" class="page_h1" cellpadding="0" cellspacing="0" border="0"><tr><td>'+heading+'</td></tr></table><br>');
		}

		// Drawing a page heading with a defined page style  AND  with a Back link to a URL
		function page_heading_menu(heading,url)
		{
		    document.write('<table width="100%" class="page_h1" cellpadding="1" cellspacing="0" border="0"><tr><td width="80%">'+heading+'</td><td width="20%" align="right"> <a href="file:///C|/xampp/cgi-bin/media/%27%2Burl%2B%27">[ Back ]</a>&nbsp;&nbsp;&nbsp; </td></tr></table><br>');
		}

		// Drawing a page heading with a defined page style  AND  with a Close the window AND Refresh the parent window
		function page_heading_close(heading)
		{
		    document.write('<table width="100%" class="page_h1" cellpadding="1" cellspacing="0" border="0"><tr><td width="100%">'+heading+'</td><td width="20%" align="right"> <a href="JavaScript:close_win()">[ Close ]</a>&nbsp;&nbsp;&nbsp; </td></tr></table><br>');
		}


		//Drawing a page heading with a defined page style  AND  with a Close the child window
		function child_window_close(heading,url)
		{
		    document.write('<table width="100%" class="page_h1" cellpadding="1" cellspacing="0" border="0"><tr><td width="100%">'+heading+'</td><td width="20%" align="right"> <a href="JavaScript:close_win();">[ Close ]</a>&nbsp;&nbsp;&nbsp; </td></tr></table><br>');
		}

		//Drawing a page heading with a defined page style  AND  with a Close the child window
		function close_current_refresh_parent(heading,url)
		{
		    document.write('<table width="100%" class="page_h1" cellpadding="1" cellspacing="0" border="0"><tr><td width="100%">'+heading+'</td><td width="20%" align="right"> <a href="JavaScript:close_win();">[ Close ]</a>&nbsp;&nbsp;&nbsp; </td></tr></table><br>');
		}

		//Drawing a page heading with a defined page style  AND  with a Close the child window
		function close_current(heading,url)
		{
		    document.write('<table width="100%" class="page_h1" cellpadding="1" cellspacing="0" border="0"><tr><td width="100%">'+heading+'</td><td width="20%" align="right"> <a href="JavaScript:close_child();">[ Close ]</a>&nbsp;&nbsp;&nbsp; </td></tr></table><br>');
		}

		//Drawing a page heading with a defined page style  AND  with a History Back Option
		function page_heading_history(heading)
		{
			    document.write('<table width="100%" class="page_h1" cellpadding="1" cellspacing="0" border="0"><tr><td width="80%">'+heading+'</td><td width="20%" align="right"> <a href="JavaScript:page_go(-1)">[ Back ]</a>&nbsp;&nbsp;&nbsp; </td></tr></table><br>');
		}


		// History back link
		function page_go(mile)
		{
			history.go(mile);
		}


		// Assigning a URL to a current window
		function web_go(url)
		{
			document.location.href=url;
		}


		// Assigning a URL to additon of existing address 
		function self_go(url)
		{
			document.URL=document.location.href+url;
		}
		
		
		// Assigning a URL to additon of existing address 
		function block_go(block_id)
		{
			document.location.href="#"+block_id;
		}


		// Writing a HTML Content
		function html(content)
		{
			document.write(content);
		}


		/*
		//function return value statement
		function html_get(content)
		{
			return content;
		}
		*/


		// Opening a window with give URL AND in a default name AND given feature list
		function WS_open(theURL,winName,features) 
		{ 
			  window.moveTo(0,0); 
			  
			  var window_attributes=(features)?features:'width=1000,height=350,scrollbars=yes,left=0,top=0';
			  
			  window.open(theURL,'winmax',window_attributes);
		}

		// Opening a window in agiven URL AND given name and features
		function WS_show(theURL,winName,features) 
		{ 
  			  window.moveTo(0,0); 
			  
			  if(!winName){ winName='name';} 
			  var window_attributes=(features)?features:'width=1000,height=350,scrollbars=yes,left=0,top=0';
			  
			  window.open(theURL,winName,window_attributes);
		}
		
		// Opening a window in a given URL and Window Name and Features
		function WS_print(theURL,winName,features) 
		{ 
  			  window.moveTo(0,0); 
			  
			  var window_attributes=(features)?features:'width=700,height=842,scrollbars=yes,left=0,top=0';
			  
			  window.open(theURL,winName,'width=700,height=842,scrollbars=yes,menubar=yes');
  		}


		// Closing the window AND refrishing the parent window
		function close_win()
		{
	 		   var cur_win=window.opener.location.href;	
			   window.opener.location.href=cur_win;
   	   		   self.close(); 
		}

		// Closing the window
		function close_child()
		{
				//  var cur_win=window.opener.location.href;	
			   //	window.opener.location.href=cur_win;
   	   		   self.close(); 
		}


		// Applying Hidding function for the elements passed
		function hide()
		{
			   for(var hi=0;hi<hide.arguments.length;hi++)
				   {
					      document.getElementById(hide.arguments[0]).style.visibility="hidden";
				   }  
  		}






// Modal window

				function modal_window(page,width,height,scroll){

						var pass_id=document.getElementById('PASS_ID').value;
						
						var url=(page.indexOf('?')==-1)?page+'?WIN=off&PASS_ID='+pass_id:page+'&WIN=off&PASS_ID='+pass_id; 
		
						var w_width=(width)?width:1000;    // Window Width
						var w_height=(height)?height:600; // Window height 
		
						var cl=Math.floor(Math.random()*(10+1));
						
						var newWindow=window.open(url,cl,"scrollbars=yes,width="+w_width+",Height="+w_height+"");

						newWindow.moveTo(0,0);

				 }

				
				// Modal print window -> optimizaton needed

				function modal_window_print(page,width,height){

						var pass_id=document.getElementById('PASS_ID').value;
						
						var url=(page.indexOf('?')==-1)?page+'?WIN=off&PASS_ID='+pass_id:page+'&WIN=off&PASS_ID='+pass_id; 
		
						var w_width=(width)?width:1000;    // Window Width
						var w_height=(height)?height:600; // Window height 
		
						var cl=Math.floor(Math.random()*(10+1));
						
						var newWindow=window.open(url,cl,"scrollbars=yes,menubar=yes,width="+w_width+",Height="+w_height+"");

						newWindow.moveTo(0,0);

				 }


//////////////// MODleess ////////////////////////
function MODAL_WIN(page,width,height){

                var sess_id=document.getElementById('PASS_ID').value;
                var url=(page.indexOf('?')==-1)?page+'?WIN=off&PASS_ID='+sess_id:page+'&WIN=off&PASS_ID='+sess_id; 

                var w_width=(width)?width:1000;    // Window Width
                var w_height=(height)?height:600; // Window height 

				var cl=Math.floor(Math.random()*(5+1));
				
				var newWindow= window.showModalDialog(url,cl,"dialogWidth="+w_width+",dialogHeight="+w_height+"");
				newWindow.moveTo(0,0);
 }
 
///////////////////////MAIN CLOSE //////////////////////////////////
function Main_Close(WIN)
{
     self.close();       
}

		//Child Window Close 
			// Closing the child window	
			
			function CHILD_CLOSE()
				{
					self.close();
				}


//////////////////// ADDING ELEMENT INTO PARENT PAGE ////////////////////////
//Function for addding a varaible into a select box froma child form that added nto database

function add_into_parent_sel(parent_area,parent,child_var)
{
   
  //Getting the element value
  var new_element=child_var.split(",");
  
  //Creating the value in openenr structure
  window.opener.document.getElementById(parent_area).innerHTML='<select id='+parent+' name='+parent+'>'+window.opener.document.getElementById(parent).innerHTML+'<option value='+new_element[0]+'>'+new_element[1]+'</option></select>';

}


function AIP_MUL_SEL_APPEND(parent_area,parent,child_var,element_function)
{
 		//Getting the element value
		var new_element=child_var.split(",");
   		
		//Element Function
    	element_function=(element_function)?element_function:'';
	
		//Creating the value in openenr structure
	    window.opener.document.getElementById(parent_area).innerHTML='<select id='+parent+' name='+parent+'   '+element_function+'>'+window.opener.document.getElementById(parent).innerHTML+'<option value='+new_element[0]+'>'+new_element[1]+'</option></select>';
  
}



function AIP_MUL_SEL_NEW(parent_area,parent,child_var,element_function)
{
    //Removing old  		
	remove_all(window.opener.document.getElementById(parent));

	//Select Type
//	select_type=(select_type)?select_type:'';
  		
	//Element Function
    element_function=(element_function)?element_function:'';
  
  	var element=child_var.split("#"); //Spliting Content
  
	var length=element.length-1; // Getting Length
  
    var option_list=''
  
    for(var i=0;i<length;i++)
    {
       var child_element=element[i].split('::');
       option_list+='<option value='+child_element[0]+' selected=true>'+child_element[1]+'</option>';     
    }
 
    //Creating the value in openenr structure
    window.opener.document.getElementById(parent_area).innerHTML='<select id='+parent+' name='+parent+' '+element_function+' class="FI_200" >'+window.opener.document.getElementById(parent).innerHTML+option_list+'</select>';
 
}


///////////////////////////////////////// AIP TEXT BOX ////////////////////////////////

function AIP_MUL_TEXT_NEW(parent_area,parent,child_var)
{
    //Getting the element value
    var new_element=child_var.split(",");
  
    //Creating the value in openenr structure
    window.opener.document.getElementById(parent_area).innerHTML='<input type="text" id="'+parent+'" name="'+parent+'" class="formInputMiniMedium" value="'+child_var+'" >';
}


//// AIP HTML


function AIP_HTML(parent,child){
	
	window.alert('...');

	window.opener.document.getElementById(parent).innerHTML=child;

}




/////////////////// ADDING ELEMENT INTO PARENT PAGE ////////////////////////





/////////////////////////////////////////////////////////////////   CHECK ERROR ///////////////////////////////////////////////////


var CHECK_ERROR_MESSAGE='';
var CHECK_ERROR_FLAG=new Array();

/// 0-> select text  1 -> text   2 -> Chekc box  3-> selectbox _fill   4-> radio box

check_reset();

//Default Variables
function check_reset()
{
	 CHECK_ERROR_MESSAGE='';
	 
	 
	 CHECK_ERROR_FLAG[0]=1;
	 
	 CHECK_ERROR_FLAG[1]=1;
	 
	 CHECK_ERROR_FLAG[2]=1;
	 
	 CHECK_ERROR_FLAG[3]=1;
	 
	 CHECK_ERROR_FLAG[4]=1;
} 



	// Select Test
	function selectTest()
	{
	   var argLength=selectTest.arguments.length;
	   var select_error='';
	   
	   
		  for(ai=0;ai<argLength;ai++)
		  {
			      
			
			 if(selectTest.arguments[ai]){
 					
					
				 if(selectTest.arguments[ai].length==0)
				 { 
				 	// 
					  select_error+='\n '+selectTest.arguments[ai].title;
				 }//alert(ai+'..'+selectTest.arguments[ai].type);
				 
			 	
					// Note -- This is for multiple selectbox validation 
				 if ( ( (selectTest.arguments[ai].selectedIndex==0) && (selectTest.arguments[ai].type=='select-one') ) ||  ( (selectTest.arguments[ai].selectedIndex==-1) && (selectTest.arguments[ai].type=='select-multiple') )   )
				 {					  
					  
					 select_error+='\n '+selectTest.arguments[ai].title;
				 }
			}

		  }
	 
		  if(select_error!='')
			{
			   CHECK_ERROR_MESSAGE+='\n\nPlease Select the following elements :'+select_error;
			   CHECK_ERROR_FLAG[0]=0;
			   return false;
			}	   
	 
	 	return true;
	 
	}



	// Select Fill Test
	function selectFillTest()
	{
			
			var argLength=selectFillTest.arguments.length;
			var select_error='';
	   
	  		for(var ai=0;ai<argLength;ai++)
			{
				 if(selectFillTest.arguments[ai].length==0)
				 {
					  select_error+='\n '+selectFillTest.arguments[ai].label;
					
				 }
			}
	
		    if(select_error!='')
			{
				 CHECK_ERROR_MESSAGE+='\n\nPlease Fill the following elements :'+select_error;
				 CHECK_ERROR_FLAG[3]=0;
				 return false;
			}
			 
			return true;
	}


	// Text Test
	function textTest()
	{
		var argLength=textTest.arguments.length;

		var select_error='';
	   
	   for(ai=0;ai<argLength;ai++)
		  {
			  	
			 if(textTest.arguments[ai].value.length<1)
			 {
				
				  select_error+='\n '+textTest.arguments[ai].title;
			 }
		  }
	   if(select_error!='')
		 {
		   CHECK_ERROR_MESSAGE+='\n\nPlease enter information for the following elements :'+select_error;
		   CHECK_ERROR_FLAG[1]=0;
		 }	   
		 
		 
	}


   // Check Box text
   function optionTest()
   {	
	   var argLength=optionTest.arguments.length;  
	   
	  // alert(argLength);
	   
	   var select_error='';
	   for(ai=0;ai<argLength;ai++)
		  {
			  
	
			  
			 if(optionTest.arguments[ai].checked==false)
			 {
				 
				  select_error+='\n '+optionTest.arguments[ai].label;
				  
			 }
		  }
	  if(select_error!='')
		{
		   CHECK_ERROR_MESSAGE+='\n\nPlease check the following elements :'+select_error;
		   CHECK_ERROR_FLAG[2]=0;	
		   return false;
		}	   
	 return true;
	 
   }


    // Check Box text
			// element name

				
   function optionTestSeries()
   {	
	   var argLength=optionTest.arguments.length;  
	   
	   var select_error='';
	   
	   for(ai=0;ai<argLength;ai++)
		  {
			 
			 
			 
			 if(optionTest.arguments[ai].length<1)
			 {
				  select_error+='\n '+optionTest.arguments[ai].label;
				  
			 }
			 
			 
			 
		  }
	  if(select_error!='')
		{
		   CHECK_ERROR_MESSAGE+='\n\nPlease add information for the following elements :'+select_error;
		   CHECK_ERROR_FLAG[2]=0;	
		   return false;
		}	   
	 return true;
	 
   }

	// Radio Check
	
	function radioTest(element)
	{
	        var radio_error='';
			
			var argLength=radioTest.arguments.length;
	   	    
			for(ai=0;ai<argLength;ai++)
	 		  {
				 if(arguments[ai].checked==false)
				 {
					 radio_error+='\n '+radioTest.arguments[ai].label;
				 }
			  }
				
			if(radio_error!='')
			{
				    CHECK_ERROR_MESSAGE+='\n\nPlease select the following radio elements :'+radio_error;
		   			CHECK_ERROR_FLAG[4]=0;	
				    return false;
			}
			
			return true;
	}


function CHECK_UNFILL()
{
     
	  var check_flag=CHECK_ERROR_FLAG[0]+CHECK_ERROR_FLAG[1]+CHECK_ERROR_FLAG[2];

	  if(check_flag<3)
		  {
		     window.alert(CHECK_ERROR_MESSAGE);
			 check_reset();		
			 return false;
		  }
	  	  
  	  
}


	function ask_once(message)
	{
			
		var answer=window.confirm(message);

		if(answer==true){
			return true;
		}
		else{
			return false;
		}
	
	}



////////////////////////////////////////////////////////////////// END OF CHECK ERROR /////////////////////////////////////////////////////

/////////////////FILTER ACT //////////////////////////////////////////////////////////
//1- > URL 2 -> filter elements
function show_filter_act()
{
    //spliting url part
	
	//Short namin function
	var FUNC=show_filter_act; 
	
	//var URL CUSTOM STRING
	var url_string='?';
	
	//Connecting param
	var connect='&';
	
	//Getting main link
	var url_root=FUNC.arguments[0].split("?");
	
	//Added New
	/*
	var url_root=FUNC.arguments[0];
	if(url_root.length > 1 )
	{
		url_string='&';
	}
	else
	{
		url_string='?';
	}*/
	
		
	//Getting Fragment
	var url_id=FUNC.arguments[1].split(",");
		
	//url id length
	var url_id_len=url_id.length;
	
	
	
	
	//Building parameter list
	for(ui=0;ui<url_id_len;ui++)
	{
        var elem=FUNC.arguments[ui+2];
		
		//alert(elem+'..'+ui);
		
		var elem_value=(elem.tagName=="SELECT")?elem.options[elem.selectedIndex].value:elem.value;
		
        if(ui==0)
		url_string+=url_id[ui]+'='+elem_value;
		else
		url_string+=connect+url_id[ui]+'='+elem_value;

	}
	
	//Added New
	//document.location.href=url_root+url_string;
	document.location.href=url_root[0]+url_string;
	
	
	
}

////////////////////////////////////////////////////////////////////////////////////////////////  FILE UPLOAD CHECK //////////////
// JavaScript Document
var PERMITTED_FILES=new String('|jpg|gif|png|pdf|doc|ppt|xls|mdb|zip|txt|html|');

//Check for filename	
function check_file(element)
{
   
   
	if(element.value.length>3)
	{
	 		 var fileName=element.value;
			 var fileSplit=fileName.split("\\");
			 var fileFormat=fileSplit[fileSplit.length-1].split('.');
			
			 if(fileSplit[fileSplit.length-1].indexOf('.')<0)
				{
				   window.alert('Please select your filename');
				   return false;
				}
			 else if( PERMITTED_FILES.indexOf('|'+fileFormat[1]+'|')<0 )
			    {
				  window.alert('Please check your file format. It is not a prescribed file format.\n\nCG accepts only in MS-Office File Formats,Adobe PDF,Windows Text File, HTML & Image Formats(jpg,png,gif)');
				  return false;
			  	}		
				   
			 document.getElementById('FILE_FORMAT').value=fileFormat[1];
  }	
  else
  {
        element.value='';
        return false;
  }
    
  return true;
  
  
}


///////////////////////////////////////////////////// STORED FILE OPENING //////////////////////////////////////////////////////////

//function image open
//iid->imageid

function file_sys_open(file_name)
		{
			 window.moveTo(0,0);						  
             window.open('../uploads/'+file_name,'','width=700,height=500,toolbar=0,scrollbars=1,menubar=1,status=0');
		}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////// FUNCTION REPEAT ////////////////////////////////
function repeat(symbol,count)
{
	var sym_content='';
	
	for(si=1;si<=count;si++)  //Counting the symbol for root
	{
	   sym_content+=symbol;	
	}
	
	document.write(sym_content);
	
}



//////////////////////////////////////////////// SORT ICON /////////////////////////////
var SORT_ICON=new Array('&#9650;','&#9660;');


//////////////////////////////////////////////////  SESSION ID /////////////////////////
function crypt_url(url)
{
 
   var q_index=url.indexOf("?");
   var sess_id=document.getElementById('PASS_ID').value;
   document.URL=(q_index==-1)?url+'?PASS_ID='+sess_id:url+'&'+'PASS_ID='+sess_id;
}


/////////////////////////////////////// PARENT TO CHILD //////////////////////////////
//Transfering element from one select box to another ///////////////////////////f(/////
function parent_to_child(parent,child)
{
           var length=parent.options.length;
           
           for(pi=0;pi<parent.options.length;pi++)
           {
                  
				   
				  
				  if(parent.options[pi].selected==true)
                        {
                          
						  if(check_select_match(parent.options[pi].text,child)==0)
						  {
						  	var newD=document.createElement("OPTION");
                          	newD.text=parent.options[pi].text;
                          	newD.value=parent.options[pi].value;
                          	newD.selected=true;
                          	child.options.add(newD);
                          	parent.options.remove(pi);
                          	pi--;   
						  }
						  else
						  {
							window.alert('Already the value '+parent.options[pi].text+' added');  
							return false;
						  }
						  
                        }          
						
                      
           }
}


/////////////////////////// SORT DEFAULT /////////////////////////////////////

function sort_order(column_sort,sort_order,column_value)
{
           
           if(column_sort.value==column_value)
           {
		   if(sort_order.value==0)
		   sort_order.value=1;
		   else if(sort_order.value==1)
		   sort_order.value=0;
           }
           else
	   { sort_order.value=0; }

           column_sort.value=column_value;           
}


/////////////////////////// RETRIEVE OPTION /////////////////////////////////////

function selectbox_capture(ele,taker,connector)
{
     
      connector=(connector)?connector:'#';
      
      var ele_length=ele.length;
      var ele_option='';

      for(ei=0;ei<ele_length;ei++)
	     {
			ele_option+=ele.options[ei].value+'::'+ele.options[ei].text+connector;
         }

      taker.value=ele_option;
	  
   
}


function selectbox_capture_selected(ele,taker,connector)
{
     
      connector=(connector)?connector:'#';
      
      var ele_length=ele.length;
      var ele_option='';

      for(ei=0;ei<ele_length;ei++)
	     {
				if(ele.options[ei].selected==true)
					{
						ele_option+=ele.options[ei].value+'::'+ele.options[ei].text+connector;
					}
         }

      taker.value=ele_option;
	  
   
}


//Delete from select box
function del_sel_box(ele)
{
    if((ele.options.length>0)&&(ele.options.selectedIndex!=-1))
	{
		 ele.options.remove(ele.options.selectedIndex)
	}
}	        


// Capture select box text values
function selectbox_capture_text(ele,taker,connector)
{
      
      connector=(connector)?connector:'#';
      
      
      
      var ele_length=ele.length;
      var ele_option='';
     
      for(ei=0;ei<ele_length;ei++)
	     {
			if(ele.options[ei].selected==true)
                        {
                                 ele_option+=ele.options[ei].text+connector;
                        }         
             }
			 
		 
      taker.value=ele_option.slice(0,(ele_option.length-1));  // For removing last extra ,

}


			// Capture Select Box Values
					
				// ele -> element
				// taker -> value taker
				// connector				
		

			function selectbox_capture_value(ele,taker,connector)
			{

			      connector=(connector)?connector:'#';
           
      			  var ele_length=ele.length;
			      var ele_option='';
     
			      for(var ei=0;ei<ele_length;ei++)
				     {
							if(ele.options[ei].selected==true)
                        		{
                    	             ele_option+=ele.options[ei].value+connector;
                        		}         
             		}

		      	  taker.value=ele_option.slice(0,(ele_option.length-1));  // For removing last extra ,

					

			}

			
	// Capture Select Box Values
					
				// ele -> element
				// taker -> value taker
				// connector				
		

			function selectbox_capture_value_all(ele,taker,connector)
			{

			      connector=(connector)?connector:'#';
           
      			  var ele_length=ele.length;
			      var ele_option='';
     
			      for(var ei=0;ei<ele_length;ei++)
				     {
							
                    	             ele_option+=ele.options[ei].value+connector;
                        		        
             		}

		      	  taker.value=ele_option.slice(0,(ele_option.length-1));  // For removing last extra ,

			}

	// Trimming the content * make extra a  mouse over option

		// 0 -> Content
		// 1 -> Length

    function CONTENT_TRIM(content,trim_length,width,height)
	{
			// Checking for width & height
           
			if( (width) && (height) )
			{
		        document.write('<a  onMouseMove="JavaScript:show_tip(\''+content+'\',event,'+width+','+height+');" onMouseOut="hide_tip()">'+content.substr(0,trim_length)+'...</a>');	
			}
			else
			{
				document.write('<a  onMouseMove="JavaScript:show_tip(\''+content+'\',event);" onMouseOut="hide_tip()">'+content.substr(0,trim_length)+'...</a>');	
			}
	}
	 
	 

	 



/////////////////////////////////////////////   Element Action /////////////////////////////////////
// passing value to a action //////////////////
// E- >Element
// V-> value , H-> HTML

function ELEMENT(element_id){

     	 	if(document.getElementById(element_id))
			{
				return document.getElementById(element_id); 
			}
			else
			{
				//window.alert('Not an Element : '+element_id);
				return false;
			}
			
}


function E_V_PASS(element_id,value)
{
	        document.getElementById(element_id).value=value;
}

function E_H_PASS(element_id,value)
{
           if(document.getElementById(element_id)){
				   document.getElementById(element_id).innerHTML=value;
		   }
            
}


function E_V_TEMP(element_id)
{
            
            TEMP[element_id]=document.getElementById(element_id).value;
            
}

function E_H_TEMP(element_id)
{
            TEMP[element_id]=document.getElementById(element_id).innerHTML;
			
            
}



function V_F_TEMP(element_id)
{
            if(TEMP[element_id])
            document.getElementById(element_id).value=TEMP[element_id];
}


function H_F_TEMP(element_id)
{
            if(TEMP[element_id])
            document.getElementById(element_id).innerHTML=TEMP[element_id];
}



// Simple Element Forms

function GET_E_VALUE(element_id)
{
         	return document.getElementById(element_id).value;
}

// Get HTML Value
function GET_E_HTML(element_id)
{
         	return document.getElementById(element_id).innerHTML;
}



function E_STATE(element_id,state)
{
     	 	if(document.getElementById(element_id))
				{
					document.getElementById(element_id).disabled=state;
				} 
}


function E_VISIBLE(element_id,state)
{
     	 	if( (document.getElementById(element_id)) && (state) )
				{
					document.getElementById(element_id).style.visibility=state;
				} 
			
			if(!state)
			{
				return document.getElementById(element_id).style.visibility;
			}
		   		
}

function E_READONLY(element_id,state)
{
     	 	if(document.getElementById(element_id))
				{
					document.getElementById(element_id).readOnly=state;
				} 
}


function E_FOCUS(element_id)
{
     	 	if(document.getElementById(element_id))
				{
					document.getElementById(element_id).focus();
				} 
}

function E_TYPE(element_id)
{
     	 	return (document.getElementById(element_id))?document.getElementById(element_id).type:'-1'; 
}


function E_TOP(element_id)
{
		window.alert(element_id+'..'+document.getElementById(element_id).style.pixelLeft);	
		return (document.getElementById(element_id))?document.getElementById(element_id).style.top:'0'; 

}


///////////////////////////////////////////// ///////////////////////////// END  Element Action ////////



//////   Element Focus  ////////////////////////////////////////////////////////////////////////////


function E_ROW_FOCUS(element)
{
           element.style.backgroundColor="#B9D300";
}

//ELEMEN ACTION
function E_ROW_FOCUS_OUT(element)
{
           element.style.backgroundColor="";
}



function E_FOCUS_HEIGHT(element)
{
           element.style.rows=10;
}



	


///////////////////////////////////////////////////////////////////////  Element Focus   //////////

///////////////////////////////////// SIMPLE CALCULATION /////////////////////////////////////

function E_MULTIPLY()
{
           var length=E_MULTIPLY.arguments.length;
           var result=1
           
           for(i=0;i<length;i++)
           {
               result=result*document.getElementById(arguments[i]).value;
                      
           }
           
           return result;
}

function E_ADD()
{
           var length=E_ADD.arguments.length;
           var result=1
           
           for(i=0;i<length;i++)
           {
               result=result+document.getElementById(arguments[i]).value;
                      
           }
           
           return result;
}

//Addition series
//1-> "element'
//2- > nuber of rows

function E_ADD_SERIES()
{
           var length=arguments[1];
           
           var result=new Number(0);
           
           for(i=1;i<=length;i++)
           {
               var num=new Number(document.getElementById(arguments[0]+i).value);
               result=result+num;
                      
           }
           
           return result;
}


function E_SUB()
{
           var length=E_SUB.arguments.length;
           var result=1
           
           for(i=0;i<length;i++)
           {
               result=result-document.getElementById(arguments[i]).value;
                      
           }
           
           return result;
}

//////////////////////////////////////////  String concatination //////////////////////////////

function E_CONCAT_SERIES()
{
           var length=arguments.length;
           
           var result='';
           
       
           
           for(i=0;i<length;i++)
           {
               result=result+document.getElementById(arguments[i]).value;
               
                      
           }
           
           return result;
}

///////////////////////////////////////////  STRING CONCATIONATION //////////////////////



///////////////////////  FORM GENERAL VALUS ////////////////////////////////////////////


	//function  for checking all elements
	
	function check_all(c_count)
	{


    	    c_count=c_count;
			for(var i=1;i<=c_count;i++)
		  	{   
         		  D.getElementById('c'+i).checked=true;
			}
	}



	function clear_all(c_count){   for(var i=1;i<=c_count;i++)	{  D.getElementById('c'+i).checked=false;} }


///////////////////////  FORM GENERAL VALUS ////////////////////////////////////////////



////////////////////////  WINDOW PRINT ////////////////////////////////////////////////

// Printing a element content area
	
	// 0 -> Element Id


 // code form  http://www.microsector.net/javascript2.html
 
 
 function E_PRINT(element_id)
	{
			if(document.getElementById('REPORT_HEADER_INFO'))
                        {
                          E_H_PASS('REPORT_HEADER_INFO','');  
                        }

			var prtContent = document.getElementById(element_id);
			var WinPrint = window.open('','','letf=10,top=10,width="700",height="500",toolbar=0,scrollbars=1,menubar=1,status=0');

			WinPrint.document.write("<html><head><LINK rel=\"stylesheet\" type\"text/css\" href=\"../css/cg.css\" media=\"print\"><LINK rel=\"stylesheet\" type\"text/css\" href=\"../css/cg.css\" media=\"screen\"></head><body>");

			WinPrint.document.write("<textarea id=\"REPORT_USER_TITLE\"  name=\"REPORT_USER_TITLE\" class=\"REPORT_USER_TITLE\" rows=1>Report Title</textarea>");
                        
			WinPrint.document.write(prtContent.innerHTML);
			WinPrint.document.write("</body></html>");
			WinPrint.document.close();
			WinPrint.focus();
			WinPrint.print();
			
 }

//////////////////////// //////////////////////// //////////////////////// Window print /////////



////////////////////// POP UP CONTENT ///////////////////////////////////////

 function WIN_SHOW_CONTENT()
	{
			
			var WinPrint = window.open('','Part','width="800",height="500",toolbar=0,scrollbars=0,menubar=1,status=0');
           	     
			WinPrint.document.write("<html><head><title>Part Image</title><LINK rel=\"stylesheet\" type\"text/css\" href=\"../css/cg.css\" media=\"print\"><LINK rel=\"stylesheet\" type\"text/css\" href=\"../css/cg.css\" media=\"screen\"></head><body>");

			WinPrint.document.write('<img src="../tmp/part.jpg"></img>');
			WinPrint.document.write("</body></html>");
			

			
 }
 
 
 ////////////////////////////////////////////////////////////////////// Pop up content



//////////////////// Report Controls ////////////////////////////////




function dummy_act()
{
}
	