﻿
//get the browser kind 
if(navigator.appName == "Microsoft Internet Explorer")
{
    browserKind = "IE";
}
else if(navigator.appName == "Netscape")
{
    browserKind = "NT";
}

// global vars
var docTotalHeight, docScrollHeight, middleX, middleY, picOrignWidth, picOrignHeight;
var globTarget = "_self";

function showHide(theID)
{
    document.getElementById(theID).style.display = document.getElementById(theID).style.display == "none" ? "block" : "none";
}

//get mouse X Y position
var mouseX, mouseY;
function getMousePos(e)
{
    if (!e){e = window.event || window.Event;}

    if('undefined' != typeof e.pageX)
    {
        mouseX = e.pageX;
        mouseY = e.pageY;
    }
    else
    {
        mouseX = e.clientX + getScrollXY()[0];
        mouseY = e.clientY + getScrollXY()[1]; 
    }  
}

//Get document height
function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

//get scrolling info
function getScrollXY()
{
   var scrOfX = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft;        
   scrOfX = scrOfX ? scrOfX : 0;
   var scrOfY = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
   scrOfY = scrOfY ? scrOfY : 0;
   return [ scrOfX, scrOfY ];
} 

//get browser with height
function getSizeWH()
{
   var scrOfW = window.innerWidth || document.body.clientWidth || document.documentElement.clientWidth;
   scrOfW = scrOfW ? scrOfW : 0;
   var scrOfH = window.innerHeight || document.body.clientHeight || document.documentElement.clientHeight;
   scrOfH = scrOfH ? scrOfH : 0;
   return [ scrOfW, scrOfH ];
} 

//returen object top and left positions
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function flashRekaVars(tdid, width, height, theSWF, theVars)
{
    if(theVars == "0")
    {
        document.getElementById(tdid).innerHTML = "";
    }
    else
    {
        document.getElementById(tdid).innerHTML = giveFlashStr(width, height, theSWF, theVars);
    }
}

function flashRekaParent(tdid, width, height, theSWF, theVars)
{
    tdid.parentNode.innerHTML = giveFlashStr(width, height, theSWF, theVars);
}
function flashRekaParentSimple(tdid, width, height, theSWF)
{
    tdid.parentNode.innerHTML = giveFlashStrSimple(width, height, theSWF);
}
function doFlash(tdid, width, height, theSWF)
{
    document.getElementById(tdid).innerHTML = giveFlashStrSimple(width, height, theSWF);
}
function flashRekaPic1(tdid, objReka)
{
    document.getElementById(tdid).innerHTML = giveFlashStr('186', '163', 'flash/roundBG.swf', objReka);
}

// insert meny same swf once 
function flashRekaVarsArray(width, height, theSWF, theVars, idsArray)
{
    var strHTML = giveFlashStr(width, height, theSWF, theVars);   
    for(i=0; i<idsArray.length; i++)
    {
        document.getElementById(idsArray[i]).innerHTML = strHTML;
    }
}

function flashReka(tdid, width, height, theSWF)
{
    if(browserKind == "IE")
    {
      document.getElementById(tdid).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width=" + width + " height=" + height + ">"+
      "<param name=movie value='" + theSWF + "' />"+
      "<param name='scale' value='noscale' />"+
      "<param name='salign' value='lt' />"+
      "<param name=wmode value=transparent />"+
      "</object>";
    }
    else
    {
        document.getElementById(tdid).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width=" + width + " height=" + height + ">"+
        "<embed src='" + theSWF + "' scale='noscale' wmode='transparent' salign='lt' width=" + width + " height=" + height + " type='application/x-shockwave-flash' /></object>";
    }
}

