function getClientWidth(){return document.documentElement.clientWidth}
function getClientHeight(){return document.documentElement.clientHeight}
function addLoadEvent (func) {
	 var oldonload = window.onload;
	 if (typeof window.onload != 'function') {window.onload = func;}
	else {window.onload = function() {if (oldonload) oldonload();func();}}}
function by_id (id) {
	var res = document.getElementById(id);
	return res;
}
function by_tag (tag,where) {
	var res=0;
	var where_=where ? where:document;
	var out_ = where_.getElementsByTagName(tag);
	if (out_.length == 1) {res=out_[0]} else {res=out_}
	return res;
}
function by_class(clname,obj,tag_name){
  var tn=tag_name ? tag_name:'*';
  var elmts=by_tag(tn,obj);
  var _out=new Array();
  var i=0, j=0;
  while(elmts[i]){
	if(elmts[i].className==clname){
	  _out[j]=elmts[i];
	  j++;
	}
	i++;
  }
  var res=0;
  if (_out.length == 1) {res=_out[0]} else {res=_out}
  return res;
}

function getStyle(e,s){
  var v=null;
  if(document.defaultView && document.defaultView.getComputedStyle){
    var cs=document.defaultView.getComputedStyle(e,null);
    if(cs && cs.getPropertyValue) v=cs.getPropertyValue(s);
  }
  if(!v && e.currentStyle) v=e.currentStyle[s];
  return v;
}

var tdesc=new Array(
  'Marianna is not a silly teen, I mean being in her twenties she has enough experience and craziness to be a perfect match in bed. But I didn’t let her try my cock at once! First I made that naughty cougar in leopard print stockings play with the toys she has around. My dick was like a treat after the ass balls and mighty dildo penetrations. It was wonderfully wet there!',
  'See this girl? She’s absolutely marvelous! Being only 19 y.o. Adeline (this is her name) has made masturbation sessions and other insane sex games the part of her bright high-energy life. I’ve seen her making pictures of herself while doing her pussy with a vibrator, a spoon and a brush (yes, I was there!). Do you want to know what else she does? <a href="/join.html">Get inside then</a>',
  'Meet Nadja – frisky coed I picked up in a campus bar. You may have noticed that beer is an important part of her life so to say. You love it – you get it baby! But it’s not that you can only drink it, you need to amuse me. She did manage in it stuffing the beer bottle into her burning pussyhole. It made me very horny and I fucked the brain out of her!',
  'This is Jessica – shop assistant in a store selling lingerie. I was planning to buy something naughty for my girlfriend (my ex-girlfriend?) but then there was Jessica… You can’t but agree that she looks fabulous in that red lingerie and fishnet stockings. Her tits, her big round ass drove me crazy. And she was perfect with her pink Barbie-style dildo.',
  'I’ll hardly forget that party we had – one of my friends’ b-day party actually. Girls got boozed and started the dirty dances with kissing and rubbing against each other. I liked Val most of all because she had an intelligent face and still a naughty look in her eyes. I was right about her – she did it all from dildo fucking to my dick sucking.',
  'Magda looked so conservative and that’s why I felt the challenge of seducing her into a crazy fuck session. You know what – she had a hairy pussy which has never seen a razor in its life probably, ha-ha. But still it was very tight and wet… She did everything to my cock, packed ass balls into her holes and even stuffed a rotten cucumber into her ass!',
  'Olga is a Russian cutie who came to America on some exchange program. Oh that mysterious Russian soul…  She was so naïve and at the same time yearned for fun. I nearly exploded when she wearing her school uniform started to play with the dildo I gave her. You’ll see her packing a huge pink thing into her silky pussy and teasing her clit – hot!'
);

function tabs(obj) {
	var tabs=by_id('tabs');
	var desc=by_id('tabsdesc');
	var imgs=by_id('tabsbox').getElementsByTagName('img');
	var lis = tabs.getElementsByTagName('li');
	for (i=0;i<lis.length;i++) {lis[i].className='li'+(i+1)}
	this.setTimeout(function(){for(var j=0;j<imgs.length;j++){imgs[j].src='#'}},10);
	this.setTimeout(function(){for(var j=0;j<imgs.length;j++) {imgs[j].src='images/block4-sets/li'+obj.className.substr(2,1)+'/0'+(j+1)+'.jpg'}},200);	
	obj.className+=' act';
	desc.innerHTML=tdesc[obj.className.substr(2,1)-1];
}

