var scroll_pixels=131;


function setCookie(c_name,value,expiredays,path)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+";path="+path+";";

}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function copy_to_clip_url()
{
	var page_url = document.getElementById('page_url');
	if (page_url)
	{
		page_url.select()
		clipboardData.setData('Text',page_url.value)
	}
}

function copy_to_clip_embed()
{
	var embed_code = document.getElementById('embed_code');
	if (embed_code)
	{
		embed_code.select()
		clipboardData.setData('Text',embed_code.value)
	}
}

function scroll_artist_clips(obj)
{
	var artist_clips = document.getElementById('artist_clips');
	var scroll_for_artist_clips = document.getElementById('scroll_for_artist_clips');
	
	if (artist_clips.scrollHeight>scroll_for_artist_clips.scrollHeight) 
	{
		
		scroll_for_artist_clips.innerHTML="<img src='/pixel.gif' style='border:none;' width=1 height="+artist_clips.scrollHeight+">";
	}
	artist_clips.scrollTop=Math.floor(scroll_for_artist_clips.scrollTop/130)*130;
	if (artist_id>0) setCookie("a"+artist_id,artist_clips.scrollTop,1,"/track/"+artist_id);
	

	var relatedImages = artist_clips.getElementsByTagName("img");
	//alert (relatedImages.length);
	pos=Math.ceil(scroll_for_artist_clips.scrollTop/130);
//document.title=pos;
	for (i=0; i<relatedImages.length; i++)
	{
		
		if ((i>(pos-2))&&(i<(pos+6)))
		{
			//alert (relatedImages[i].alt);
			if (relatedImages[i].alt!="")
			{
				relatedImages[i].src=relatedImages[i].alt
				relatedImages[i].alt=""
			}
		}
	}
	
}


function scroll_related_clips()
{
	
	var related_clips=document.getElementById ('related_videos');

	var relatedImages = related_clips.getElementsByTagName("img");
	//alert (relatedImages.length);
	pos=Math.ceil(related_clips.scrollTop/88);
//document.title=pos;
	for (i=0; i<relatedImages.length; i++)
	{
		
		if ((i>(pos-2))&&(i<(pos+8)))
		{
			//alert (relatedImages[i].alt);
			if (relatedImages[i].alt!="")
			{
				relatedImages[i].src=relatedImages[i].alt
				relatedImages[i].alt=""
			}
		}
	}
	
}


function init_scroll_bar()
{
	var artist_clips = document.getElementById('artist_clips');
	var scroll_for_artist_clips = document.getElementById('scroll_for_artist_clips');
	scroll_for_artist_clips.innerHTML="<img src='/pixel.gif' style='border:none;' width=1 height="+artist_clips.scrollHeight+">";//artist_clips.innerHTML
	scroll_for_artist_clips.style.height=artist_clips.style.height
	var scroll_pos=parseInt(getCookie("a"+artist_id));
	if (scroll_pos)
	{
		//alert (scroll_pos+"\r\n"+scroll_for_artist_clips.scrollTop+"\r\n"+artist_clips.scrollTop);
		scroll_for_artist_clips.scrollTop=scroll_pos;
		artist_clips.scrollTop=scroll_for_artist_clips.scrollTop;
		if (scroll_for_artist_clips.scrollTop!=scroll_pos)
		{
			scroll_for_artist_clips.innerHTML="<img src='/pixel.gif' style='border:none;' width=1 height="+(scroll_pos+650)+">";//artist_clips.innerHTML
			//alert (scroll_pos+"\r\n"+scroll_for_artist_clips.innerHTML);
			scroll_for_artist_clips.scrollTop=scroll_pos;
			//scroll_for_artist_clips.style.height=(scroll_pos+650);
		}
	}
	
	
		
	scroll_artist_clips(artist_clips);
}



function scroll_artist_clips_by_timeout(obj)
{
	var artist_clips = document.getElementById('artist_clips');
	var scroll_for_artist_clips = document.getElementById('scroll_for_artist_clips');
	
	if (artist_clips.scrollHeight>scroll_for_artist_clips.scrollHeight) 
	{
		scroll_for_artist_clips.innerHTML="<img src='/pixel.gif' style='border:none;' width=1 height="+artist_clips.scrollHeight+">";
	}
	artist_clips.scrollTop=Math.floor(scroll_for_artist_clips.scrollTop/130)*130;
	//if (artist_id>0) setCookie("a"+artist_id,artist_clips.scrollTop,1,"/track/"+artist_id);
}

function scroll_down()
{
	var artist_clips = document.getElementById('artist_clips');
	var scroll_for_artist_clips = document.getElementById('scroll_for_artist_clips');
	scroll_for_artist_clips.onscroll="";
	for (i=1;i<scroll_pixels;i++)
	{
		artist_clips.scrollTop=artist_clips.scrollTop+1;
		scroll_for_artist_clips.scrollTop=artist_clips.scrollTop;
	}
	scroll_for_artist_clips.onscroll=function() {scroll_artist_clips(this)};
	if (artist_id>0) setCookie("a"+artist_id,artist_clips.scrollTop,1,"/track/"+artist_id);
}



function scroll_up()
{
	var artist_clips = document.getElementById('artist_clips');
	var scroll_for_artist_clips = document.getElementById('scroll_for_artist_clips');
	if (artist_clips.scrollTop>scroll_pixels) 
	{
		scroll_for_artist_clips.onscroll="";
		for (i=1;i<scroll_pixels;i++)
		{
			artist_clips.scrollTop=artist_clips.scrollTop-1;
			scroll_for_artist_clips.scrollTop=artist_clips.scrollTop;
		}
		scroll_for_artist_clips.onscroll=function() {scroll_artist_clips(this)};
	}
	else
	{
		artist_clips.scrollTop=0;
		scroll_for_artist_clips.scrollTop=0;
	}
	if (artist_id>0) setCookie("a"+artist_id,artist_clips.scrollTop,1,"/track/"+artist_id);
}