function doFlashID(tdid, width, height, theSWF, theVars, SWFid)
{
    if(browserKind == "IE")
    {
      document.getElementById(tdid).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' id=" + SWFid + " width=" + width + " height=" + height + ">"+
      "<param name=movie value='" + theSWF + "' />"+
      "<param name=FlashVars value='theW=" + width + "&theH=" + height + "&" + theVars + "' />"+
      "<param name='scale' value='noscale' />"+
      "<param name='salign' value='lt' />"+
      "<param name=wmode value=transparent />"+
      "</object>";
    }
    else
    {
        document.getElementById(tdid).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' id=" + SWFid + " width=" + width + " height=" + height + ">"+
        "<embed id=" + SWFid + "embed src='" + theSWF + "' FlashVars='theW=" + width + "&theH=" + height + "&" + theVars + "' scale='noscale' wmode='transparent' salign='lt' width=" + width + " height=" + height + " type='application/x-shockwave-flash' /></object>";
    }
}

function doFlashVarsFscreen(tdid, width, height, theSWF, theVars)
{
    if(browserKind == "IE")
    {
      document.getElementById(tdid).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='" + width + "' height='" + height + "'>"+
      "<param name='allowFullScreen' value='true' />"+
      "<param name=movie value='" + theSWF + "' />"+
      "<param name=FlashVars value='" + theVars + "' />"+
      "<param name=wmode value='transparent' />"+
      "</object>";
    }
    else
    {
        document.getElementById(tdid).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='" + width + "' height='" + height + "'>"+
        "<embed src='" + theSWF + "' allowFullScreen='true' FlashVars='" + theVars + "' wmode='transparent' width='" + width + "' height='" + height + "' type='application/x-shockwave-flash' /></object>";
    }
}

function doFlashVars(tdid, width, height, theSWF, theVars)
{
    if(browserKind == "IE")
    {
      document.getElementById(tdid).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='" + width + "' height='" + height + "'>"+
      "<param name=movie value='" + theSWF + "' />"+
      "<param name=FlashVars value='" + theVars + "' />"+
      "<param name=wmode value='transparent' />"+
      "</object>";
    }
    else
    {
        document.getElementById(tdid).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='" + width + "' height='" + height + "'>"+
        "<embed src='" + theSWF + "' FlashVars='" + theVars + "' wmode='transparent' width='" + width + "' height='" + height + "' type='application/x-shockwave-flash' /></object>";
    }
}

function giveFlashStr(width, height, theSWF, theVars)
{
    var strHTML;
    if(browserKind == "IE")
    {
      strHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='" + width + "' height='" + height + "'>"+
      "<param name='movie' value='" + theSWF + "' />"+
      "<param name='flashvars' value='theW=" + width + "&theH=" + height + "&" + theVars + "' />"+
      "<param name='scale' value='noscale' />"+
      "<param name='salign' value='lt' />"+
      "<param name='wmode' value='transparent' />"+
      "</object>";
    }
    else
    {
        strHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='" + width + "' height='" + height + "'>"+
        "<embed src='" + theSWF + "' flashvars='theW=" + width + "&theH=" + height + "&" + theVars + "' scale='noscale' wmode='transparent' salign='lt' width='" + width + "' height='" + height + "' type='application/x-shockwave-flash' /></object>";
    }
    return strHTML;
}

function giveFlashStrSimple(width, height, theSWF)
{
    var strHTML;
    if(browserKind == "IE")
    {
      strHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='" + width + "' height='" + height + "'>"+
      "<param name='movie' value='" + theSWF + "' />"+
      "<param name='wmode' value='transparent' />"+
      "</object>";
    }
    else
    {
        strHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='" + width + "' height='" + height + "'>"+
        "<embed src='" + theSWF + "' wmode='transparent' width='" + width + "' height='" + height + "' type='application/x-shockwave-flash' /></object>";
    }
    return strHTML;
}

function doFlashSMvars(tdid, width, height, theSWF, theVars)
{
    var xPose1,xPose2;
    xPose1 = Math.max(objSideMenu.paddingA2, objSideMenu.paddingB2);
    xPose2 = Math.max(objSideMenu.paddingA4, objSideMenu.paddingB4);
      
    if(browserKind == "IE")
    {
        document.getElementById(tdid).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' id='SWF" + tdid + "' width=" + width + " height=" + height + ">"+
        "<param name=movie value='" + theSWF + "' />"+
        "<param name=FlashVars value='xPose1=" + xPose1 + "&xPose2=" + xPose2 + "&" + theVars + "' />"+
        "<param name=wmode value=transparent />"+
        "</object>";
    }
    else
    {
        document.getElementById(tdid).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width=" + width + " height=" + height + ">"+
        "<embed id='SWF" + tdid + "' src='" + theSWF + "' FlashVars='xPose1=" + xPose1 + "&xPose2=" + xPose2 + "&" + theVars + "' wmode='transparent' width=" + width + " height=" + height + " type='application/x-shockwave-flash' /></object>";
    }
}

