var clicked = "features";
var last_clicked_id = "features";
var last_class = "stompio_top_menu_col";

var clicked_i = "ampi";
var last_clicked_id_i = "ampi";
var last_class_i = "left_in_button";

var clicked_v = "vauno";
var last_clicked_id_v = "vauno";
var last_class_v = "videolist-ul-a";

var mf_flag = false;
var car_flag = false;
var default_img ="";
var default_txt ="";
var default_index = 0;
var mycarousel_itemList;
var current_zoom = 1;
var current_page = "";
var current_1x = "";
var current_2x = "";
var current_3x = "";
var current_name = "";
var width_limit = 0;
var height_limit = 0; 
var counter_nw = 0;


var max_x;
var max_y;
var min_x;
var min_y;
var inc_x;
var inc_y;
var timerID = null;
var timerID1 = null;

var vertical_detail_height = 304;
var vertical_detail_width = 400;
var vertical_detail_height_txt = 266;
var vertical_detail_width_txt = 470;
var zoom_max_width = 800;
var zoom_min_width = 482;

function set_max(mxx,mxy,minx){
	max_x = mxx;
	max_y = mxy;
	min_x = minx;
	min_y = parseInt(min_x/max_x)*max_y;
	inc_x = 10;
	inc_y = parseInt(10/max_x) * max_y;	
}

function set_min(minx){
	
}

function mycarousel_itemLoadCallback(carousel, state){
//	 default_index = 0;
    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
            continue;
        }

        if (i > mycarousel_itemList.length) {
            break;
        }

        carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[i-1]));
		  default_index++;	
    }
//	 show_img( default_img ,'detail');
};

function mycarousel_itemLoadCallback_v(carousel, state){
//	 default_index = 0;
    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
            continue;
        }

        if (i > mycarousel_itemList.length) {
            break;
        }

        carousel.add(i, mycarousel_getItemHTML_v(mycarousel_itemList[i-1]));
		  default_index++;
    }
//	 show_img_v( default_img ,'detail');
//	 show_txt( default_txt,'txt','stomp');
};

function mycarousel_itemLoadCallback_txt(carousel, state){
//  default_index = 0;
    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
            continue;
        }

        if (i > mycarousel_itemList.length) {
            break;
        }

        carousel.add(i, mycarousel_getItemHTML_txt(mycarousel_itemList[i-1]));
        default_index++;
    }
//  show_img_v( default_img ,'detail');
//  show_txt( default_txt,'txt','stomp');
};


function mycarousel_itemLoadCallback_mic(carousel, state){
//	 default_index = 0;
    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
            continue;
        }

        if (i > mycarousel_itemList.length) {
            break;
        }

        carousel.add(i, mycarousel_getItemHTML_mic(mycarousel_itemList[i-1]));
		  default_index++;
    }
//	 show_img_mic( default_img ,'detail');
	 
};

function mycarousel_itemLoadCallback_generic(carousel, state){
//	 default_index = 0;
    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
            continue;
        }

        if (i > mycarousel_itemList.length) {
            break;
        }

        carousel.add(i, mycarousel_getItemHTML_generic(mycarousel_itemList[i-1]));
		  default_index++;	 
    }
//	 show_img_generic( default_img ,'detail');
};


function set_defaults(i_page,i_name,i_x1,i_x2,i_x3,i_w,i_h){
	current_zoom = 1;
	current_1x = i_x1;
	current_2x = i_x2;
	current_3x = i_x3;
	current_page = i_page;
	current_name = i_name;
}

function get_download_link(){
	sr = "img/"+current_page+"/download/"+current_name; 
	window.open(sr,'newwin'+counter_nw);
	counter_nw++;
}

function get_download_link_mono(){
	sr = current_page+"/download/"+current_name; 
	window.open(sr,'newwin'+counter_nw);
	counter_nw++;
}

function mycarousel_getItemHTML(item){

	if(default_index == 0){
		default_img = item.big_x1;	
		show_img( default_img ,'detail');
		show_txt(item.txt,'txt','stomp');
		set_defaults(item.page, item.name, item.big_x1, item.big_x2, item.big_x3, 100, 280);
	}

	return "<img src=\"" + item.small + "\" onMouseOver=\"this.className='bordoblue'\" onMouseOut=\"this.className='nobordo'\" onClick=\"show_txt('" + item.txt + "','txt','stomp'); show_img('" + item.big_x1 + "','detail'); set_defaults('"+ item.page +"', '"+ item.name +"', '"+ item.big_x1 +"', '"+ item.big_x2 +"', '"+ item.big_x3 +"',100,280);\" />\n";
};

