// JavaScript Document

var total_content;			// Number of Tab need

var tab_COUNT=0;			// Count for one or more tab content create....

var tabcontent_btnfocus_flag=new Array();	

var TABCONTENT = new Array();

	TABCONTENT['tab_COUNT']=0;

function table_creation(total_content,tbl_width,data_prefix,btn_name,CONTENT,EMPTY_CONTENT,FOCUS_ON,FLEXI) {		
				
				// 1. Number of tab fields .
				// 2. Tab index total width .
				// 3. Content ID which we want to show in below.
				// 4. Tab fields names
				// 5. Non-empty tab index fields CSS property's.
				// 6. Empty tab index fields CSS property's.
				// 7. While focus the Tab index fields Color ( we choose color over here ).
				
	TABCONTENT['row']=2;


	var btn_value_array = new Array();					
	btn_value_array[0] = btn_name;		
	tab_COUNT++;						
	tabcontent_btnfocus_flag['current'+data_prefix]='';			// assign Array index current is 'empty'
	tabcontent_btnfocus_flag['text'+data_prefix]='';				// assign Array index text is 'empty'
	tabcontent_btnfocus_flag['previous'+data_prefix]='';			// assign Array index previous is 'empty'		
	tabcontent_btnfocus_flag[tab_COUNT] = new Object ; 				// create new object.
	tabcontent_btnfocus_flag[tab_COUNT].e_content=EMPTY_CONTENT;		// 'e_content' is a new variable of tabcontent_btnfocus_flag[tab_COUNT] object 
	tabcontent_btnfocus_flag[tab_COUNT].content=CONTENT;				// 'content' is a new variable of tabcontent_btnfocus_flag[tab_COUNT] object
	tabcontent_btnfocus_flag[tab_COUNT].focus_off=CONTENT;			// 'focus_off' is a new variable of tabcontent_btnfocus_flag[tab_COUNT] object
	tabcontent_btnfocus_flag[tab_COUNT].focus_on=FOCUS_ON;			// 'focus_on' is a new variable of tabcontent_btnfocus_flag[tab_COUNT] object  
			
	temp='<table id="tbl_tab" width="'+tbl_width+'" cellpadding=0 cellspacing=0  >';		// create table in JS
	var td_width =Number(tbl_width/total_content);	
	td_width=Math.floor(td_width);								// Round Of the value 
	
	
	for(var tab_i=1;tab_i<TABCONTENT['row'];tab_i++) {								
		temp+='<tr  width="'+tbl_width+'">';				
		for(var tab_j=1;tab_j<=total_content;tab_j++){	
		
				// If opacity anination use means 
				
					//temp+='<td class="tab" style="width:'+td_width+'" id=r'+tab_i+'c'+tab_j+''+tab_COUNT+' name=r'+tab_i+'c'+tab_j+''+tab_COUNT+' onclick="content_chage(\''+data_prefix+''+tab_j+'\','+tab_COUNT+');find_identity(this);opacity_tabchange.create(0,100);"></td>'; 					
			
				// IF Dint use 	opacity anination use means
				
					//temp+='<td class="tab" style="width:'+td_width+'" id=r'+tab_i+'c'+tab_j+''+tab_COUNT+' name=r'+tab_i+'c'+tab_j+''+tab_COUNT+' onclick="content_chage(\''+data_prefix+''+tab_j+'\','+tab_COUNT+');find_identity(this);"></td>'; 					
					
		if(FLEXI){
		
			temp+='<td class="tab"  style="heigth:500px;width:'+td_width+'px;" id=r'+tab_i+'c'+tab_j+''+tab_COUNT+' name=r'+tab_i+'c'+tab_j+''+tab_COUNT+' onclick="content_chage(\''+data_prefix+''+tab_j+'\','+tab_COUNT+');find_identity(this);"></td>'; 
		}else{
			
			temp+='<td class="tab"  style="heigth:500px;width:'+td_width+'px;"  width="'+td_width+'px;" id=r'+tab_i+'c'+tab_j+''+tab_COUNT+' name=r'+tab_i+'c'+tab_j+''+tab_COUNT+' onclick="content_chage(\''+data_prefix+''+tab_j+'\','+tab_COUNT+');find_identity(this);"></td>'; 
		}
			
			
					// creating table TD.
		}					
		temp+="</tr>";			
		temp+='<tr>';				
		temp+='<td class="tab_content" colspan='+total_content+'  id=content'+tab_COUNT+'></td>';  
					// creating DIV i.e which we want to show in below.
		temp+="</tr>";		
	}						
	temp+='</table>'; 										
	document.write(temp);					// write all tab fiels.
	return d_value(total_content,btn_name,tab_COUNT);		// call the d_value fucntion.	
}