function doFlashSideMenu(obj, tdid, width, height, theSWF, theIcon)
{
    var xPose1,xPose2;
    xPose1 = Math.max(objSideMenu.paddingA2, objSideMenu.paddingB2);
    xPose2 = Math.max(objSideMenu.paddingA4, objSideMenu.paddingB4);
      
    if(browserKind == "IE")
    {
        document.getElementById(tdid).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' id='SWF" + tdid + "' width=" + width + " height=" + height + ">"+
        "<param name=movie value='" + theSWF + "' />"+
        "<param name=FlashVars value='xPose1=" + xPose1 + "&xPose2=" + xPose2 + "&bodyDir=" + bodyDir + "&theIcon=" + theIcon + "&" + obj.icon2 + "' />"+
        "<param name=wmode value=transparent />"+
        "</object>";
    }
    else
    {
        document.getElementById(tdid).innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width=" + width + " height=" + height + ">"+
        "<embed id='SWF" + tdid + "' src='" + theSWF + "' FlashVars='xPose1=" + xPose1 + "&xPose2=" + xPose2 + "&bodyDir=" + bodyDir + "&theIcon=" + theIcon + "&" + obj.icon2 + "' wmode='transparent' width=" + width + " height=" + height + " type='application/x-shockwave-flash' /></object>";
    }
}

function rekaPaddingOnly(obj, TD, TDcode, isHeight)
{
    document.getElementById(TDcode).style.paddingTop = obj.padTop + "px";
    document.getElementById(TDcode).style.paddingBottom = obj.padBot + "px";
    if(isHeight == 0){ document.getElementById(TD).style.height = document.getElementById(TDcode).offsetHeight + "px"; }
}

