function ajax_getTopPos(inputObj){
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
  	returnValue += inputObj.offsetTop;
  }
  return returnValue;
}
function ajax_getLeftPos(inputObj){
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
  return returnValue;
}

function make_send_sms(){
	var sms_imgs = document.getElementsByTagName('img');
	for(var i=0;i<sms_imgs.length;i++){		if (sms_imgs[i].className.substr(0,8) == 'send_sms'){			var tmp = document.getElementById('img_sms'+sms_imgs[i].className.substring(8,sms_imgs[i].className.length))			var img = document.createElement('img');
			img.style.top = (ajax_getTopPos(sms_imgs[i])+5)+'px';
			img.style.left = (ajax_getLeftPos(sms_imgs[i])+120)+'px';
			img.style.position = 'absolute';
			img.style.zIndex = '10';
			img.style.display = '';
			img.className = 'img_send_sms';
			img.title = tmp.title;
			img.src = tmp.src;
			img.style.width = '18px';
			img.style.height = '18px';
			img.alt = img.alt;
			img.style.cursor = 'help';
			img.model_id = sms_imgs[i].className.substring(8,sms_imgs[i].className.length);
			img.onclick = function(){				stop_show(this.model_id);				send_sms(this, this.model_id)			}
			tmp.parentNode.removeChild(tmp);
			document.body.appendChild(img);
		}
	}
}
var thumb = new Array;
var thumb_w = new Array;
var thumb_link = new Array;

function pre_start_show(model_id,link){	var timerid = window.setTimeout("start_show("+model_id+",'"+link+"');",500);
	document.getElementById('snapshot'+model_id).onmouseout = function(){		window.clearTimeout(timerid);	}}

function start_show(model_id,link){	stop_show(model_id);
	document.getElementById('snapshot'+model_id).onmouseover = null;
	var obj = document.getElementById('snapshot'+model_id);
	if (thumb_w[model_id]!=1){		thumb[model_id]=obj.innerHTML;
		thumb_link[model_id]=link;
		thumb_w[model_id]=1;
	}
	var html = '';
	html += '<div id="tmp_container'+model_id+'">Loading</div>';
	obj.innerHTML = html;


	var flashvars = {};
	flashvars.file = '/peep/pic_show.php%3Fmodel_id%3D'+model_id+'%26link%3D'+escape(link);
	flashvars.height = 140;
	flashvars.width = 140;
	flashvars.rotatetime = 1.5;
	flashvars.transition = 'flash';
	flashvars.shownavigation = false;
	flashvars.linkfromdisplay = true;
	flashvars.showicons = false;
	flashvars.repeat = true;
	var params = {};
	params.menu = "false";
	params.quality = "best";
	params.bgcolor = "#ffffff";
	params.allowfullscreen = "false";
	params.allowscriptaccess = "sameDomain";
	var attributes = {};
	attributes.id = 'rotator'+model_id;
	swfobject.embedSWF('/peep/imagerotator.swf', 'tmp_container'+model_id, '140', '140', "9.0.0", '', flashvars, params, attributes);
//	document.getElementById('rotator'+model_id).onmouseout = function(){ stop_show(model_id); };
//	document.getElementById('tmp_container'+model_id).onmouseout = function(){ stop_show(model_id); };
}
function stop_show(model_id){	var x;	for (x in thumb_w){		if (model_id != x){
			document.getElementById('snapshot'+x).innerHTML = thumb[x];
			document.getElementById('snapshot'+x).onmouseover = function(){				pre_start_show(this.id.substring(8,this.id.length),thumb_link[this.id.substring(8,this.id.length)]);
			}
		}
	}
}

function send_sms(obj,model_id){	if (document.getElementById('send_sms') != undefined) document.body.removeChild(document.getElementById('send_sms'));
	var div = document.createElement('div');
	var html = '<iframe src="/peep/user_sms.php?model='+model_id+'" scrolling="no"></iframe>';
	div.id = 'send_sms';
	div.style.top = (ajax_getTopPos(obj)+20)+'px';
	div.style.left = (ajax_getLeftPos(obj)+30)+'px';
	div.innerHTML = html;
	document.body.appendChild(div);
}