function mycarousel_getItemHTML_v(item){
	if(default_index == 0){
//		if(car_flag){
	      default_img = item.big_x1;
			default_txt = item.txt;
			show_img_v( default_img ,'detail'); 
			show_txt(item.txt,'txt','stomp');
			set_defaults( item.page, item.name, item.big_x1, item.big_x2, item.big_x3);
//			car_flag = false;
//		}
   }
	return "<img src=\"" + item.small + "\" onMouseOver=\"this.className='bordoblue'\" onMouseOut=\"this.className='nobordo'\" onClick=\"show_txt('" + item.txt + "','txt','stomp'); show_img_v('" + item.big_x1 + "','detail'); set_defaults('"+ item.page +"', '"+ item.name +"', '"+ item.big_x1 +"', '"+ item.big_x2 +"', '"+ item.big_x3 +"');\" />\n";
};

function mycarousel_getItemHTML_txt(item){
   if(default_index == 0){
//    if(car_flag){
         default_img = item.big_x1;
         default_txt = item.txt;
         show_img_txt( default_img ,'detail');
         show_txt(item.txt,'txt','stomp');
         set_defaults( item.page, item.name, item.big_x1, item.big_x2, item.big_x3, 470, 266);
//       car_flag = false;
//    }
   }
   return "<img src=\"" + item.small + "\" onMouseOver=\"this.className='bordoblue'\" onMouseOut=\"this.className='nobordo'\" onClick=\"show_txt('" + item.txt + "','txt','stomp'); show_img_txt('" + item.big_x1 + "','detail'); set_defaults('"+ item.page +"', '"+ item.name +"', '"+ item.big_x1 +"', '"+ item.big_x2 +"', '"+ item.big_x3 +"');\" />\n";
};



function mycarousel_getItemHTML_generic(item){
	 if(default_index == 0){
      default_img = item.big_x1;
		show_img_generic( default_img ,'detail');
		set_defaults( item.page, item.name, item.big_x1, item.big_x2, item.big_x3);
//		alert(default_img);
    }	
    return "<img src=\"" + item.small + "\" onMouseOver=\"this.className='bordoblue'\" onMouseOut=\"this.className='nobordo'\" onClick=\"show_img_generic('" + item.big_x1 + "','detail'); set_defaults('"+ item.page +"', '"+ item.name +"', '"+ item.big_x1 +"', '"+ item.big_x2 +"', '"+ item.big_x3 +"');\" />\n";
};

function mycarousel_getItemHTML_mic(item){
	if(default_index == 0){
      default_img = item.big_x1;
		show_img_mic( default_img ,'detail');
		show_txt(item.txt,'txt','stomp'); 
		set_defaults(item.page, item.name, item.big_x1, item.big_x2, item.big_x3);
   }
	return "<img src=\"" + item.small + "\" onMouseOver=\"this.className='bordoblue'\" onMouseOut=\"this.className='nobordo'\" onClick=\"show_txt('" + item.txt + "','txt','stomp'); show_img_mic('" + item.big_x1 + "','detail'); set_defaults('"+ item.page +"', '"+ item.name +"', '"+ item.big_x1 +"', '"+ item.big_x2 +"', '"+ item.big_x3 +"');\" />\n";
};

function start_carousel(){
	jQuery(document).ready(function() {
    	jQuery('#mycarousel').jcarousel({
        	size: mycarousel_itemList.length,
	        itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback}
    	});
	});
}

function start_carousel_zero(){
   jQuery(document).ready(function() {
      jQuery('#mycarousel').jcarousel({
//         size: mycarousel_itemList.length,
         itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback}
      });
   });
}

function start_carousel_v(){
	jQuery(document).ready(function() {
		jQuery('#vcarousel').jcarousel({
			vertical: true,
			scroll: 1,
			size: mycarousel_itemList.length,
	        itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback_v}
		});
	});
}

