function getClientWidth(){return document.documentElement.clientWidth}
function getClientHeight(){return document.documentElement.clientHeight}
function scrlTop(){if(document.documentElement.scrollTop)return document.documentElement.scrollTop; else return document.body.scrollTop;}
function by_id(name){if(document.getElementById)return document.getElementById(name);else if(document.all)return document.all[name];else if(document.layers)return document.layers[name];else return false}function _setStyle(o,st){for(var key in st)if(st.hasOwnProperty(key))o.style[key]=st[key]}function cumulativeOffset(element){var valueT=0,valueL=0;do{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;element=element.offsetParent}while(element);return{top:valueT,left:valueL}};

var wnd1,wnd1MainImg,wnd1load,wnd1preimg,wnd_prel,wnd1desc,onloadfl,wnd1to;

var wndOther_sections=by_id('other_sections');

function wnd_init(){
  wnd1=document.createElement('div');
  wndOther_sections.appendChild(wnd1);
  _setStyle(wnd1,{
    width:'458px',
    padding:'0 10px 10px 10px',
    position:'absolute',
    //overflow:'hidden',
    top:'0',
    left:'0',
    display:'none',
    background:'#8f7b60 url(images/samples_grad_bg.gif) bottom left repeat-x',
    fontSize:'1px',
    border:'2px solid #FFFFFF',
    zIndex:'1000'
  })
  
  wnd1.innerHTML='<div style="overflow:hidden"><div style="background:url(images/left_r.jpg) center left no-repeat;float:left;width:7px;height:22px"></div>'+
                '<div style="text-align:center; font:bold 13px/16px Verdana, Geneva, sans-serif;color:#F00;height:22px;background:#FFF;float:left;width:444px;margin:0 auto 10px auto;">This is just a low quality sample. To view HQ photo join now</div>'+
                '<div style="background:url(images/right_r.jpg) center right no-repeat;float:left;width:7px;height:22px;"></div></div>'+
                '<div style="text-align:center;width:400px;height:400px;margin:0 auto"><img id="wnd1MainImg" style="width:32px;height:32px" src="#" /></div>'+
                '<div id="wnd1desc" style="width:458px;text-align:center; font:bold 15px Verdana, Geneva, sans-serif;color: #fff"></div>'+
                '<img src="http://100cameltoe.com/images/wndloader.gif" id="wnd1load" style="width:128px;height:15px;position:absolute;top:222px;left:178px" />';
  
  setTimeout(function(){
    wnd1MainImg=by_id('wnd1MainImg');
    wnd1desc=by_id('wnd1desc');
    wnd1load=by_id('wnd1load');
  },100);
  
  wnd1preimg=document.createElement('img');
  wndOther_sections.appendChild(wnd1preimg);
  _setStyle(wnd1preimg,{position:'absolute',top:'-10000px'});
  wnd1preimg.onload=wndpreimgLoad;  
  return true;
}


function wndpreimgLoad(e){
  wndOther_sections.style.cursor='default';
  wnd1load.style.display='none';
  wnd1MainImg.src=this.src;
  wnd1MainImg.style.width=this.offsetWidth+'px';
  wnd1MainImg.style.height=this.offsetHeight+'px';
  wnd1MainImg.style.marginTop=Math.floor(200-this.offsetHeight/2.0)+'px';  
  //alert(wnd1img.src);
}

function showwnd(imobj){
  if(wnd1to){clearTimeout(wnd1to);}
  var ts1=imobj.src.replace(/\/th/,'');
  
  wnd1desc.innerHTML=imobj.alt;
  wndOther_sections.style.cursor='wait';
  var pos=cumulativeOffset(imobj);
  var bwidth=getClientWidth(),bheight=getClientHeight();
  if((pos.top+500)>(scrlTop()+bheight)){
    wnd1.style.top=scrlTop()+bheight-500+'px';
  }else{
    wnd1.style.top=pos.top+'px';
  }
  
  if(bwidth>(pos.left+558)){
    wnd1.style.left=(pos.left+100)+'px';
  }else{
    wnd1.style.left=pos.left-488+'px';
  } 
  wnd1.style.display='block';
  wnd1load.style.display='block';
  wnd1preimg.src=ts1;
}

function hidewnd(){
  wnd1to=setTimeout(function(){  
    wnd1.style.display='none';
    //wnd1MainImg.src='#';
    //wnd1img.height='0';

  },100);
  return true;
}
setTimeout(function(){wnd_init();},250);