function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function addResizeEvent(func) {
  var oldonresize = window.onresize;
  if (typeof window.onresize != 'function') {
    window.onresize = func;
  } else {
    window.onresize = function() {
      oldonresize();
      func();
    }
  }
}

// Submits the form when search button is clicked
function search() {
  document.searchFrm.submit();
}

// Removes leading whitespaces
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function Trim( value ) {
	return LTrim(RTrim(value));
}

// Displays the Search Text when the Text Box is empty
function searchTextDisplay() {
  str = Trim(document.searchFrm.searchTxt.value).length;
  if(str == 0) {
    document.searchFrm.searchTxt.value=document.searchFrm.searchTxtDisplay.value;
  }
}



//////////////// below was added for image scroll//////////////////
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function addResizeEvent(func) {
  var oldonresize = window.onresize;
  if (typeof window.onresize != 'function') {
    window.onresize = func;
  } else {
    window.onresize = function() {
      oldonresize();
      func();
    }
  }
}


/////////////////
var left_position=0;
       
function TextScroll(scrollname, div_name, up_name, down_name)
{
 
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    //this.speed = 10;
	this.speed = 6;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;

{
        if (document.getElementById) {
        	div_obj = document.getElementById(this.div_name);
        
            if (div_obj) {
            	this.div_obj = div_obj;
                this.div_obj.style.overflow = 'hidden';
            }
            div_up_obj = document.getElementById(this.up_name);

            div_dn_obj = document.getElementById(this.dn_name);

			/* newly added - to position the cursor*/
			if (left_position > 0) {
			//document.body.onload = function() { eval(scrollname + ".scrollDownLittle();") }	
				window.onload = function() { eval(scrollname + ".scrollDownLittle();") }	
			}
			/* ends */

            if (div_up_obj && div_dn_obj) {

            	//IE ondersteunt geen setAttribute, dus dan maar op de vieze manier
        		div_up_obj.onmouseover = function() { eval(scrollname + ".scrollUp();") }
				div_up_obj.onmouseout = function() { eval(scrollname + ".stopScroll();")}
                div_up_obj.style.cursor = 'pointer';

	    		div_dn_obj.onmouseover = function() { eval(scrollname + ".scrollDown();") }
				div_dn_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") }
	            div_dn_obj.style.cursor = 'pointer';

            }
        }
    }

this.stopScroll = function() {
		clearTimeout(this.timeoutID);
    }

this.scrollUp = function() {
	    if (this.div_obj) {
            this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
            this.div_obj.scrollLeft = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
        }
    }

this.scrollDown = function() {
        if (this.div_obj) {
            this.scrollCursor += this.speed;
            this.div_obj.scrollLeft = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
        }
    }

/* newly added - to position the cursor*/
this.scrollDownLittle = function() {		
        if (this.div_obj) {			
            this.scrollCursor += left_position;
            this.div_obj.scrollLeft = this.scrollCursor;
        }
    }
/* newly added - ends*/


this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollLeft = 0;
            this.scrollCursor = 0;
        }
    }
}
////////////////////////
var left_position=0;

			var scrolldan = new TextScroll('scrolldan', 'prodscroller', 'links', 'rechts');

			function getCursorPosition() {
				return scrolldan.scrollCursor;
			}			

			function show_url(temp_url,titel_url,image_count) {
				//var cursor_position = getCursorPosition();

				/*alert('cursorpos='+cursor_position);
				alert('image_count='+image_count);

				var hidden_image_count = '';

				hidden_image_count = cursor_position/128;
				alert('hidden_image='+hidden_image_count);

				hidden_image_count = Math.ceil(hidden_image_count);

				if (image_count <= hidden_image_count) {
					cursor_position = 0;
				}*/

				var image_end_position  = (image_count * 1) * 128;

				var visibility_area		= 822;

				var cursor_position		= image_end_position - visibility_area;

				if (cursor_position < 0) {
					cursor_position = 0;
				}


				var redirect_url = '/paginas/showCase/'+temp_url+'/scrollPosition/'+cursor_position+'/fromPage/'+titel_url;
				window.location.href = redirect_url;				         
			}
///////////////above was added for image scroll////////////////////