function start_carousel_txt(){
   jQuery(document).ready(function() {
      jQuery('#vcarousel').jcarousel({
         vertical: true,
         scroll: 1,
         size: mycarousel_itemList.length,
           itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback_txt}
      });
   });
}


function start_carousel_mic(){
	jQuery(document).ready(function() {
		jQuery('#vcarousel').jcarousel({
			vertical: true,
			scroll: 1,
			size: mycarousel_itemList.length,
	        itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback_mic}
		});
	});
}

function start_carousel_generic(){
   jQuery(document).ready(function() {
    jQuery('#gcarousel').jcarousel({
        vertical: true,
        scroll: 1,
		  size: mycarousel_itemList.length,
           itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback_generic}	
    });
   });

}


function get_interface(pag){
	new Ajax.Request('switch_server.php?page=' + pag, {
  		method:'get',
  		onSuccess: function(transport){
     		var json = transport.responseText.evalJSON();
			current_zoom = 1;
			current_page = "";
			current_1x = "";
			current_2x = "";
			current_3x = "";
			mycarousel_itemList = json;
			start_carousel();
   		}
	});
	
}

function get_interface_v(pag){
	new Ajax.Request('switch_server.php?page=' + pag, {
  		method:'get',
  		onSuccess: function(transport){
     		var json = transport.responseText.evalJSON();
			current_zoom = 1;
			current_page = "";
			current_1x = "";
			current_2x = "";
			current_3x = "";
			mycarousel_itemList = json;
			start_carousel_v();
   		}
	});
}

function get_interface_txt(dir){
   new Ajax.Request('txt_server.php?dir=' + dir, {
      method:'get',
      onSuccess: function(transport){
         var json = transport.responseText.evalJSON();
         current_zoom = 1;
         current_page = "";
         current_1x = "";
         current_2x = "";
         current_3x = "";
         mycarousel_itemList = json;
         start_carousel_txt();
         }
   });
}

function get_interface_generic(pag){
   new Ajax.Request('switch_server.php?page=' + pag, {
      method:'get',
      onSuccess: function(transport){
         var json = transport.responseText.evalJSON();
         current_zoom = 1;
         current_page = "";
         current_1x = "";
         current_2x = "";
         current_3x = "";
         mycarousel_itemList = json;
         start_carousel_generic();
         }
   }); 
}

function get_interface_mic(pag){
	new Ajax.Request('switch_server.php?page=' + pag, {
  		method:'get',
  		onSuccess: function(transport){
     		var json = transport.responseText.evalJSON();
			current_zoom = 1;
			current_page = "";
			current_1x = "";
			current_2x = "";
			current_3x = "";
			mycarousel_itemList = json;
			start_carousel_mic();
   		}
	});
}

function show_img(trg,div,xmin){
	$(div).innerHTML = "<img id='img1' src='" + trg + "'>";
	imgtd = $('img1');
	width_limit = imgtd.width;
	height_limit = imgtd.height;
	set_max(imgtd.width,imgtd.height,100);
	imgtd.width = min_x;
}


function show_image(nome,div,flag,op){
	if(flag){
		$(div).innerHTML = "<img id='img1' src='" + trg + "'>";
	}
	$(div).innerHTML = "<img id='img1' src='" + trg + "'>";
	
	imgtd = $('img1');
	set_max(imgtd.width,imgtd.height,100);
	imgtd.width = min_x;
}	


function show_img_v(trg,div,xmin){
	$(div).innerHTML = "<img id='img1' src='" + trg + "'>";
	imgtd = $('img1');
	width_limit = imgtd.width;
	height_limit = imgtd.height;
	set_max(imgtd.width,imgtd.height,400);
	imgtd.width = min_x;
}

function show_img_txt(trg,div,xmin){
   $(div).innerHTML = "<img id='img1' src='" + trg + "'>";
   imgtd = $('img1');
   width_limit = imgtd.width;
   height_limit = imgtd.height;
   set_max(imgtd.width,imgtd.height,470);
   imgtd.width = min_x;
}


function show_img_generic(trg,div,xmin){
   $(div).innerHTML = "<img id='img1' src='" + trg + "'>";
   imgtd = $('img1');
   width_limit = imgtd.width;
   height_limit = imgtd.height;
   set_max(imgtd.width,imgtd.height,500);
   imgtd.width = min_x;
}