function do2flashReka(obj, theWidth, TD, TDcode, TDreka1, TDreka2, isHeight, objRekaA, objRekaB)
{
    //padding of the html text
    var padTopBot = 0;
    if(webKind == 'adver')
    {
        document.getElementById(TDcode).style.paddingTop = obj.padTop + "px";
        document.getElementById(TDcode).style.paddingBottom = obj.padBot + "px";
        padTopBot += (parseInt(obj.padTop) + parseInt(obj.padBot));
    }
    //document.getElementById(TDcode).style.padding = "" + obj.padTop + "px 6px " + obj.padBot + "px 6px";
    
    var padA1,padA2,padA3,padA4,padB1,padB2,padB3,padB4 
    var theHeight = isHeight != 0 ? parseInt(isHeight) + parseInt(padTopBot) : document.getElementById(TDcode).offsetHeight;

    if(isHeight == 0){ document.getElementById(TD).style.height = document.getElementById(TDcode).offsetHeight + "px"; }

    padA1 = obj.paddingA1
    padA3 = obj.paddingA3
    padB1 = obj.paddingB1
    padB3 = obj.paddingB3
    
    if(bodyDir == "rtl")
    {
        padA2 = obj.paddingA2
        padA4 = obj.paddingA4
        padB2 = obj.paddingB2
        padB4 = obj.paddingB4
    }
    else
    {
        padA2 = obj.paddingA4
        padA4 = obj.paddingA2
        padB2 = obj.paddingB4
        padB4 = obj.paddingB2
    }
    
    if(TDreka1 != 'no'){ document.getElementById(TDreka1).style.padding = "" + padA1 + "px " + padA2 + "px " + padA3 + "px " + padA4 + "px"; }
    if(TDreka2 != 'no'){ document.getElementById(TDreka2).style.padding = "" + padB1 + "px " + padB2 + "px " + padB3 + "px " + padB4 + "px"; }
    
    //if height is more then flash limit   
    if(theHeight > 4000)
    {
        var rekaNums = Math.ceil(theHeight/4000);
        
        var theHeight1 = 4000;
        var theHeight2 = (theHeight+parseInt(obj.padBot))-((rekaNums-1)*4000);
        var htmlInner = "";
         
        if(TDreka1 != 'no')
        {
            htmlInner = "<table><tr><td>" + giveFlashStr('' + (theWidth-padA2-padA4) + '', '' + (theHeight1-padA1-padA3) + '', 'flash/roundBGrekaTop.swf', 'bodyDir=' + bodyDir + '&rekaPic=' + obj.rekaPic1 + '&repeatPic=' + obj.repeatPic1 + '&' + objRekaA + '') + "</td></tr>";
            if(rekaNums > 2)
            {
                for(i = 1; i <= (rekaNums-2); i++)
                {
                    htmlInner += "<tr><td>" + giveFlashStr('' + (theWidth-padA2-padA4) + '', '' + (theHeight1-padA1-padA3) + '', 'flash/BGmiddle.swf', 'bodyDir=' + bodyDir + '&rekaPic=' + obj.rekaPic1 + '&repeatPic=' + obj.repeatPic1 + '&' + objRekaA + '') + "</td></tr>";
                }
            }
            htmlInner += "<tr><td>" + giveFlashStr('' + (theWidth-padA2-padA4) + '', '' + (theHeight2-padA1-padA3) + '', 'flash/roundBGrekaBottom.swf', 'bodyDir=' + bodyDir + '&rekaPic=' + obj.rekaPic1 + '&repeatPic=' + obj.repeatPic1 + '&' + objRekaA + '') + "</td></tr></table>"; 
            document.getElementById(TDreka1).innerHTML = htmlInner;
        }
        
        if(TDreka2 != 'no')
        {
            htmlInner = "<table><tr><td>" + giveFlashStr('' + (theWidth-padB2-padB4) + '', '' + (theHeight1-padB1-padB3) + '', 'flash/roundBGrekaTop.swf', 'bodyDir=' + bodyDir + '&rekaPic=' + obj.rekaPic2 + '&repeatPic=' + obj.repeatPic2 + '&' + objRekaB + '') + "</td></tr>";
            if(rekaNums > 2)
            {
                for(i = 1; i <= (rekaNums-2); i++)
                {
                    htmlInner += "<tr><td>" + giveFlashStr('' + (theWidth-padB2-padB4) + '', '' + (theHeight1-padB1-padB3) + '', 'flash/BGmiddle.swf', 'bodyDir=' + bodyDir + '&rekaPic=' + obj.rekaPic2 + '&repeatPic=' + obj.repeatPic2 + '&' + objRekaB + '') + "</td></tr>";
                }
            }
            htmlInner += "<tr><td>" + giveFlashStr('' + (theWidth-padB2-padB4) + '', '' + (theHeight2-padB1-padB3) + '', 'flash/roundBGrekaBottom.swf', 'bodyDir=' + bodyDir + '&rekaPic=' + obj.rekaPic2 + '&repeatPic=' + obj.repeatPic2 + '&' + objRekaB + '') + "</td></tr></table>"; 
            document.getElementById(TDreka2).innerHTML = htmlInner;
        }
    }
    else
    {
        if(TDreka1 != 'no')
        {
            flashRekaVars(TDreka1, '' + (theWidth-padA2-padA4) + '', '' + (theHeight-padA1-padA3) + '', 'flash/roundBG.swf', 'bodyDir=' + bodyDir + '&rekaPic=' + obj.rekaPic1 + '&repeatPic=' + obj.repeatPic1 + '&' + objRekaA + '')
        }
        if(TDreka2 != 'no')
        {
            flashRekaVars(TDreka2, '' + (theWidth-padB2-padB4) + '', '' + (theHeight-padB1-padB3) + '', 'flash/roundBG.swf', 'bodyDir=' + bodyDir + '&rekaPic=' + obj.rekaPic2 + '&repeatPic=' + obj.repeatPic2 + '&' + objRekaB + '')
        }
    } 
}

