	function $_rgb(id)
	{
		return document.getElementById(id);
	}
	function hide(id)
	{
		$_rgb(id).style.display = 'none';
	}
	function show(id)
	{
		$_rgb(id).style.display = 'block';
	}
	function isHidden(id)
	{
		if($_rgb(id).style.display == 'none')
			return true;
		else
			return false;
	}
	function V_switch(id)
	{
		if(isHidden(id))
			show(id);
		else
			hide(id);
	}
													
function processData(responseText, responseStatus)
 { 
	
	//document.getElementById('loadingbar').style.display ='none';
	if (responseStatus==200) // succes
	{
		if(responseText == 'error')
						alert('Error updating data!'+responseText);
		else
		{
			eval(responseText);
			
		}
	 }
	else if(responseStatus == 0)
	{
	
	}
	else 
	{ 
	   alert(responseStatus + ' -- Error Processing Request');
	}
  }
function ajaxObject(url) {
	  var that=this;      
	   this.updating = false;
		  this.abort = function() {
				that.AJAX.onreadystatechange = function () {}
			  that.updating=false;
			  that.AJAX.abort();
			  that.AJAX=null;
			
		  }
	  this.update = function(form,postMethod) { 
		if(that.updating) that.abort();
		 that.AJAX = null;                      
		 var passData = getFormValues(form,"validate");
		 
		 
				
		if (window.XMLHttpRequest) {              
		  that.AJAX=new XMLHttpRequest();              
		} else {                                  
		  that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
		}                                             
		if (that.AJAX==null) {                             
		  return false;                               
		} else {
		
			
			  that.AJAX.onreadystatechange = function() {  
				if (that.AJAX.readyState==4) {             
				  that.updating=false;                
				  that.callback(that.AJAX.responseText,that.AJAX.status);        
				  that.AJAX=null;                                         
				} 
				}
			                                                
		  that.updating = new Date();                              
		  if (/post/i.test(postMethod)) {
			var uri=urlCall+'?'+that.updating.getTime();
			that.AJAX.open("POST", uri, true);
			that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
			that.AJAX.setRequestHeader("Content-Length", passData.length);
			that.AJAX.send(passData);
		  } else {
			var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
			that.AJAX.open("GET", uri, true);                             
			that.AJAX.send(null);                                         
		  }              
		  return true;                                             
		}                                                                           
	  }
	  var urlCall = url;        
	  this.callback = processData;
	  }
	  
	  var myRequest = new ajaxObject('get_album_details.php');		
function getFormValues(fobj,valFunc, url) 
	
	{ 
	
	   var str = ""; 
	
	   var valueArr = null; 
	
	   var val = ""; 
	
	   var cmd = ""; 
	
	   for(var i = 0;i < fobj.elements.length;i++) 
	
	   { 
	
		   switch(fobj.elements[i].type) 
	
		   { 
			case "checkbox":
					var myval = fobj.elements[i].checked;
					if(myval) 
						myval = 1;
					else
						myval = 0;								   
				   str += fobj.elements[i].name + 
	
					"=" + myval + "&"; 
	
					   break; 
			  case "textarea":
				 str += fobj.elements[i].name + 
	
						 "=" + escape(fobj.elements[i].value) + "&"; 
						 break; 
		   
				case "password":
					str += fobj.elements[i].name + 
	
						 "=" + escape(fobj.elements[i].value) + "&"; 

						  break; 
				case "hidden":
					str += fobj.elements[i].name + 

					 "=" + (fobj.elements[i].value) + "&"; 
					  break; 
			   case "text": 
	
							
					str += fobj.elements[i].name + 
	
					 "=" + escape(fobj.elements[i].value) + "&"; 
	
					 break; 
	
			   case "select-one": 
	
					str += fobj.elements[i].name + 
	
					"=" + fobj.elements[i].options[fobj.elements[i].selectedIndex].value + "&"; 
	
					break; 
	
		   } 
	
	   } 
							
				
					 
					 
	   str = str.substr(0,(str.length - 1)); 
	
	   return str; 
	
	}
	
	function popup(url,winName,W,H,X,Y) {
			if(W == undefined) W = 400;	//default width
			if(H == undefined) H = 300; //default height
			if(X == undefined) X = screen.width/2-W/2; //default Xpos (is now centered)
			if(Y == undefined) Y = screen.height/2-H/2; //default Ypos (is now centered)
			X = 10;
			Y = 10;
		
			winprops = 'height='+H+',width='+W+',top='+X+',left='+Y+',scrollbars=yes, resizable=yes';
		
			win = window.open(url, winName, winprops);
			if (parseInt(navigator.appVersion) >= 4) {
				win.window.focus();
			}
		}
		function disclaimer()
		{
		popup(stricturl+"disclaimer.php",'disclaimer',500,600,10,10)
		}