function content_chage(data,tab_count) {			// 1. Div ID

									// If opacity anination use means 
									
											/*if(document.all){
												document.getElementById('content'+tab_count+'').style.filter="Alpha(opacity=0)";
											}else{
												document.getElementById('content'+tab_count+'').style.opacity=0;
											}					// 2. tab_COUNT value.
									
											 document.getElementById('content'+tab_count+'').innerHTML='<br>'+document.getElementById(data).innerHTML;*/
																	
									// If without opacity anination use means 
									// document.getElementById('content'+tab_count+'').innerHTML='<br>'+document.getElementById(data).innerHTML;	

		 document.getElementById('content'+tab_count+'').innerHTML='<br>'+document.getElementById(data).innerHTML;
}

function find_identity(element){			// 1. tab field ID .		


	document.getElementById('r1c11').style.cssText=''+tabcontent_btnfocus_flag[tab_COUNT].focus_off+'';
	
	if(tabcontent_btnfocus_flag['previous']){				// if prev. value is empty.
		
		//alert(tabcontent_btnfocus_flag['previous']);
		document.getElementById(tabcontent_btnfocus_flag['previous']).style.cssText=''+tabcontent_btnfocus_flag[tab_COUNT].focus_off+'';
												// prev. value show white.
	}
	document.getElementById(element.id).style.cssText=''+tabcontent_btnfocus_flag[tab_COUNT].focus_on+'';      
	
											   // focus value is show in User which color want.
	tabcontent_btnfocus_flag['previous']=element.id; 		
}

function d_value(total_content,btn_name,tab_count) {		//	1. Number of tab fields 
														// 2. tab field names 
														// 3. tab_COUNT value
	var e_css;
	var c_css;

	var temp = new Array();		
	temp = btn_name.split(",");					
	 TABCONTENT['row']=2;		  
	 m=0;
	for(var css_i=1;css_i<TABCONTENT['row'];css_i++) {					
		for(var css_j=1;css_j<=total_content;css_j++){				
			if(temp[m]==''){			// if tab fields is empty
				e_css = 'r'+css_i+'c'+css_j+''+tab_count+'' ;
				empty_css(e_css,tab_count);
				document.getElementById('r'+css_i+'c'+css_j+''+tab_COUNT+'').innerHTML='&nbsp;';
			}else{						// if tab fields is non- empty.
				c_css = 'r'+css_i+'c'+css_j+''+tab_count+'' ;
				content_css(c_css,tab_count);
				document.getElementById('r'+css_i+'c'+css_j+''+tab_COUNT+'').innerHTML=temp[m];	
			}				
			m++;
		}			
	}		
}
		
		
	function empty_css(e_css,tab_count){		// if tab fields is empty this function calling 
			
		document.getElementById(e_css).style.cssText=''+tabcontent_btnfocus_flag[tab_count].e_content+'';    //"color:green;";
			
	}
	
	
	function content_css(c_css,tab_count){		// if tab fields is non - empty this unction calling
		
		document.getElementById(c_css).style.cssText=''+tabcontent_btnfocus_flag[tab_count].content+'';    //"color:green;";
			
	}
	
		
function inbulidtab_css(){
	//alert(tab_count);
	document.getElementById('r1c11').style.cssText=''+tabcontent_btnfocus_flag[tab_COUNT].focus_on+'';
	
}




