var gCookieName = 'ddc_impopup'; //??? ????
var gDivID      = 'ddc_impopup'; //?? ???? ? ???????
var gDelay      = 1; // ???????? ????? ???????
var gImgPath    = 'http://www.teensboss.com/IM/Suzanna.gif'; //??? ????????
var gLink       = 'http://free.youngasiangfs.com/track/MTM1MTo0OjEw/'; //??????
var gSpeed      = 10; //???????? ????? ????? ????????. ??? ?????? ?????, ??? ?????????.
var gStep       = 1; //??? ???????? ? ????????. ??? ????? ???, ??? ???????, ?? ? ????????? ?????.
var gImg=new Image();

var css       = 'position:fixed;';
var html_code = '';

if(document.all && window.XMLHttpRequest && !window.opera){
  
  if( ( window.document.childNodes[0].text == undefined ) || ( window.document.childNodes[0].text.search(/DOCTYPE\s+HTML\s+PUBLIC.+\.dtd/i) == -1) ){
    css = 'position:absolute; top:expression( eval( document.compatMode && document.compatMode == \'CSS1Compat\' ) ? documentElement.scrollTop + (documentElement.clientHeight-this.clientHeight) : document.body.scrollTop + ( document.body.clientHeight-this.clientHeight ) ); ';
  }
}
if(document.all && !window.XMLHttpRequest){
  css = 'position:absolute; top:expression( eval( document.compatMode && document.compatMode == \'CSS1Compat\' ) ? documentElement.scrollTop + (documentElement.clientHeight-this.clientHeight) : document.body.scrollTop + ( document.body.clientHeight-this.clientHeight ) ); ';
}

html_code += '<div id="ddc_impopup_container" style="' + css + ' display:none; z-index:99999; bottom:0px; right:0; overflow:hidden; background-color:transparent; border-width:0px;">';
html_code += '<div id="' + gDivID + '" style="position:relative;top:600px; z-index:99998; padding:0px; ">';
html_code+= '<a id="ddc_impopup_link" href="'+gLink+'" onclick="return(false);"><img src="'+gImgPath+'" style="border:none"></a>';
html_code += '</div>';
html_code += '</div>';

document.write(html_code);

gImg.onload=function(){phmg_delay(gDelay)}
gImg.src=gImgPath;

//--[Functions]-----------------------------------------------------------------//
var phmg_timer;
var phmg_btn_elm = document.getElementById('ddc_impopup_link');

phmg_btn_elm.onclick = function (){
  window.open(gLink, '_blank', '');
  phmg_move(gDivID,'down');
  return false;
}

function phmg_delay(sec){
    sec = sec || 0;
    phmg_timer = setTimeout('phmg_checkCookie()',1000 * sec);
}

function phmg_checkCookie(){
  var ck = phmg_getCookie(gCookieName);

  if(!ck){    
    phmg_move(gDivID);    
  }else{
    clearTimeout(phmg_timer);
  }
}

function phmg_move(elmID,direction){
  var supported = (document.getElementById);
  if (!supported){
    return;
  }
  var x;
  var divPath = document.getElementById(elmID);
  var currPos = parseInt(divPath.style.top);
  var holderDisplay = document.getElementById('ddc_impopup_container');
  holderDisplay.style.display = ''; 
  if(direction === 'down'){
    x = divPath.offsetHeight;
    if(currPos <= x){
      currPos += (currPos + gStep) > x? ( (x - currPos) +gStep ):gStep;
      divPath.style.top = currPos + 'px';
      phmg_timer = setTimeout("phmg_move('" + elmID + "','down')",gSpeed);
    }else{
      // Antimation completed clear timeout
      clearTimeout(phmg_timer);
      holderDisplay.style.display = 'none';       
    }
  }else{
    x = 0;
    if(currPos > x){
      currPos -= currPos < gStep? currPos:gStep;
      divPath.style.top = currPos + 'px';                                        
      phmg_timer = setTimeout("phmg_move('" + elmID + "','')",gSpeed);
    }else{
      // Antimation completed clear timeout
      clearTimeout(phmg_timer);
    }
  }
}

function phmg_setCookie(name,value,expires,path,domain,secure){
  var expStr = '';
  var type   = 'H';
  var ms     = {
     Y : 31557600000,
     W : 604800000,
     D : 86400000,
     H : 3600000,
     M : 60000,
     S : 1000
         };           
  if(expires){
    var expDte = new Date();
    var expMS  = expDte.valueOf() + (ms[type] * expires);
    expDte.setTime(expMS);
    expStr     = '; expires=' + expDte.toGMTString();
  }
  
  pathStr   = ( (path   === undefined ) ? '' : ('; path=' + path) );
  domainStr = ( (domain === undefined ) ? '' : ('; domain=' + domain) ); 
  secureStr = ( (secure === undefined ) ? '' : ('; secure') ); 

  document.cookie = name + '=' + escape(value) + expStr + pathStr + domainStr + secureStr;
}

function phmg_getCookie(name){
  var output   = null;
  var cks      = ' ' + document.cookie + ';';
  var matchCk  = ' ' + name + '=';
  var startPos = cks.indexOf(matchCk);  
  var endPos;
  if(startPos != -1){
    startPos += matchCk.length;
    endPos    = cks.indexOf(';', startPos);
    output    = unescape(cks.substring(startPos, endPos));
  }
  return output;
}