var tmp = 0;
var tr = 0;
function slider_(a,max_mar,big_step,cont,step) {
	var mar=0,cm=0;
	if (getStyle(cont,'margin-left')) {mar = 'margin-left'}
	else {mar = 'marginLeft'}
	var r_arrow = cont.id=='top_photos'?by_id('r_arrow'):by_id('rr_arrow');
	var l_arrow = cont.id=='top_photos'?by_id('l_arrow'):by_id('ll_arrow');
		switch (a) {
		case 1: {
			if(parseInt(getStyle(cont,mar))==max_mar) {r_arrow.className='rstop';r_arrow.style.cursor='default'}
			if (tmp<big_step&&(parseInt(getStyle(cont,mar))!=max_mar)) {
				r_arrow.className='';r_arrow.style.cursor='pointer';l_arrow.className='';l_arrow.style.cursor='pointer';
				cm-=step;tmp+=step;tr = parseInt(getStyle(cont,mar)) + cm;cont.style.marginLeft = tr + 'px';
				setTimeout(function(){slider_(a,max_mar,big_step,cont,step)},20);}
			else {tmp = 0;return true}
		}break;
		case 2: {
			if(parseInt(getStyle(cont,mar))==0) {l_arrow.className='lstop';l_arrow.style.cursor='default'}
			if (tmp<big_step&&(parseInt(getStyle(cont,mar))!=0)) {
				r_arrow.className='';r_arrow.style.cursor='pointer';l_arrow.className='';l_arrow.style.cursor='pointer';
				cm+=step;tmp+=step;tr = parseInt(getStyle(cont,mar)) + cm;cont.style.marginLeft = tr + 'px';
				setTimeout(function(){slider_(a,max_mar,big_step,cont,step)},20);}
			else {tmp = 0;return true}		
		}break;
		default: {alert('Error!')}break;}
	}

var flashvars = {file:"tr01.flv",screen:"/images/trailer/tr01.jpg"};
var chngmov=function(o) {
	var obj=by_id(o),desc=by_id('top_movie_desc');as=obj.getElementsByTagName('a'),i=0;
	for(i=0;i<as.length;i++) {
		as[i].lang=to_zero(i+1)
		as[i].onclick=function() {
			flashvars = {file:'tr'+this.lang+'.flv',vscreen:'images/trailer/tr'+this.lang+'.jpg',autoplay:'true'};
			swfobject.embedSWF("images/trailer/iplayer.swf", "trailer2", "384", "288", "9.1.0", "",    
        flashvars,//ФЛЭШВАРЫ (FLASHVARS)
        {bgcolor:'#000000',allowfullscreen:'true',allowscriptaccess:'always',wmode:'opaque',quality:'high'},//ПАРАМЕТРЫ (PARAMS)
        {id:'trailer2'}//АТРИБУТЫ (ATTRIBUTES)
      );
			desc.innerHTML=tmd[parseInt(this.lang-1,10)];
		}
	}
}
function to_zero(o){var res=0;obj=parseInt(o);if(obj<10){res='0'+obj}else{res=obj};return res}
	
function submit_h(num) {
	var sub = document.getElementById('submit_h');
	var cont = document.compatMode=='CSS1Compat'&&!window.opera?document.documentElement.clientHeight:document.body.clientHeight;
	//alert(cont);
	if (window.opera) {cont = document.documentElement.clientHeight}
	if (cont > 1000) {sub.style.height = cont - num +'px';}
}

/* Bookmark */
var urlAddress = document.location;
var pageName = document.title;

function bookmark_(){
 if (window.sidebar) // firefox
 window.sidebar.addPanel(pageName, urlAddress, "");
 else if(window.opera && window.print){ // opera
 var elem = document.createElement('a');
 elem.setAttribute('href',urlAddress);
 elem.setAttribute('title',pageName);
 elem.setAttribute('rel','sidebar');
 elem.click();
 } else if(document.all)// ie
 window.external.AddFavorite(urlAddress, pageName);
}
/* Bookmark */


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 tempimg;
var loader;
//