function doAMover(swfID)
{ 
    swfID = browserKind != "IE" ? swfID + "embed" : swfID;
    document.getElementById(swfID).TSetProperty('/reka', 7, 0);
    document.getElementById(swfID).TSetProperty('/rekaOver', 7, 1);  
}
function doAMout(swfID)
{
    swfID = browserKind != "IE" ? swfID + "embed" : swfID;
    document.getElementById(swfID).TSetProperty('/reka', 7, 1);
    document.getElementById(swfID).TSetProperty('/rekaOver', 7, 0); 
}

function dateRandPics(theID, theArray, picAmount, picsPath, picsClass, vertOtHer, picsPad, isParent)
 {
    var strHtml = "<table>";
    
    var randNum = Math.floor(Math.random()*(theArray.length-(picAmount+1)));
    if(vertOtHer == "h")
    {
        strHtml += "<tr>";
        for(i = randNum; i < randNum + picAmount; i++)
        {
            strHtml += "<td><img src='"+ picsPath + theArray[i] + "' alt='' class='" + picsClass + "' /></td><td style='width:" + picsPad + "px;'></td>";
        }
        strHtml += "</tr>"; 
    }
    else
    {
        for(i = randNum; i < randNum + picAmount; i++)
        {
            strHtml += "<tr><td style='text-align:center;'><img src='"+ picsPath + theArray[i] + "' alt='' class='" + picsClass + "' /></td></tr>";
            strHtml += "<tr><td style='height:" + picsPad + "px;'></td></tr>";
        }
    }
    
    strHtml += "</table>";
    
    if(isParent == "1")
    {
        theID.parentNode.innerHTML = strHtml; 
    }
    else
    {
        document.getElementById(theID).innerHTML = strHtml;
    } 
 }
 
function doMobile(wapID, type)
{
    switch (type) 
    {
        case "1":
            doLw('http://2sex.wap.co.il/c/index?page=download&sub=pics&cat=wap3&cid=' + wapID + '', '_blank')
            break;
        case "2":
            doLw('http://2sex.wap.co.il/c/index?page=download&sub=animations&cat=wap3&cid=' + wapID + '', '_blank')
            break;
    }  
}

function doL(linkID)
{
    getL(linkID, globTarget);
}

var xmlHttp;
var target;

function getL(linkID, tar) 
{
    target = tar;
    getLresponse("urlGet.aspx?linkID=" + linkID); 
}

function getIndL(linkID) 
{
    target = "_blank";
    getLresponse("urlGetInd.aspx?linkID=" + linkID); 
}

function getLresponse(page) 
{
    if (window.XMLHttpRequest) 
    {
        xmlHttp = new XMLHttpRequest();
        xmlHttp.onreadystatechange = processReqChange;
        xmlHttp.open("GET", page, true);
        xmlHttp.send(null);
    } 
    else if (window.ActiveXObject) 
    {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        if (xmlHttp) 
        {
            xmlHttp.onreadystatechange = processReqChange;
            xmlHttp.open("GET", page, true);
            xmlHttp.send();
        }
    }
}

function processReqChange()
{
    if (xmlHttp.readyState==4)
    {
        if (xmlHttp.status==200 && xmlHttp.responseText != "no")
        {
            doLw(xmlHttp.responseText, target)
        } 
    }
}

function doLw(WU,theTarget)
{
    if(browserKind == "IE")
    {
        linkUwL.href = WU;
	    linkUwL.target=theTarget;
	    linkUwL.click();
    }
    else
    {
        var newWin = window.open(WU,'','scrollbars=yes,menubar=yes,height=750,width=1000,resizable=yes,toolbar=yes,location=yes,status=yes');  
    }
}

