var photoGallery = {
	hideelements:function(n){
		for(i=1; i<=n; i++) {
			$('#bigImage'+i).css({'display':'none'})
		}
	},
	removeclass:function(n) {
		for(i=0; i<n; i++) {
			$('.thumb').eq(i).removeClass('active')
		}
	},
	addclass:function(e){
		e.addClass('active')
	},
	animation:function(e){
		e.fadeIn('slow')
	},
	changetitle:function(title){
		$('#bigImageTitle').text(title)
	},
	
	initialize:function(){ // initialize function starts
		thumbs=$('.thumb').length;
		current=$('.thumb.active').children('a').attr('rel');
		current=parseInt(current.substr(8,1))
		
		$('.thumb').click(function(a){
			photoGallery.removeclass(thumbs)
			photoGallery.hideelements(thumbs)
			photoGallery.addclass($(this))
			photoGallery.animation($('#'+$(this).children('a').attr('rel')))
			photoGallery.changetitle($(this).children('a').attr('title'))
			current=$('.thumb.active').children('a').attr('rel');
			current=parseInt(current.substr(8,1))
		})
		
		
		$('#nextArrow').click(function(){
			if(current>=thumbs) {
				current=0;
			}
			current++;
			photoGallery.removeclass(thumbs)
			photoGallery.addclass($('.thumb').eq(current-1))
			photoGallery.hideelements(thumbs)
			photoGallery.animation($('#bigImage'+(current)))
			photoGallery.changetitle($('.thumb').eq(current-1).children('a').attr('title'))
		})
		
		$('#previousArrow').click(function(){
			current--;
			if(current<1){
				current=thumbs	
			}
			
			photoGallery.removeclass(thumbs)
			photoGallery.addclass($('.thumb').eq(current-1))
			photoGallery.hideelements(thumbs)
			photoGallery.animation($('#bigImage'+(current)))
			photoGallery.changetitle($('.thumb').eq(current-1).children('a').attr('title'))
		})
	} // initialize function ends
}


var win = null;
function OpeVidWin(url,name,title) {
	xhtml='<embed src="http://www.4shared.com/flash/flvplayer.swf" style="width:400px;height:326px" allowscriptaccess="always" allowfullscreen="true" flashvars="file='+url+'&autostart=true"></embed>';
	
	//xhtml='<embed src="http://www.4shared.com/flash/flvplayer.swf" style="width:400px;height:326px" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="true" flashvars="file=http://dc152.4shared.com/img/'+arr[0]+'/'+arr[1]+'/dlink__2Fdownload_2F'+arr[0]+'_2F'+arr[1]+'_3Fdsid_3DJGITKOINJZHYGJIAJPJYHXISIQKIJFIVHXHZHYJIIZJBJPIWKSIRKQITIGJTIAGHGCIAHYJHINIQKVKU/preview.flv&image=http://dc152.4shared.com/img/'+arr[0]+'/'+arr[1]+'/'+arr[2]+'&autostart=true"></embed>
	//}
	
	left = (screen.width) ? (screen.width-400)/2 : 0;
	top = (screen.height) ? (screen.height-326)/2 : 0;
	var settings = 'width=440';
	settings += ', height=375';
	settings += ', top='+top+', left='+left;
	settings += ', directories=no';
	settings += ', location=no';
	settings += ', menubar=no';
	settings += ', resizable=no';
	settings += ', scrollbars=no';
	settings += ', status=0';
	settings += ', toolbar=no';
	win = window.open("",name,settings);
	win.document.write('<html>'+
					   		'<head>'+
								'<title>'+title+' Video</title>'+
							'</head>'+
							'<body style="magin:10px; background:#000; color:#fff; font:11px/1.5em Arial">'+
								'<div style="text-align:center; margin:0 0 5px; border-bottom:1px dashed #999;"><b>Video by :</b> '+title+'</div>'+
								'<div style="text-align:center;">'+xhtml+'</div>'+
								'<script type="text/javascript">'+
									'window.status="'+title+'"'+
								'</script>'+
							'</body>'+
					  	'</html>');
}