function createLoader(m,t,l){
  if(m=='create'){
    loader=document.createElement('img');
    document.body.insertBefore(loader,document.body.firstChild);
    loader.src='images/load.gif';
    loader.width='20'; loader.height='20';
    loader.style.position='absolute';
    loader.style.display='none';
    loader.style.top=t+'px';
    loader.style.left=l+'px';
    loader.style.display='block';
    loader.style.zIndex='1010';
  }else{
    if(!loader) return 0;
    document.body.removeChild(loader);
    delete loader;
    loader=null;
  }  
}

function _setStyle(o,st){
  for(var key in st) if(st.hasOwnProperty(key)){
    o.style[key]=st[key];
  }
}
function createCloseBtn(m,forwhat,callback,side){
  if(m=='create'){    
    var closeBtn=document.createElement('div');
    closeBtn.id='closeBtn0';    
    closeBtn.innerHTML='<strong>CLOSE</strong>';
    _setStyle(closeBtn,{
      position:'absolute',
      zIndex:'1010',
      border:'2px outset #B00',
      backgroundColor:'#B00',
      fontFamily:'Arial',
      fontSize:'12px',
      fontWeight:'normal',
      padding:'0 3px',
      color:'#FFF',
      cursor:'pointer'
    });
    closeBtn.onmouseover=function(ev){
      _setStyle(this,{backgroundColor:'#F00',borderColor:'#F00'});
    }
    closeBtn.onmouseout=function(ev){
      _setStyle(this,{backgroundColor:'#B00',borderColor:'#B00'});
    }
    closeBtn.onmousedown=function(ev){
      _setStyle(this,{border:'2px inset #F00'});
    }
    closeBtn.onclick=function(ev){      
      callback(ev);      
    }
    document.body.insertBefore(closeBtn,document.body.firstChild);
    var forwhatOffs=cumulativeOffset(forwhat);
    var t=0,l=0;
    t=forwhatOffs.top+6;
    switch(side){
      case 'left':{
        l=forwhatOffs.left+5;
      }break;
      case 'right':{
        l=forwhatOffs.left+forwhat.offsetWidth-closeBtn.offsetWidth-5;
      }break;
    }    
    _setStyle(closeBtn,{top:t+'px',left:l+'px'});
  }else{
    var closeBtn=by_id('closeBtn0');
    if(closeBtn){
      document.body.removeChild(closeBtn);
      delete closeBtn;
      closeBtn=null;
    }    
  }
  
}

function showPhoto(lobj,purl){
  var deleteImg=function(iobj){
    iobj.onload=null;
    iobj.onclick=null;  
    document.body.removeChild(iobj);
    createLoader(0);
    delete iobj;
  }  
  var imgborderw=1;
  var cw=getClientWidth()-imgborderw; var ch=getClientHeight()-imgborderw;
  
  tempimg=by_id('tempimg');  
  if(tempimg){deleteImg(tempimg);} 
  var timg=by_tag('img',lobj);
  var timgOffs=cumulativeOffset(timg);  
  createLoader('create',timgOffs.top+Math.round((timg.offsetHeight-31)/2)+3,timgOffs.left+Math.round((timg.offsetWidth-31)/2)+3);  
  
  
  
  tempimg=document.createElement('img');
  document.body.insertBefore(tempimg,document.body.firstChild);
  tempimg.id='tempimg';  
  tempimg.style.position='absolute';
  tempimg.style.zIndex='1000';  
  
  tempimg.style.visibility='hidden';
  setTimeout('tempimg.src=\''+purl+'\'',20);
  
  
  
  tempimg.onclick=function(ev){
    createCloseBtn(0);
    document.body.removeChild(tempimg);
    createLoader(0,0,0);
    createFade(0);
  }
  
  tempimg.onload=function(ev){
    //alert('aaa');   return false;    
    createLoader(0,0,0);
    createFade('create');
    
    var ih=tempimg.offsetHeight; var iw=tempimg.offsetWidth;
    var cih=ih; var ciw=iw;
    var iar=iw/ih;
    if(cih>ch){tempimg.height=ch;cih=ch;ciw=Math.round(cih*iar);tempimg.width=ciw;}
    if(ciw>cw){tempimg.width=cw;ciw=cw;cih=Math.round(ciw/iar);tempimg.height=cih;}
    var itop=(document.documentElement.scrollTop+Math.round((ch-cih)/2));
    var ileft=Math.round((cw-ciw)/2);
    tempimg.style.visibility='visible';
    tempimg.style.top=itop+'px';
    tempimg.style.left=ileft+'px';    
    tempimg.style.border=imgborderw+'px solid #FFFFFF';    
    createCloseBtn('create',tempimg,tempimg.onclick,'right');
    //alert(fade.style.filter);
  }   
}