var current_topbtn = null;
function topBtnOver(id )
{
	if(!id) id = 2;
	if(id == current_topbtn) return;
	for(var i=1; i<=4; i++)
	{
		$_rgb('topmenu_'+i).className = 'topbtn';			
	}
	$_rgb('topmenu_'+id).className = 'topbtn_act';
	current_topbtn = id;
	
}



// GALLY
var timeout = 5000;
var imgurl = "";
var timer = null;
var current_id = 0;

function showActiveGallery(myimgurl)
{
	imgurl = myimgurl;
	
	var str = "";
	
	
	str = "<img onload='done_loading(0);' src='"+imgurl+""+array_src[0]+"'/>";
	$_rgb('gally_imgholder').innerHTML = str;
	
	
	
	
	
	
	
		
	clearTimeout(timer);
		
	// set timers
	
	timer = setTimeout("loadPicture("+(((current_id)%(array_src.length))+1)+")",timeout);
	
	//attempt preload
	nextimg = new Image(); 
	nextimg.src = ""+imgurl+array_src[(((current_id)%(array_src.length)))]+"";
	
}
function gally_go(param)
{
	if(param == 1)
		loadPicture( ((current_id+1)%(array_src.length)) );
	else if(param == -1)
	{
		if( current_id > 0) loadPicture( ((current_id-1)) ); else loadPicture(array_src.length-1);
	}
}
function done_loading(id)
{
	

}
function setActive(id)
{
	
	
	
}

function loadPicture(id)
{
	current_id = id;
	var str = "";
	
	
	
	str = "<img  onload='done_loading("+id+");' src='"+imgurl+array_src[(id)]+"'/>";
	$_rgb('gally_imgholder').innerHTML = str;	
	
	
	clearTimeout(timer);
	
	timer = setTimeout("loadPicture("+(((current_id+1)%(array_src.length)))+")",timeout);

	// attempt preloading next pic
	nextimg = new Image(); 
	nextimg.src = ""+imgurl+array_src[(((current_id)%(array_src.length)))]+"";
	
	
}




// main gallery stuff
function initGal(imgs)
{	
	
	PreLoad2 = new Image();
	PreLoad2.src = imgs;
	
}



function submitNewsletter()
{
	myRequest.update($_rgb('index_newsletter_form'),'POST');	
}

function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
{
submitNewsletter();
return false;
}
else
return true;
}

function addClassName(objElement, strClass, blnMayAlreadyExist){
   if ( objElement.className ){
      var arrList = objElement.className.split(' ');
      if ( blnMayAlreadyExist ){
         var strClassUpper = strClass.toUpperCase();
         for ( var i = 0; i < arrList.length; i++ ){
            if ( arrList[i].toUpperCase() == strClassUpper ){
               arrList.splice(i, 1);
               i--;
             }
           }
      }
      arrList[arrList.length] = strClass;
      objElement.className = arrList.join(' ');
   }
   else{  
      objElement.className = strClass;
      }
}

//http://www.bigbold.com/snippets/posts/show/2630
function removeClassName(objElement, strClass){
   if ( objElement.className ){
      var arrList = objElement.className.split(' ');
      var strClassUpper = strClass.toUpperCase();
      for ( var i = 0; i < arrList.length; i++ ){
         if ( arrList[i].toUpperCase() == strClassUpper ){
            arrList.splice(i, 1);
            i--;
         }
      }
      objElement.className = arrList.join(' ');
   }
}

var last_id = null;
function accordeon(id, activeclass)
{
	if(last_id == id) return;
	last_id = id;
	
	var elem1 = null;
	var elem2 = null;
	
	if(id == 1)
	{
		 elem1 = $_rgb('widget-1');
		elem2 = $_rgb('widget-2');
		seth1 = h1;
		seth2 = h2;
		addClassName($_rgb('button-1'), activeclass);
		removeClassName($_rgb('button-2'), activeclass);
	}else if (id == 2)
	{
		elem1 = $_rgb('widget-2');
		elem2 = $_rgb('widget-1');
		seth1 = h2;
		seth2 = h1;
		addClassName($_rgb('button-2'), activeclass);
		removeClassName($_rgb('button-1'), activeclass);
	}
	
	var my_seq = new Parallel();
	elem1.style.display="block";
	
	t1 = new Tween(elem2.style,'height',Tween.regularEaseOut,seth2,0,0.75,'px')

	my_seq.addChild(new Tween(elem1.style,'height',Tween.regularEaseOut,0,seth1,0.75,'px'));
	my_seq.addChild(t1);
	my_seq.onMotionFinished = function(){  elem2.style.display="block"  };
	my_seq.start();
		
}

function move(id, value)
{
	visible = 800;
	unit_w = 110;
	var c = $_rgb(id);
	units = c.children.length;
	max_w = units*unit_w;
	scale = (max_w - 800)/100;
	if(max_w <= 800) scale = 0;
	
	c.style.left = -(value*scale)+"px";

}
function getCar(id)
{
	$_rgb('getcarid').value = id;
	myRequestCar.update( $_rgb('carform')  , 'POST');
}


// END GALLY
