var dynamicContent_ajaxObjects = new Array();
function ajax_loadContent(divId,pathToFile)
{
	
	var ajaxIndex = dynamicContent_ajaxObjects.length;
	dynamicContent_ajaxObjects[ajaxIndex] = new sack();
	dynamicContent_ajaxObjects[ajaxIndex].requestFile = pathToFile;
	document.getElementById(divId).innerHTML = 'Loading content...';
	dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function (){ ajax_showContent(divId,ajaxIndex); };
	dynamicContent_ajaxObjects[ajaxIndex].runAJAX();
}
function ajax_showContent(divId,ajaxIndex){
	document.getElementById(divId).innerHTML = dynamicContent_ajaxObjects[ajaxIndex].response;
}
function adjustRatio(img){
	if(window.innerHeight < img.height){
	img.style.height = '100%';
	img.style.width = 'auto';
	}else if(window.innerWidth < img.width){
	img.style.width = '100%';
	img.style.height = 'auto';
	}
}
function addnote(id){
	var x=prompt("Add note (64 chars max)");	
	if(x.length > 0){
		var fn='http://' + window.location.hostname + '/scripts/addnote.php?i=' + id + '&x='+x;
		ajax_loadContent(id,fn);
	}
}
function clearnote(id){
	var fn='http://' + window.location.hostname + '/scripts/clearnote.php?i=' + id;
	ajax_loadContent(id,fn);
}
function editnote(id,note){
	var x=prompt("Add note (64 chars max)", note);	
	if(x.length > 0){
		var fn='http://' + window.location.hostname + '/scripts/addnote.php?i=' + id + '&x='+x;
		ajax_loadContent(id,fn);
	}
}
function charts(buysell,domain){
	if(buysell == 2){
		document.getElementById('graph_sold').src='http://traffic.alexa.com/graph?w=228&h=130&r=3m&y=r&u=' + domain;
		document.getElementById('alexa_sold').href='http://www.alexa.com/data/details/traffic_details/' + domain;
	}else{
		document.getElementById('graph_bought').src='http://traffic.alexa.com/graph?w=228&h=130&r=3m&y=r&u=' + domain;
		document.getElementById('alexa_bought').href='http://www.alexa.com/data/details/traffic_details/' + domain;
	}
}
function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";path=/;expires="+exdate.toGMTString()+";domain=.urlashare.com;");
}
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 toggle_ticker() {
	if(document.getElementById('markie').style.visibility == 'hidden'){
		setCookie('ticker',0,-1);
		show_ticker();
	}else{
		hide_ticker();		
	}
}
function show_ticker() {
	var sticker = document.cookie.indexOf('ticker=');
	//alert(sticker);
	if(sticker == -1){
		document.getElementById('ticker').style.height = '100%';
		document.getElementById('markie').style.height = '100%';
		document.getElementById('markie').style.visibility = 'visible';
		document.getElementById('toggle').innerHTML="<a href=\'javascript:toggle_ticker()\' style=\'font-size:13px;\'>HIDE TICKER</a>";
	}else{
		document.getElementById('ticker').style.height = '15pt';
		document.getElementById('markie').style.height = '0px';	
		document.getElementById('markie').style.visibility = 'hidden';
		document.getElementById('toggle').innerHTML="<a href=\'javascript:toggle_ticker()\' style=\'font-size:13px;\'>SHOW TICKER</a>";			
	}
}

function hide_ticker() {
	document.getElementById('ticker').style.height = '15pt';
	document.getElementById('markie').style.height = '0px';	
	document.getElementById('markie').style.visibility = 'hidden';
	document.getElementById('toggle').innerHTML="<a href=\'javascript:toggle_ticker()\' style=\'font-size:13px;\'>SHOW TICKER</a>";
	setCookie('ticker',1,365);
}

var o_LMarquees = [], o_LMrunning,
	o_Interv =        30,     //interval between increments
	o_Step =          2,      //number of pixels to move between increments
	o_LMDirection =     'left'; //'left' for LTR text, 'right' for RTL text


