 var state_ready = true;
 var opacity_state_ready = true;
 var opacity_objects = true;
 var last_xmlhttp_status;
 var get_data;
 
 var global_fade_out = 1;
 var global_fade_in = 0;
 
 var set_images;
 var fade_out_min_value = 0;

 var gal_number_images = 0;
 var thumbs_limit = 0;
 var check_g_state_ready;
   
 var xmlhttp=false;
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (e) {
	   xmlhttp = false;
	  }
	 }
	  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	  xmlhttp = new XMLHttpRequest();
	}
	
var Browser = {
  Version: function() {
    var version = 999; // we assume a sane browser
    if (navigator.appVersion.indexOf("MSIE") != -1)
      // bah, IE again, lets downgrade version number
      version = parseFloat(navigator.appVersion.split("MSIE")[1]);
    return version;
  }
}	
	
 function generate_security_code(){
 		var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
		var string_length = 10;
		var random_code = '';
		for (var i=0; i<string_length; i++) {
			var rnum = Math.floor(Math.random() * chars.length);
			random_code += chars.substring(rnum,rnum+1);
		}
		return random_code;
 }
 


 var local_first_object = 0;
 var local_num_object = 0;
 var move_objects = 0;
 var counter = 410;
  
 function __checkGStateReady(){

 	if(global_fade_in < 1){
 		clearTimeout(check_g_state_ready);
		 		check_g_state_ready = setTimeout("__checkGStateReady();", 300);
 	}else{
 		clearTimeout(check_g_state_ready);
 		 			
		global_fade_out = 1;
		global_fade_in = 0;
					
		state_ready = true;
 	}
 }

 function setEGallery(num_images){ 
 	gal_number_images = num_images;
 	//alert(gal_number_images);

 }
 
 function __fade_out(object_prefix, num_objects){
 	
 	fade_out_min_value = (0.1 * num_objects)*(-1);
 	
 	for(var i=0; i<num_objects; i++){
 		if(document.getElementById(object_prefix + i)){
 		
 			__set_fade_out_opacity(object_prefix + i, global_fade_out);
 			
 			
 			//document.getElementById(object_prefix + i).style.filters.alpha.opacity=30;
 			
 		}
 		 
 	}
 	
 }
 
 function __set_fade_out_opacity(object_id, fade_out){
 	//fade_out -= 0.1;
 	fade_out = 0;

 	//document.getElementById(object_id).style.opacity=fade_out;
 	//document.getElementById(object_id).style.filter.alpha(opacity=80);
 	//alert(document.getElementById(object_id).style.opacity+' -- '+object_id);
 	var opacity;
 	if(fade_out >= 0){
	 	clearTimeout(opacity);
			if(opacity_state_ready){
					opacity = setTimeout("__set_fade_out_opacity('"+object_id+"', "+fade_out+")", 40);
			}else if(last_xmlhttp_status == 0){
				alert("Sorry there was a problem while executing your request!!\nPlease refresh your page!!");
			}
 	}
 	global_fade_out = fade_out;
 }
 
 
  function __fade_in(object_prefix, num_objects){
 	
 	for(var i=0; i<num_objects; i++){
 		
 		if(document.getElementById(object_prefix + i)){
 		
 			__set_fade_in_opacity(object_prefix + i, global_fade_in);
 		
 		}
 	}
 	
 }
 
 function __set_fade_in_opacity(object_id, fade_in){
 	//fade_in += 0.01;
 	fade_in = 1;
 	//document.getElementById(object_id).style.opacity=fade_in;
 	//alert(document.getElementById(object_id).style.opacity+' -- '+object_id);
 	//alert('fade in - '+fade_in);
 	//document.getElementById(object_id).style.filter.alpha(opacity=80);
 	var opacity;
 	if(fade_in < 1){
	 	clearTimeout(opacity);
			if(opacity_state_ready){
					opacity = setTimeout("__set_fade_in_opacity('"+object_id+"', "+fade_in+")", 40);
			}else if(last_xmlhttp_status == 0){
				alert("Sorry there was a problem while executing your request!!\nPlease refresh your page!!");
			}
 	} 	
 	global_fade_in = fade_in;
 }
 

  
  
  function move_objects_left(object_prefix, limit_from, url){
 	//alert(thumbs_limit);
 	if(thumbs_limit != 0){
	 	clearTimeout(move_objects);
			if(state_ready){
					move_objects = setTimeout("__move_objects_left('"+object_prefix+"',"+limit_from+", '"+url+"')", 40);
			}else if(last_xmlhttp_status == 0){
				alert("Sorry there was a problem while executing your request!!\nPlease refresh your page!!");
			}
 	}
 }
 
 
 
 function __move_objects_left(object_prefix, limit_from, url){
 	
 	if(state_ready){
		//alert('ahaa');
		if(document.getElementById('move_left_image').style.display == 'block'){
 		 			//document.getElementById('move_left_image').style.display = 'none';	
		 			//document.getElementById('move_right_image').style.display = 'none';	
		}
		/*
	 	clearTimeout(opacity_objects);
			if(state_ready){
					opacity_objects = setTimeout("__fade_out('"+object_prefix+"', 4)", 300);
					
			}else if(last_xmlhttp_status == 0){
				alert("Sorry there was a problem while executing your request!!\nPlease refresh your page!!");
			}
	 	
	 	*/
	 	
	 	clearTimeout(get_data);
				if(state_ready){
					
					limit_from = thumbs_limit = thumbs_limit-4;
					get_data = setTimeout("__get_http_data('"+object_prefix+"', "+limit_from+", '"+url+"');", 500);
				}else if(last_xmlhttp_status == 0){
					alert("Sorry there was a problem while executing your request!!\nPlease refresh your page.");
				}
				
				
	 	clearTimeout(check_g_state_ready);
				if(state_ready){
					check_g_state_ready = setTimeout("__checkGStateReady();", 350);
				}else if(last_xmlhttp_status == 0){
					alert("Sorry there was a problem while executing your request!!\nPlease refresh your page.");
				}
 	 }		
 	 
 }
  function move_objects_right(object_prefix, limit_from, url){
 	//alert(thumbs_limit);
 	if(gal_number_images >= (thumbs_limit+4)){ 	
	 	clearTimeout(move_objects);
			if(state_ready){
					move_objects = setTimeout("__move_objects_right('"+object_prefix+"',"+limit_from+", '"+url+"')", 40);
			}else if(last_xmlhttp_status == 0){
				alert("Sorry there was a problem while executing your request!!\nPlease refresh your page!!");
			}
	}
 	
 }
 
 
 
 function __move_objects_right(object_prefix, limit_from, url){
 	
 	if(state_ready){
		
		if(document.getElementById('move_left_image').style.display == 'block'){
 		 			//document.getElementById('move_left_image').style.display = 'none';	
		 			//document.getElementById('move_right_image').style.display = 'none';	
		}
		/*
	 	clearTimeout(opacity_objects);
			if(state_ready){
					opacity_objects = setTimeout("__fade_out('"+object_prefix+"', 4)", 300);
					
			}else if(last_xmlhttp_status == 0){
				alert("Sorry there was a problem while executing your request!!\nPlease refresh your page!!");
			}
	 	
	 	*/
	 	clearTimeout(get_data);
				if(state_ready){
					limit_from = thumbs_limit = thumbs_limit+4;
					get_data = setTimeout("__get_http_data('"+object_prefix+"', "+limit_from+", '"+url+"');", 500);
				}else if(last_xmlhttp_status == 0){
					alert("Sorry there was a problem while executing your request!!\nPlease refresh your page.");
				}
				
				
	 	clearTimeout(check_g_state_ready);
				if(state_ready){
					check_g_state_ready = setTimeout("__checkGStateReady();", 350);
				}else if(last_xmlhttp_status == 0){
					alert("Sorry there was a problem while executing your request!!\nPlease refresh your page.");
				}
 	 }		
 	 
 }
 
 function __get_http_data(object_prefix, limit_from, url){
 	
 	if(state_ready){
 		
	 	var get_url = '';
			
		get_url = url + "common/httpservices/get_exclusive_property.php?limit_from="+limit_from+"&sec_code="+generate_security_code();
		
		
			state_ready = false;
			xmlhttp.open("GET", get_url, true);
				 xmlhttp.onreadystatechange = function() {	
					if (xmlhttp.readyState == 4) {
						if(xmlhttp.status == 200){
							var response_text = xmlhttp.responseText;
							//var response_text_array = response_text;//.split('&');
	
								document.getElementById('exclusive_property_holder').innerHTML = response_text;
																
								state_ready = true;
								/*
								clearTimeout(opacity_objects);
									if(!state_ready){
											opacity_objects = setTimeout("__fade_in('"+object_prefix+"', 4)", 300);
									}else if(last_xmlhttp_status == 0){
										alert("Sorry there was a problem while executing your request!!\nPlease refresh your page!!");
									}
								*/
									
								__checkGStateReady();
								//setTimeout("state_ready = true; ", 3000);
								
						}
							
					}else if(xmlhttp.readyState == 0){
						alert("Sorry there was a problem while executing your request!!\nPlease refresh your page.");
					}
					last_xmlhttp_status = xmlhttp.readyState;
					
				};
			xmlhttp.send(null);	
 		
 	}
 	
 
 }
 		














