$(function() {

	
	var screenwidth=window.screen.width;
	
	screenwidth=1380;
	if(screenwidth>=1340)
	{
		$(".toparea").css({"width":"1340px"});	
		$(".footer").css({"width":"1340px"});
		$(".main").css({"width":"1340px"});
	}	
	else if(screenwidth>1024&&screenwidth<1340)
	{
		$(".toparea").css({"width":screenwidth+"px"});	
		$(".footer").css({"width":screenwidth+"px"});
		$(".main").css({"width":screenwidth+"px"});	
	}
	else
	{
		$(".toparea").css({"width":"1001px"});	
		$(".footer").css({"width":"1001px"});
		$(".main").css({"width":"1001px"});		
	}
	
	
	
	var wrapwith=$(".main").width();
    //alert(wrapwith);
    var left=(1366-wrapwith)/2;
    $("#productswfbox").css({"left":-left+"px"});

					
});		


function AtmBox()
{
	
	/*Image Player Start*/

	$(".EzinePlay").each(function(i){
		
		var run=true;
		var speed=5000;
		var playindex = 0;
		var imgObj=$(this).find(".ImgBox img");
		var imglist=$(this).find(".smallbank a");
		var imglen=imglist.length;
		
		
		
		if(imglen<=0){
		   $(this).hide();
		   return;
		}
		
		var $this=$(this);
		
		speed=$this.find(".SpeedBox .speed").val()*1000;
		
		var count=imglen;

		var w=873;
		var h=444;

		
		var inner="";
		
		inner+="<div class=\"box\" style=\"width:"+w*count+"px;height:"+h+"px;\">";
		
		for(var j=0;j<count;j++)
		{
			inner+="<div style=\"width:"+w+"px;height:"+h+"px;float:left;\"></div>";	
		}
		
		inner+="</div>";
		
		
		$this.find(".ImgBox").html(inner);
		
		ShowImg();
		
		var Interval;
		
		if (run){
             Interval = setInterval(function () { 
				Next();
								   
			}, speed);
		}
		
			
		$this.find(".Page-Prev").click(function(){
			
			if(playindex>0)
			{
				playindex--;
			}
			else
			{
				playindex=imglen-1;
			}		
			
			ShowImg();
			
		});
		
		$this.find(".Page-Next").click(function(){
			if(playindex<imglen-1)
			{
				playindex++;
			}
			else
			{
				playindex=0;
			}
						
			ShowImg();
			
			
		});
		
		
		$this.find(".Page-First").click(function(){
			playindex=0;
						
			ShowImg();
			
		});
		
		$this.find(".Page-Last").click(function(){
			playindex=imglen-1;
						
			ShowImg();

		});
		
		$this.find(".Page-Exit").click(function(){
			history.back();
		});
		
		var speedObj=$this.find(".SpeedBox .speed");
		
		speedObj.keyup(function(){
														 
			var isNumber = /^[-\+]?\d+(\.\d+)?$/;
			if(!isNumber.test(speedObj.val()))
			{
				speedObj.val("5");							  
			}
			
			speed=speedObj.val()*1000;
			
			clearInterval(Interval);
			
			Interval = setInterval(function () { 
				Next();
								   
			}, speed);
			
		});

		
		
		function ShowImg()
		{
			var src=imglist.eq(playindex).attr("rel");
			//imgObj.hide().attr("src",src).fadeIn();	
			
			var img = new Image();
			$(img).load(function () {

				//$this.find('.loadings').addClass('hidden');
				$this.find(".ImgBox .box div").eq(playindex).html("<img src=\""+src+"\">");
			
				$this.find(".ImgBox .box").animate({'margin-left': -w*playindex+'px'}, "");
				
			}).error(function () {
				//alert('e');
			}).attr('src', src);
			
		}
		
		function Next()
		{
				if(playindex<imglen-1)
				{
					playindex++;
				}
				else
				{
					playindex=0;
				}
							
				ShowImg();
		}
		
		
		
	
		
	});
	
	/*Image Player End*/
}

				