function doClick(linkID)
{
    if(browserKind == "IE")
    {
	    document.getElementById(linkID).click();
    }
    else
    {
        if(document.getElementById(linkID).target == "_blank")
        {
            var newWin = window.open(document.getElementById(linkID).href,'','scrollbars=yes,menubar=yes,height=750,width=1000,resizable=yes,toolbar=yes,location=yes,status=yes'); 
        }
        else
        {
            //document.getElementById("linkUwL").setAttribute("href", WU.href);
	        //document.getElementById("linkUwL").setAttribute("target", theTarget);
            location.replace(document.getElementById(linkID).href);
        }  
    }
}

function doSwfOver(swfID, movie, frame)
{
    document.getElementById(swfID).TGotoFrame(movie, frame); 
}

function doInnerHTML(id, theHtml)
{
    document.getElementById(id).innerHTML = theHtml;
}

// for all brosers innerText or textContent --------
function getInnerText(elementId)
{
    var hasInnerText = (document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
    return !hasInnerText ? elementId.textContent : elementId.innerText;
}

function changeTextById(elementId,changeVal)
{
    elementId.textContent = changeVal;
    elementId.innerText = changeVal; 
}
//---------------------------------------------

function fullScreenDiv(theHtml, color, theClass)
{
    if(theHtml != '')
    {
        var divHtml = "<div id='divFscreen1' class='fullscreen1' style='background-color:" + color + ";'></div>";
        divHtml += "<div id='divFscreen2' class='" + theClass + "' style='z-index:400;'>" + theHtml + "</div>";
        document.getElementById("DIVfullScreen").innerHTML = divHtml;
    }
    else
    {
        document.getElementById("DIVfullScreen").innerHTML = '';
    }
}

function checkPlugIns(plugInName)
{
    isPlugIn = false;
    if (navigator.plugins && navigator.plugins.length) 
    {
        for (x = 0; x <navigator.plugins.length; x++) 
        {
            if (navigator.plugins[x].name.indexOf(plugInName) != -1) 
            {
                isPlugIn = true;
            } 
        }
    }
    return isPlugIn;
}

//---- fade opacity  ------------------------ 
var TimeToFade = 1000.0;
function fade(eid)
{
  var element = document.getElementById(eid);
  if(element == null){ return; }
  
  element.style.display = 'block';
   
  if(element.FadeState == null)
  {
    if(element.style.opacity == null || element.style.opacity == '' || element.style.opacity == '1')
    {
      element.FadeState = 2;
    }
    else
    {
      element.FadeState = -2;
    }
  }
   
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
  } 
}

function animateFade(lastTick, eid)
{ 
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
 
  var element = document.getElementById(eid);
 
  if(element.FadeTimeLeft <= elapsedTicks)
  {
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'alpha(opacity = ' + (element.FadeState == 1 ? '100' : '0') + ')';
    element.style.display = element.FadeState == 1 ? 'block' : 'none';
    element.FadeState = element.FadeState == 1 ? 2 : -2;
    return;
  }
 
  element.FadeTimeLeft -= elapsedTicks;
  var newOpVal = element.FadeTimeLeft/TimeToFade;
  if(element.FadeState == 1){ newOpVal = 1 - newOpVal; }

  element.style.opacity = newOpVal;
  element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
 
  setTimeout("animateFade(" + curTick  + ",'" + eid + "')", 33);
}

//---- cookies  ------------------------
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 setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}

//scroll obj up and down
var tSm,objT,pHeight;
function smoothMove(theID, finalP, minWidth)
{
    objT = document.getElementById(theID);
    objT.style.display = minWidth < getSizeWH()[0] ? "block" : "none";
    pHeight = getScrollXY()[1];
    if(parseInt(objT.style.top) > 0){ objT.style.top = (parseInt(objT.style.top) + Math.floor((pHeight+finalP-parseInt(objT.style.top))*.04)) + 'px'; }
    else{ objT.style.top = Math.floor((pHeight+finalP)*.07) + 'px'; }
    tSm=setTimeout("smoothMove('"+theID+"', "+finalP+", "+minWidth+")",10);
}

//----  movie players embed  --------------------------------------
function getMHtmlParent(tdID, theID, movieSrc, theWidth, theHeight, autoStart, loopNumber)
{
    tdID.parentNode.innerHTML = givMovieHtml(theID, movieSrc, theWidth, theHeight, autoStart, loopNumber);
}