function show_img_mic(trg,div,xmin){
	$(div).innerHTML = "<img id='img1' src='" + trg + "'>";
	
	imgtd = $('img1');
	
	width_limit = imgtd.width;
	height_limit = imgtd.height;
	
	set_max(imgtd.width,imgtd.height,200);
	imgtd.width = min_x;
}

function show_txt(name,div){
	load('interface_server.php', 'display=' + name, div);
}

/*
function init_stomp(){
	zoom_max_width = 300;
	zoom_min_width = 150;
	vertical_detail_height = 280;
	vertical_detail_width = 100;
	str = '<div class="caraousel"><div id="wrap"><ul id="mycarousel" class="jcarousel-skin-tango"></ul></div></div>';
	str += '<div id="detail" class="caraousel_detail_enlarge">&nbsp;</div><div id="txt" class="caraousel_detail_text">&nbsp;</div>';
	$('main').innerHTML = str;
	get_interface('stomp');
}

function init_vertical(pages){
	zoom_max_width = 850;
	zoom_min_width = 424;
	vertical_detail_height = 195;
	vertical_detail_width = 400;
	str = '<div class="caraousel_v"><div id="wrap"><ul id="vcarousel" class="jcarousel-skin-tango-v"></ul></div></div>';
              	str += '<div id="detail" class="caraousel_detail_enlarge_v">&nbsp;</div><div id="txt" class="caraousel_detail_text_v">&nbsp;</div>';
	$('main').innerHTML = str;
	get_interface_v(pages);
}

function init_vertical_mic(pages){
	zoom_max_width = 800;
	zoom_min_width = 400;
	vertical_detail_height = 197;
	vertical_detail_width = 200;
	str = '<div class="caraousel_mic"><div id="wrap"><ul id="vcarousel" class="jcarousel-skin-tango-micro"></ul></div></div>';
	str += '<div id="detail" class="caraousel_detail_enlarge_mic">&nbsp;</div><div id="txt" class="caraousel_detail_text_mic">&nbsp;</div>';
	$('main').innerHTML = str;
	get_interface_mic(pages);
}

function init_vertical_rack(pages){
	zoom_max_width = 800;
	zoom_min_width = 400;
	vertical_detail_height = 48;
	vertical_detail_width = 400;
	str = '<div class="caraousel_v"><div id="wrap"><ul id="vcarousel" class="jcarousel-skin-tango-rack"></ul></div></div>';
	str += '<div id="detail" class="caraousel_detail_enlarge_rack">&nbsp;</div><div id="txt" class="caraousel_detail_text_rack">&nbsp;</div>';
	$('main').innerHTML = str;
	get_interface_v(pages);
}

function init_tuner(pages){
   zoom_max_width = 800;
   zoom_min_width = 400;
   vertical_detail_height = 195;
   vertical_detail_width = 400;
   str = '<div class="caraousel_v"><div id="wrap"><ul id="vcarousel" class="jcarousel-skin-tango-v"></ul></div></div>';
               str += '<div id="detail" class="caraousel_detail_enlarge_tuner">&nbsp;</div><div id="txt" class="caraousel_detail_text_tuner">&nbsp;</div>';
   $('main').innerHTML = str;
   get_interface_v(pages);
}

function init_other(pages){
   zoom_max_width = 850;
   zoom_min_width = 482;
   vertical_detail_height = 227;
   vertical_detail_width = 400;
   str = '<div class="caraousel_v"><div id="wrap"><ul id="vcarousel" class="jcarousel-skin-tango-other"></ul></div></div>';
               str += '<div id="detail" class="caraousel_detail_enlarge_other">&nbsp;</div><div id="txt" class="caraousel_detail_text_other">&nbsp;</div>';
   $('main').innerHTML = str;
   get_interface_v(pages);
}

function init_generic(page){		//'moreinfo3'){
	zoom_max_width = 800;
   zoom_min_width = 400;
   vertical_detail_height = 300;
   vertical_detail_width = 500;
   str = '<div class="caraousel_generic_v"><div id="wrap"><ul id="gcarousel" class="jcarousel-skin-tango-generic-v"></ul></div></div>';
               str += '<div id="detail" class="caraousel_detail_enlarge_v_generic">&nbsp;</div>';
   $('main').innerHTML = str;
   get_interface_generic(page);	
}
*/