var o_RMarquees = [], o_RMrunning,
	o_RMDirection =     'right'; //'left' for LTR text, 'right' for RTL text

/***     Do not edit anything after here     ***/
function slow_down(){
	o_Interv = 50;
	o_Step = 1;
}

function speed_up(){
	o_Interv = 30;
	o_Step = 2;
}

function do_Marquees() {
	if( o_LMarquees.length && o_RMarquees.length || !document.getElementsByTagName ) { return; }
	var o_Divs = document.getElementsByTagName('div');
	for( var i = 0, o_Div; i < o_Divs.length; i++ ) {
		o_Div = o_Divs[i];
		if( o_Div.className && o_Div.className.match(/\bmarquee_left\b/) ) {
			if( !( o_Div = o_Div.getElementsByTagName('div')[0] ) ) { continue; }
			if( !( o_Div.mchild = o_Div.getElementsByTagName('div')[0] ) ) { continue; }
			o_Div.mchild.style.cssText += ';white-space:nowrap;';
			o_Div.mchild.style.whiteSpace = 'nowrap';
			o_Div.style.height = o_Div.offsetHeight + 'px';
			o_Div.style.overflow = 'hidden';
			o_Div.style.position = 'relative';
			o_Div.mchild.style.position = 'absolute';
			o_Div.mchild.style.top = '0px';
			o_Div.mchild.style[o_LMDirection] = o_Div.offsetWidth + 'px';
			o_LMarquees[o_LMarquees.length] = o_Div;
			i += 2;
		}else if( o_Div.className && o_Div.className.match(/\bmarquee_right\b/) ) {
			if( !( o_Div = o_Div.getElementsByTagName('div')[0] ) ) { continue; }
			if( !( o_Div.mchild = o_Div.getElementsByTagName('div')[0] ) ) { continue; }
			o_Div.mchild.style.cssText += ';white-space:nowrap;';
			o_Div.mchild.style.whiteSpace = 'nowrap';
			o_Div.style.height = o_Div.offsetHeight + 'px';
			o_Div.style.overflow = 'hidden';
			o_Div.style.position = 'relative';
			o_Div.mchild.style.position = 'absolute';
			o_Div.mchild.style.top = '0px';
			o_Div.mchild.style[o_RMDirection] = o_Div.offsetWidth + 'px';
			o_RMarquees[o_RMarquees.length] = o_Div;
			i += 2;			
		}
	}
	o_LMrunning = setInterval('ani_Marquees()',o_Interv);
}
function ani_Marquees() {
	var o_LDiv, o_LPos;
	var o_RDiv, o_RPos;
	for( var i = 0; i < o_LMarquees.length; i++ ) {
		o_LDiv = o_LMarquees[i].mchild;
		o_LPos = parseInt(o_LDiv.style[o_LMDirection]);
		if( o_LPos <= -1 * o_LDiv.offsetWidth ) {
			o_LDiv.style[o_LMDirection] = o_LMarquees[i].offsetWidth + 'px';
		} else {
			o_LDiv.style[o_LMDirection] = ( o_LPos - o_Step ) + 'px';
		}
		o_RDiv = o_RMarquees[i].mchild;
		o_RPos = parseInt(o_RDiv.style[o_RMDirection]);		
		if( o_RPos <= -1 * o_RDiv.offsetWidth ) {
			o_RDiv.style[o_RMDirection] = o_RMarquees[i].offsetWidth + 'px';
		} else {
			o_RDiv.style[o_RMDirection] = ( o_RPos - o_Step ) + 'px';
		}
	}
}



if( window.addEventListener ) {
	window.addEventListener('load',do_Marquees,false);
} else if( document.addEventListener ) {
	document.addEventListener('load',do_Marquees,false);
} else if( window.attachEvent ) {
	window.attachEvent('onload',do_Marquees);
}