

function onloadEvent(funcToLoad) {

  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = funcToLoad;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      funcToLoad();
    }
  }
}


function changeImage(imageId){
	if(slideShowEnabled == 1) disableSlideShow();
	if(document.getElementById('mainImage') && document.getElementById('img'+imageId)){
		document.getElementById('mainImage').src = document.getElementById('img'+imageId).src;
		imgNumber = imageId;
	}
}

function changeGalleryPagination(value){
	if(document.getElementById('galPag'+value)){
		document.getElementById('galPag'+value).style.display = 'block';
	}
	
	if(document.getElementById('galPag'+galleryImage)) {
		document.getElementById('galPag'+galleryImage).style.display = 'none';
	}
	galleryImage = value;
}

function changerDisplay(id){
	if(document.getElementById(id)){
		if(document.getElementById(id).style.position == 'absolute'){
			document.getElementById(id).style.position = 'static';
			document.getElementById(id).style.left = '0px';
		} else if(document.getElementById(id).style.position == 'static'){
			document.getElementById(id).style.position = 'absolute';
			document.getElementById(id).style.left = '-500000px';
		}
	}
	
}
function playSlideShow(){
	if(slideShowEnabled == 1){
		if(document.getElementById('img'+slideShowImage)){
			if(document.getElementById('mainImage') && document.getElementById('img'+slideShowImage)){
				document.getElementById('mainImage').src = document.getElementById('img'+slideShowImage).src;
				imgNumber = slideShowImage;
				if(slideShowImage < maxNumber){
					++slideShowImage;
				} else {
					slideShowImage = 1;
				}
			}
			t=setTimeout("playSlideShow()",4000);
		}
	}
}

function enableSlideShow(){
	slideShowEnabled = 1;
	if(document.getElementById('playSlide')) document.getElementById('playSlide').style.display = 'none';
	if(document.getElementById('stopSlide')) document.getElementById('stopSlide').style.display = 'inline';
}

function disableSlideShow(){
	slideShowEnabled = 0;
	clearTimeout(t);
	if(document.getElementById('playSlide')) document.getElementById('playSlide').style.display = 'inline';
	if(document.getElementById('stopSlide')) document.getElementById('stopSlide').style.display = 'none';
}

function getSiMigrationId(){
	var c_name = "SIVISITOR";
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1){
	    		c_start=c_start + c_name.length+1;
	    		c_end=document.cookie.indexOf(";",c_start);
	   		if (c_end==-1) c_end=document.cookie.length;
	   		return unescape(document.cookie.substring(c_start,c_end));
	    	}
	  }
	return "";
}
// Blank method introduced to avoid java-script error when live chat is turned off
/**
function lpAddVars(scope,name,value) {
	
}
**/

