// JavaScript Document


var CREATE_POSITION=new Array();
var new_interval  = new  Array();
var preload_postion_COUNT=0;
var preload_postion_let= new Array();
var tot_content = new Array();	 
var preload_position_input_object_length=new Array();			


  	function cre_position(div_id,left_position,top_position){
		
//		alert(div_id+'...'+left_position+'..'+top_position);
		
		preload_postion_COUNT++;	
		this.div_id = div_id;
		this.left_position= left_position;
		this.top_position = top_position;
		this.cont_name;
		
		CREATE_POSITION[this.div_id] = new Object();	
		CREATE_POSITION[this.div_id].left_position = this.left_position;
		CREATE_POSITION[this.div_id].top_position = this.top_position;
		CREATE_POSITION[this.div_id].c_css =this.c_css ;
		
		// IE 
		tot_content['prefix']=(document.all)?'&nbsp;&nbsp;&nbsp;Loading<br>':'&nbsp;Loading'; 		// Prefix
		
	}
	
	cre_position.prototype.cre_div = function(){
		
		var div_id  =  this.div_id;
		var cre_td = document.getElementById(div_id);
		CREATE_POSITION[div_id].cre_div = document.createElement('div');
		CREATE_POSITION[div_id].cre_div.id = 'preload_postion_child_div_'+preload_postion_COUNT;		
		cre_td.appendChild(CREATE_POSITION[div_id].cre_div);		
		//CREATE_POSITION[div_id].cre_div.style.border="1px solid #ffcc00";
		document.getElementById('preload_postion_child_div_'+preload_postion_COUNT).style.cssText=' 	                       							        vertical-align:middle;text-align:center;width:20px;height:20px;position:absolute';
		CREATE_POSITION[div_id].cre_div.style.left=CREATE_POSITION[div_id].left_position+'px';
		CREATE_POSITION[div_id].cre_div.style.top=''+CREATE_POSITION[div_id].top_position+'px';
	}
	
	cre_position.prototype.preload_postion_screen_animation=function(cont_name,moving_speed){  

		preload_postion_let[preload_postion_COUNT]=0;		
		tot_content[preload_postion_COUNT]=cont_name;				
		// alert(tot_content[0]);
		this.cont_name=cont_name;
		this.moving_speed = moving_speed ;	
		var div_id  =  this.div_id;			
		multiplePlace(preload_postion_COUNT,div_id);		
		new_interval[div_id]=setInterval('preload_postion_input_screen('+preload_postion_COUNT+')',moving_speed); 	
	}	
	
		cre_position.prototype.setonClick = function(functionName) {
	
		eventFunc('click',functionName,this.div_id);
		
	}
	
	function eventFunc(eventHandle,functionName,div_id) {
			
		if(window.attachEvent){		
			//IE
			document.getElementById(CREATE_POSITION[div_id].cre_div.id).attachEvent("on"+eventHandle,functionName);
		
		}else {
			
			if(window.addEventListener) {
				// FireFox		
				document.getElementById(CREATE_POSITION[div_id].cre_div.id).addEventListener(eventHandle,functionName,false);
			}			
		}		
	}
	

	function preload_postion_input_screen(preload_postion_count) {								
	
		
		if(document.getElementById('preload_img_frame'+preload_postion_count)){
			
		var  preload_postion_images = new Array();  // Sample input
			
		preload_postion_images[preload_postion_count]= new Array();	
		
		preload_postion_images[preload_postion_count] = tot_content[preload_postion_count].split(",");
		
		preload_position_input_object_length[preload_postion_count]=preload_postion_images[preload_postion_count].length;
		
		document.getElementById('preload_img_frame'+preload_postion_count).innerHTML =preload_postion_images[preload_postion_count][preload_postion_let[preload_postion_count] % preload_position_input_object_length[preload_postion_count]];		
		
		preload_postion_let[preload_postion_count]++ ;		
		
		}
		
	}
	
	function multiplePlace(preload_postion_count,div_id) {		
		
		CREATE_POSITION[div_id].imageCount ='<div id="preload_img_frame'+preload_postion_count+'" name="preload_img_frame'+preload_postion_count+'" style="position:absolute;font-size:15px;"></div>';		
		
	//	alert(CREATE_POSITION[div_id].imageCount);
		document.getElementById('preload_postion_child_div_'+preload_postion_count).innerHTML+=tot_content['prefix']+CREATE_POSITION[div_id].imageCount;
		
	}	
	
	function handleClick1(){
	
		alert('welcome to Addevent');
		
	}
	