function getMovieHtml(tdID, theID, movieSrc, theWidth, theHeight, autoStart, loopNumber)
{
    document.getElementById(tdID).innerHTML = givMovieHtml(theID, movieSrc, theWidth, theHeight, autoStart, loopNumber);
}

function getMovHtmlImg(tdID, theID, movieSrc, theWidth, theHeight, autoStart, loopNumber, theImage)
{
    document.getElementById(tdID).innerHTML = givMovieHtml(theID, movieSrc, theWidth, theHeight, autoStart, loopNumber, theImage);
}

movPlayKind = "";
function givMovieHtml(theID, movieSrc, theWidth, theHeight, autoStart, loopNumber, theImage)
{
    var htmlMPlayer = "";
    var movieExt3 = movieSrc.slice(movieSrc.length-3, movieSrc.length);
    var movieExt4 = movieSrc.slice(movieSrc.length-4, movieSrc.length);
    
    if(movieExt4 == "mpeg" || movieExt3 == "mpg" || movieExt4 == "MPEG" || movieExt3 == "MPG")
    {
        movPlayKind = "realPlayer";
    
        htmlMPlayer += "<object id='" + theID + "' classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' width='" + theWidth + "' height='" + (theHeight-33) + "'>";
        htmlMPlayer += "<param name='src' value='" + movieSrc + "?embed'>";
        htmlMPlayer += "<param name='controls' value='imagewindow'>";
        htmlMPlayer += "<param name='console' value='clip" + theID + "'>";
        htmlMPlayer += "<param name='autostart' value='" + autoStart + "'>"; 
        htmlMPlayer += "<param name='numloop' value='" + loopNumber + "'>"; 
        htmlMPlayer += "<param name='maintainaspect' value='true'>"; 
        
        htmlMPlayer += "<embed name='Player' src='" + movieSrc + "?embed' type='audio/x-pn-realaudio-plugin' height='" + (theHeight-33) + "' width='" + theWidth + "' controls='imagewindow' console='clip" + theID + "' autostart='true' numloop='" + loopNumber + "' pluginspage='http://www.real.com/'></embed>"; 
        htmlMPlayer += "</object>"; 
  
        htmlMPlayer += "<object id='video" + theID + "' classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' height='33' width='" + theWidth + "'>";
        htmlMPlayer += "<param name='controls' value='ControlPanel'>";
        htmlMPlayer += "<param name='console' value='clip" + theID + "'>";
        htmlMPlayer += "<embed type='audio/x-pn-realaudio-plugin' console='clip" + theID + "' controls='ControlPanel' height='33' width='" + theWidth + "'></embed>";
        htmlMPlayer += "</object>";
    }
    else if(movieExt3 == "mov" || movieExt3 == "MOV")
    {
        movPlayKind = "quickTime";
        
        if(browserKind == "IE")
        { 
            htmlMPlayer += "<object id='" + theID + "' height='" + theHeight + "' width='" + theWidth + "' classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'";
            htmlMPlayer += "codebase='http://www.apple.com/qtactivex/qtplugin.cab'>";
            htmlMPlayer += "<param name='src' value='" + movieSrc + "' />";
            htmlMPlayer += "<param name='autoplay' value='" + autoStart + "' />";
            htmlMPlayer += "<param name='controller' value='true'>";
            htmlMPlayer += "<param name='loop' value='true'>";
            htmlMPlayer += "<param name='bgcolor' value='black'>"; 
            htmlMPlayer += "</object>";
        }
        else
        {
            htmlMPlayer += "<object id='" + theID + "' height='" + theHeight + "' width='" + theWidth + "' classid='clsid:CB927D12-4FF7-4a9e-A169-56E4B8A75598'";
            htmlMPlayer += "codebase='http://www.apple.com/qtactivex/qtplugin.cab'>";
            htmlMPlayer += "<embed src='" + movieSrc + "' autoplay='true' height='" + theHeight + "' width='" + theWidth + "'";
            htmlMPlayer += "bgcolor='black' pluginspage='http://www.apple.com/quicktime/download/'></embed>";
            htmlMPlayer += "</object>";
        }
    }
    else if(movieExt3 == "swf" || movieExt3 == "SWF" || movieExt3 == "flv" || movieExt3 == "FLV" || movieExt3 == "f4v" || movieExt3 == "F4V" || movieExt3 == "mp3" || movieExt3 == "mp4" || movieExt3 == "MP3" || movieExt3 == "MP4")
    {
        movPlayKind = "flash";
        
        if(browserKind == "IE")
        {
            htmlMPlayer += "<object id='" + theID + "' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ";
            htmlMPlayer += "height='" + theHeight + "' width='" + theWidth + "'>";
            htmlMPlayer += "<param name='movie' value='flash/player.swf'>";
            htmlMPlayer += "<param name='allowscriptaccess' value='always'>";
            htmlMPlayer += "<param name='allowfullscreen' value='true'>";
            htmlMPlayer += "<param name='FlashVars' VALUE='width=" + theWidth + "&height=" + theHeight + "&autostart=" + autoStart + "&logo=no&file=" + movieSrc + "&image=" + theImage + "'>";
            htmlMPlayer += "<param name='quality' value='high'>";
            htmlMPlayer += "<param name='wmode' value='transparent' />";
            htmlMPlayer += "</object>";
        }
        else
        {
            htmlMPlayer += "<object id='" + theID + "' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ";
            htmlMPlayer += "height='" + theHeight + "' width='" + theWidth + "'>";
            htmlMPlayer += "<embed src='flash/player.swf' width='" + theWidth + "' height='" + theHeight + "' ";
            htmlMPlayer += "allowscriptaccess='always' allowfullscreen='true' quality='high' wmode='transparent' "; 
            htmlMPlayer += "flashvars='width=" + theWidth + "&height=" + theHeight + "&autostart=" + autoStart + "&file=" + movieSrc + "&image=" + theImage + "' />";
            htmlMPlayer += "</object>";   
        }
    }
    else
    {
        movPlayKind = "mediaPlayer";
        
        if(browserKind == "IE")
        { 
            htmlMPlayer += "<object id='" + theID + "' height='" + theHeight + "' width='" + theWidth + "' "; 
            htmlMPlayer += "classid='clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6'>";
            htmlMPlayer += "<param name='url' value='" + movieSrc + "'>";
            htmlMPlayer += "<param name='uimode' value='full'>";
            htmlMPlayer += "<param name='playCount' value='" + loopNumber + "'>";
            htmlMPlayer += "<param name='autoStart' value='" + autoStart + "'>"; 
            htmlMPlayer += "<param name='windowlessVideo' value='True'>"; 
            htmlMPlayer += "</object>";
        }
        else
        {
            htmlMPlayer += "<object id='" + theID + "' data='" + movieSrc + "' type='application/x-ms-wmp' width='" + theWidth + "' height='" + theHeight + "' >";
            //htmlMPlayer += "<object id='" + theID + "' data='" + movieSrc + "' type='video/x-ms-wmv' height='" + theHeight + "' width='" + theWidth + "'>";
            htmlMPlayer += "<param name='autostart' value='" + autoStart + "' />";
            htmlMPlayer += "<param name='playCount' value='" + loopNumber + "'>";
            htmlMPlayer += "<param name='volume' value='100' />";
            //htmlMPlayer += "<param name='windowlessVideo' value='True' />";
            //htmlMPlayer += "<param name='uiMode' value='full' />";
            //htmlMPlayer += "<param name='currentPosition' value='0' />";
            //htmlMPlayer += "<embed id='" + theID + "' SRC='" + movieSrc + "' width='" + theWidth + "' height='" + theHeight + "' ";
            //htmlMPlayer += "autostart='" + autoStart + "' windowlessVideo='True' uimode='full'></embed>"; 
            htmlMPlayer += "<p>Error - the plugin has not loaded</p>";
            htmlMPlayer += "</object>"; 
        }
        
    }
    
    return htmlMPlayer;
}
