
function propergateformfeild(idname,valuetext){
values = jQuery(idname).attr('value');
if(values != valuetext && values == undefined){
jQuery(idname).attr('value',valuetext);
jQuery(idname).click(function(){
jQuery(idname).attr('value','');});}}
time = 8000;

var newimage = 0;
var totalimages = jQuery('#port li').length;

switchmov = 0;
currentnav = 0;
max_width = 0;
current = 0;
moveamount = "";
moveamountto = ""; 
speed = 1000;
main = "";

function moveto(inum){
	inum--;
	currentnav = inum;
	next = moveamount*inum;
	current = next;
	jQuery('#'+main).animate({scrollLeft:current}, speed);
	jQuery('#products_central a').removeClass('active');
	jQuery('#products_central a').eq(inum).addClass('active');
}

function moveleft(){


	if(current == max_width-moveamount){
	
	
	
	}else{
	
		currentnav++; 
		next = moveamount+current;
		current = next;
		jQuery('#'+main).animate({scrollLeft:current}, speed);
		jQuery('#products_central a').removeClass('active');
		jQuery('#products_central a').eq(currentnav).addClass('active');
	
	}

}

function autoscroll(){
totalimages = jQuery('ul#mycarousel li').length;

if(switchmov == 0){

current = current-moveamount;

switchmov = 1;
currentnav = -1;
}else{




}



  if (newimage == totalimages) {
    newimage = 0;
  }

  setTimeout("autoscroll()", 1*time);
  newimage++;



	if(current == max_width-moveamount){
	
		current = 0;
		currentnav = 0;
		jQuery('#products_central a').removeClass('active');
		jQuery('#products_central a').eq(currentnav).addClass('active');
		jQuery('#'+main).animate({scrollLeft:current}, 10);
	
	}else{

		currentnav++; 
		next = moveamount+current;
		current = next;
		jQuery('#'+main).animate({scrollLeft:current}, speed);
		jQuery('#products_central a').removeClass('active');
		jQuery('#products_central a').eq(currentnav).addClass('active');
	
	}

}


function moveright(){

if(current > 0){
currentnav--;
next = current-moveamount;
current = next;
jQuery('#'+main).animate({scrollLeft: current}, speed);
	jQuery('#products_central a').removeClass('active');
	jQuery('#products_central a').eq(currentnav).addClass('active');
}
}



jQuery(document).ready(function(){
propergateformfeild('#searchme','search website:');
size = jQuery('ul#mycarousel li').size();

liwidth = jQuery('ul#mycarousel li').width();
moveamount = liwidth;

fullwidth = liwidth * size;
max_width = fullwidth;
parentid = jQuery('ul#mycarousel').parent().parent().attr('id');
main = parentid; 
jQuery('#'+main).animate({scrollLeft: 0}, speed);

jQuery('ul#mycarousel').css('position','absolute');
jQuery('ul#mycarousel').css('width',fullwidth+'px');
jQuery('ul#mycarousel').css('width',fullwidth+'px');
jQuery('ul#mycarousel li').css('float','left').css('margin','0px').css('padding','0px').css('width',liwidth).css('list-style','none');
jQuery('#'+parentid).css('overflow','hidden');

jQuery('#products_nav a.right').click(function(){
moveleft();


});

jQuery('#products_nav a.left').click(function(){
moveright();


});


jQuery('#products_central a').click(function(){


hpl = jQuery(this).html();

moveto(hpl);


});

autoscroll();
})