function zoom(type,imgx,sz) {
	imgd = $(imgx);
	
	x = imgd.width;
	y = imgd.height;
	by = (( 2/x )*y );

	if (type=="+"){	// && imgd.width < 175) {
		imgd.width += 2; imgd.height += by;
	}
	if (type=="-"){	// && imgd.width > 20) {
		imgd.width -= 2;imgd.height -= by;
	}
}

function zoom1(type,imgx) {
	imgd = $(imgx);
	
	if (type=="+" && imgd.width < (zoom_max_width)){	// && imgd.hight < max_y) {
		imgd.width += imgd.width * 0.1;
	}
	
	if (type=="-" && imgd.width > (zoom_min_width)){	// && imgd.hight > min_y) {
		imgd.width -= imgd.width * 0.1;	
	}
	timerID = window.setTimeout(function(){	zoom1(type,imgx);	},100);
}

function zoom_in() {
	if(current_page != ""){
		if(current_zoom == 1){
			current_zoom = 2;
			$('detail').innerHTML = "<img id='img1' src='" + current_2x +"' style='cursor:move;'>";

			img_zoom2 = new Draggable('img1',{ ghosting: false, handle: 'detail', 
                     revert: function(){
                        x_p = 0;
                        y_p = 0;
                        if(   ($('img1').width + $('img1').offsetLeft) < vertical_detail_width  ){
                           x_p = vertical_detail_width - ($('img1').offsetLeft+$('img1').width);
                           //new Effect.Move('img1',{x: x_p, y:0, mode: 'relative', duration: 0.12, queue: {position:'end', scope: 'menuxscope'} });
                        }
                        if( ($('img1').width + $('img1').offsetLeft) > $('img1').width ){
                           x_p = $('img1').width - ($('img1').width + $('img1').offsetLeft);
                           // new Effect.Move('img1',{x: x_p, y:0, mode: 'relative', duration: 0.12, queue: {position:'end', scope: 'menuxscope'} });
                        }
                        if(   ($('img1').height + $('img1').offsetTop) >  $('img1').height   ){ 
                           y_p = $('img1').height - ($('img1').height + $('img1').offsetTop );
                           // new Effect.Move('img1',{x: 0, y: y_p, mode: 'relative', duration: 0.12, queue: {position:'end', scope: 'menuxscope'} });
                        }
                        if( ($('img1').height + $('img1').offsetTop) < vertical_detail_height ){
                           y_p = vertical_detail_height - ($('img1').height + $('img1').offsetTop);
                           // new Effect.Move('img1',{x: 0, y: y_p, mode: 'relative', duration: 0.12, queue: {position:'end', scope: 'menuxscope'} });
                        }
                        new Effect.Move('img1',{x: x_p, y: y_p, mode: 'relative', duration: 0.02 });
                        
                     }
                  });
         Droppables.add('detail', { accept:'caraousel_detail_enlarge_v', containment: 'detail', greedy: true});

		}else{
			if(current_zoom == 2){	
				current_zoom = 3;
				$('detail').innerHTML = "<img id='img1' src='" + current_3x +"' style='cursor:move;'>";
				img_zoom3 = new Draggable('img1',{ ghosting: false, handle: 'detail', 
                     revert: function(){
                        x_p = 0;
                        y_p = 0;
                        if(   ($('img1').width + $('img1').offsetLeft) < vertical_detail_width  ){
                           x_p = vertical_detail_width - ($('img1').offsetLeft+$('img1').width);
                        // new Effect.Move('img1',{x: x_p, y:0, mode: 'relative', duration: 0.12, queue: {position:'end', scope: 'menuxscope'} });
                        }
                        if( ($('img1').width + $('img1').offsetLeft) > $('img1').width ){
                           x_p = $('img1').width - ($('img1').width + $('img1').offsetLeft);
                        // new Effect.Move('img1',{x: x_p, y:0, mode: 'relative', duration: 0.12, queue: {position:'end', scope: 'menuxscope'} });
                        }
                        if(   ($('img1').height + $('img1').offsetTop) >  $('img1').height   ){ 
                           y_p = $('img1').height - ($('img1').height + $('img1').offsetTop );
                        // new Effect.Move('img1',{x: 0, y: y_p, mode: 'relative', duration: 0.12, queue: {position:'end', scope: 'menuxscope'} });
                        }
                        if( ($('img1').height + $('img1').offsetTop) < vertical_detail_height ){
                           y_p = vertical_detail_height - ($('img1').height + $('img1').offsetTop);
                        // new Effect.Move('img1',{x: 0, y: y_p, mode: 'relative', duration: 0.12, queue: {position:'end', scope: 'menuxscope'} });
                        }
                        new Effect.Move('img1',{x: x_p, y: y_p, mode: 'relative', duration: 0.12 });
                     }
                  });
         Droppables.add('detail', { accept:'caraousel_detail_enlarge_v', containment: 'detail', greedy: true});
			}
		}
	}
}

