
var hiclip_animate = {};
function hiclip_amt(obj, ns){

	if(typeof obj.style == "object" && typeof obj.style.backgroundImage=="string" && obj.style.backgroundImage){
		var matchtype="backgroundImage";
		var matchurl = obj.style.backgroundImage;
		
	} else {
		var matchtype="src";
		var matchurl = obj.src;
	}


	var a = matchurl.match(/vid=([0-9]+)&/);
	var b = matchurl.match(/vkey=([a-zA-Z0-9]+)&/);
	var c = matchurl.match(/([0-9]+)_([a-zA-Z0-9]+)_/);
	
		if(a && b){ // thumb
			
			var mid='im'+ns+'_'+a[1]+b[1];
			obj.id=mid;
		  	hiclip_animate[mid]=1;
			if( document.getElementById && document.childNodes && document.createElement ) {
			   var jsel = document.createElement('SCRIPT');
			   jsel.type = 'text/javascript';
			   jsel.src = obj.src+"&js=1&ns="+ns;
			   document.body.appendChild(jsel);
			} 			
		  obj.onmouseout  = function() {
			  	hiclip_animate[mid]=0;
	      };
		} else if (obj.id || c) {
			
			if(c && (!obj.id || matchtype=="backgroundImage")){ // xml
				var mid='im'+ns+'_'+c[1]+c[2];
				obj.id=mid;	
				  obj.onmouseout  = function() {
					  	hiclip_animate[mid]=0;
			      };
			  	hiclip_animate[obj.id]=0;
			}
			if(hiclip_animate[obj.id]==0){
			  	hiclip_animate[obj.id]=1;
				hiclip_amt_do(obj.src, obj.id, 2, matchtype)
			}
		}
}
function hiclip_amt_do(src, id, i, matchtype){
	var im=document.getElementById(id);
	
	if(matchtype=="backgroundImage"){
		var ims = im.style.backgroundImage.replace(/_[0-9]\.jpg/g, "_"+i+".jpg");
		im.style.backgroundImage=ims;
	} else {
		var ims = src.replace(/_[0-9]\.jpg/g, "_"+i+".jpg");
		im.src=ims;
	}
	if(i<9 && hiclip_animate[id]==1){
		window.setTimeout( function() {hiclip_amt_do(src, id, ++i, matchtype);},1000);
	} else {
	
			
		if(matchtype=="backgroundImage"){
			var ims = im.style.backgroundImage.replace(/_[0-9]\.jpg/g, "_1.jpg");
			im.style.backgroundImage=ims;
			
		} else {
			var ims = src.replace(/_[0-9]\.jpg/g, "_1.jpg");
			im.src=ims;
		}
		
		
	}
}