var fade;
function createFade(m){
  if(m!='create'){
    if(fade){
      document.body.removeChild(fade);
      delete fade;fade=null;
    }
    return true;
  }
  if(fade){
    delete fade; fade=null;
  }
  var cw=getClientWidth(); var ch=getClientHeight();
  fade=document.createElement('div');
  var st=fade.style;
  st.position='absolute';
  st.zIndex='900';
  st.width='100%'; st.height=document.body.offsetHeight+'px';
  st.opacity='0.8'; st.filter='alpha(opacity=80)';
  st.background='#000';
  document.body.insertBefore(fade,document.body.firstChild);
  /*
  fadeFadein=function(o){
    if(o>=80){      
      return true;
    }
    o+=5;
    st.opacity=(o/100);
    st.filter='alpha(opacity='+o+')';
    this.setTimeout('fadeFadein('+o+')',20);
  }
  this.setTimeout('fadeFadein(0)',300);
  */
  
}

var plctnr,closelink;

function watchMovie(vurl,vscr){  
  if(plctnr){
    createFade(0);
    plctnr.removeChild(closelink);
    document.body.removeChild(plctnr);
    delete closelink; delete plctnr;
    closelink=null; plctnr=null;
  }
  var cw=getClientWidth()-0; var ch=getClientHeight()-0;
  //var vscr=scrobj.src;
  plctnr=document.createElement('div');
  plctnr.style.position='absolute';
  plctnr.style.zIndex='1000'; 
  plctnr.style.width='512px';
  plctnr.style.height='404px';
  plctnr.style.paddingTop='30px';
  
  var plhtml='<div style="border:0px solid #1362A0; line-height:0"><span id="flplayer"><img src="" width="512" height="384" alt="video" /></span></div>';
  //var plhtml='<div style=" border:0px solid #1362A0; line-height:0;"><embed src="player.swf" width="512" height="404" bgcolor="#000" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowfullscreen="true" allowscriptaccess="always" flashvars="vfile='+vurl+'&vscreen='+vscr+'" /></div>';
  plctnr.innerHTML=plhtml;
  document.body.insertBefore(plctnr,document.body.firstChild);  
  plctnr.style.top=(Math.round((ch-plctnr.offsetHeight)/2)+document.documentElement.scrollTop)+'px';
  plctnr.style.left=Math.round((cw-plctnr.offsetWidth)/2)+'px';
  
  createCloseBtn('create',plctnr,function(){
    createFade(0);
    createCloseBtn(0);    
    document.body.removeChild(plctnr);
    delete closelink; delete plctnr;
    closelink=null; plctnr=null;
  },'right');
  createFade('create');
  //<embed src="player.swf" width="512" height="404" bgcolor="#000" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowfullscreen="true" allowscriptaccess="always" flashvars="vfile='+vurl+'&vscreen='+vscr+'" />
  swfobject.embedSWF("player.swf", "flplayer", "512", "404", "9.1.0", "",    
    {vfile:vurl,vscreen:vscr},//ФЛЭШВАРЫ (FLASHVARS)
    {bgcolor:'#000000',allowfullscreen:'true',allowscriptaccess:'always',wmode:'opaque',quality:'high'},//ПАРАМЕТРЫ (PARAMS)
    {id:'main_player'}//АТРИБУТЫ (ATTRIBUTES)
  );
}