function zoom_out() {

	if(current_page != ""){
		if(current_zoom == 3){
			current_zoom = 2;
			$('detail').innerHTML = "<img id='img1' src='" + current_2x +"'  style='cursor:move;'>";
			img_zoom2 = new Draggable('img1',{ ghosting: false, handle: 'detail',
                     revert: function(){
                        x_p = 0;
                        y_p = 0;
                        if(   ($('img1').width + $('img1').offsetLeft) < vertical_detail_width  ){
                           x_p = vertical_detail_width - ($('img1').offsetLeft+$('img1').width);
                           //new Effect.Move('img1',{x: x_p, y:0, mode: 'relative', duration: 0.12, queue: {position:'end', scope: 'menuxscope'} });
                        }
                        if( ($('img1').width + $('img1').offsetLeft) > $('img1').width ){
                           x_p = $('img1').width - ($('img1').width + $('img1').offsetLeft);
                           // new Effect.Move('img1',{x: x_p, y:0, mode: 'relative', duration: 0.12, queue: {position:'end', scope: 'menuxscope'} });
                        }
                        if(   ($('img1').height + $('img1').offsetTop) >  $('img1').height   ){
                           y_p = $('img1').height - ($('img1').height + $('img1').offsetTop );
                           // new Effect.Move('img1',{x: 0, y: y_p, mode: 'relative', duration: 0.12, queue: {position:'end', scope: 'menuxscope'} });
                        }
                        if( ($('img1').height + $('img1').offsetTop) < vertical_detail_height ){
                           y_p = vertical_detail_height - ($('img1').height + $('img1').offsetTop);
                           // new Effect.Move('img1',{x: 0, y: y_p, mode: 'relative', duration: 0.12, queue: {position:'end', scope: 'menuxscope'} });
                        }
                        new Effect.Move('img1',{x: x_p, y: y_p, mode: 'relative', duration: 0.02 });
                        
                     }
                  });
         Droppables.add('detail', { accept:'caraousel_detail_enlarge_v', containment: 'detail', greedy: true});
		}else{
			if(current_zoom == 2){	
				current_zoom = 1;
				$('detail').innerHTML = "<img id='img1' src='" + current_1x +"'>";
			}
		}
	}
}

function start_zoom(type,imgx) {
	timerID = window.setTimeout(function(){ zoom1(type,imgx); },100);
}

function stop_zoom() {
	new Effect.Move('img1',{x: 0, y:0, mode: 'absolute', duration: 0.2, beforeStart: function(){
		window.clearTimeout(timerID);
	}});
}

function center_img(){
	new Effect.Move('img1',{x: 0, y:0, mode: 'absolute', duration: 0.4});
}

function mov(direction){
	if(direction == 'left'){
		if(	($('img1').width > vertical_detail_width)	&& (	($('img1').width + $('img1').offsetLeft) >= vertical_detail_width	)	){
			new Effect.Move('img1',{x: -1, y:0, mode: 'relative', duration: 0.005});
		}
	}
	if(direction == 'right'){
		if(	($('img1').width > vertical_detail_width)	&& (	($('img1').width + $('img1').offsetLeft) <= $('img1').width	)	){
			new Effect.Move('img1',{x: 1, y:0, mode: 'relative', duration: 0.005});
		}
	}
	if(direction == 'down'){
		if(	($('img1').height > vertical_detail_height)	&& (	($('img1').height + $('img1').offsetTop) <=  $('img1').height	)	){	
			new Effect.Move('img1',{x: 0, y: 1, mode: 'relative', duration: 0.005});
		}
	}
	if(direction == 'up'){
		if(	($('img1').height > vertical_detail_height)	&&	( ($('img1').height + $('img1').offsetTop) >= vertical_detail_height )	){
			new Effect.Move('img1',{x: 0, y:-1, mode: 'relative', duration: 0.005});
		}
	}
	timerID1 = window.setTimeout(function(){ mov(direction); },0.001);
}

function start_mov(direction) {
	timerID1 = window.setTimeout(function(){ mov(direction); },0.001);
}

function stop_mov() {
	window.clearTimeout(timerID1);
}

function check_pos(){
	a = parseInt( $('img1').width - $('img1').offsetLeft );

	if($('img1').offsetLeft <0){
		b = 0 - $('img1').offsetLeft;
	}else{
		b = $('img1').offsetLeft;
	}
	
	if(	( $('img1').width - 400 ) <  $('img1').offsetLeft){
		return false;
	}else{
		return true;
	}
}

function show_html_txt(name,div)	{
	load('html_server.php', 'page_name=' + name, div);
}

function show_php_txt(name,div) {
   load('php_server.php', 'page_name=' + name, div);
}


function show_php_news(name,div,newsid,backpars){
//   load('news_php_server.php', 'page_name=' + name + '&newsid=' + newsid, div);
	load('NewsDisplay.php','Id='+newsid+backpars, div);
}

function show_php_news_list(pars,div){
//   load('news_php_server.php', 'page_name=' + name + '&newsid=' + newsid, div);
   load('news_server.php',pars , div);
}

//function set_back_link(val){
//	window.history.previous=val;
//}


function remove_generic(div) {
  var d = document.getElementById('center_main_col');
  var olddiv = document.getElementById(div);
  d.removeChild(olddiv);
}

function check_mf(div1,div2){
	if(mf_flag){
		mf_flag = false;
		remove_generic(div1);
		remove_generic(div2);	
	}
}

function open_video(vid,div){
   $(div).innerHTML = "&nbsp;";
   outcode = "<object width=\"425\" height=\"355\">"+
             "<param name=\"movie\" value=\"http://www.youtube.com/v/"+ vid +"&rel=1\"></param>"+
             "<param name=\"wmode\" value=\"transparent\"></param>"+
             "<embed src=\"http://www.youtube.com/v/"+vid+"&rel=1\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"425\" height=\"355\">"+
             "</embed></object>";
   $(div).innerHTML = outcode;
}


// PRELOAD IMAGES START

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// PRELOAD IMAGES STOP


// MAILING LIST START

function validate_form() {
	validity = true; // assume valid
  // do any sort of checks you want here such as:
	if (!check_email(document.form.r_email.value.toLowerCase()))
	{ validity = false; alert('Please insert a valid e-mail address!'); }
	else {
   alert('Thank you for joining the mailing list!\nYou will be notified about news and updates.');
   validity = true; }
  return validity;
}
function check_email(address) {
   var checkTLD=1;
   var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
   var emailPat=/^(.+)@(.+)$/;
   var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
   var validChars="\[^\\s" + specialChars + "\]";
   var quotedUser="(\"[^\"]*\")";
   var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
   var atom=validChars + '+';
   var word="(" + atom + "|" + quotedUser + ")";
   var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
   var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
   var matchArray=address.match(emailPat);
   if (matchArray==null) {
      return false;
   }
   var user=matchArray[1];
   var domain=matchArray[2];
   for (i=0; i<user.length; i++) {
      if (user.charCodeAt(i)>127) {
         return false;
      }
   }
   for (i=0; i<domain.length; i++) {
      if (domain.charCodeAt(i)>127) {
         return false;
      }
   }
   if (user.match(userPat)==null) {
      return false;
   }
   var IPArray=domain.match(ipDomainPat);
   if (IPArray!=null) {
      for (var i=1;i<=4;i++) {
         if (IPArray[i]>255) {
            return false;
         }
      }
      return true;
   }
   var atomPat=new RegExp("^" + atom + "$");
   var domArr=domain.split(".");
   var len=domArr.length;
   for (i=0;i<len;i++) {
      if (domArr[i].search(atomPat)==-1) {
         return false;
      }
   }
   if (checkTLD && domArr[domArr.length-1].length!=2 &&
      domArr[domArr.length-1].search(knownDomsPat)==-1) {
      return false;
   }
   if (len<2) {
      return false;
   }
   return true;
}

// MAILING LIST STOP



