function ovr(o){
        imgSrc=o.src;
        if (imgSrc.indexOf('0.gif')>-1) o.src=imgSrc.replace("0.gif",".gif");
        else o.src=imgSrc.replace(".gif","0.gif");
}

function add2fav(pid,img){
        o=document.getElementById('fav'+pid);
        o.innerHTML="<img name='a2f"+pid+"' width=18 height=17 title='One of my favorites!' src='"+img+"/images/myFav.gif'>";
        var tmp=new Image; tmp.src='/fast_updates..php?pid='+pid+'&ni='+Math.random();
        tmp.onload=function(){ document.images['a2f'+pid].src=tmp.src;  }
}

function notyet(msg){
        var y,o=document.getElementById('loginFirst');
        if (o){
                if(navigator.appName=="Microsoft Internet Explorer")
                        y = document.body.offsetHeight/2;
                else y= window.outerHeight/2;
                o.style.top=(document.body.scrollTop+Math.floor(y-98))+'px';
                var out="<table width=460 cellpadding=12 border=0>"+
                        "<tr><td>&nbsp;</td><td class=med1B><br><br>If you are a member, "+
                        "<a href=/?page=login>Login First.</a><br>Then, you can "+msg+
                        "<br><br><br>If you are not a member yet, now is the time...<br>"+
                        "<a href=/?mode=reg>Click [REGISTER]</a> in the top menu and join us for FREE!"+
                        "<br>&nbsp; </td></tr></table>";
                o.innerHTML=out;
                o.style.visibility='visible';
        } else alert('Login First. Then, I can '+msg+'\r\n\r\n'+
                'If you are not a member yet, now is the time...\r\n'+
                'Click [REGISTER] in the top menu and join us for FREE!');
}

function it_is_you(){
        alert("Sorry, but I can't do it... this is you trying to contact yourself?!");
}

function back(){ history.go(-1); }

function tgl(n){
        o=document.getElementById('more'+n);
        if (o.style.display=='none') o.style.display='block';
        else o.style.display='none';
}

function popw(w,h,a,url){
        window.open(url,'POP','width='+w+',height='+h+',resizable=1');
        /*
        a.onclick=function(){ 
                alert("I just Sent it...\r\n\r\nIf you want to try again,\r\nrefresh the page first"); 
        }
        */
}

function importent(on,show,from,NO){
		  //alert('[on,show,from,NO]:'+on+','+show+','+from+','+NO);
        if (NO) {
                imWin[from]=1; // do not alert any more (may need to set cookie here too)
                tmp=new Image();
                tmp.src='fast_updates..php?act=im_decline&id='+from+'&level='+NO;
        }
        msg='';
        if (document.all){
                for(i=0;i<document.forms.length;i++) with(document.forms[i]){
                        for(j=0;j<elements.length;j++) if (elements[j].type.indexOf('select')>-1){
                                if (on) elements[j].style.visibility='hidden';
                                else if (elements[j].style.visibility=='hidden')
                                        elements[j].style.visibility='visible';
                        }
                }
        }
        var o1=document.getElementById('overblack');
        if (o1) {
                if (!on) o1.style.visibility='hidden';
                else {
                        // size it to fill the screen
                        self.scrollTo(0,0);
                        if (self.innerWidth) o1.style.height=self.innerHeight;
                        else if (document.body) o1.style.height=document.body.clientHeight;
                        o1.style.visibility='visible';
                }
        }
        var o2=document.getElementById(show);
        if (o2) {
                if (!on) o2.style.visibility='hidden';
                else {
                        w=parseInt(o2.style.width); h=parseInt(o2.style.height);
                        wpx=parseInt((385-w/2))+'px'; // if not 770: =o1.style.width/2-w; 
                        hpx=parseInt(parseInt(o1.style.height)/2-h/2)+'px';
                        o2.style.left=wpx;      o2.style.top=hpx;
                        o2.style.visibility='visible';
                }
        }
}

function popim(from){
        if (self.location.href.indexOf('https')>-1) base='http://207.178.151.150/truesugardaddy.com/';
        else base='/';
		  base='';
        window.open(base+'im.php?do=2&from='+from,'IM'+from,'width=440,height=440,resizable=0');
        importent(0,'attention',from);
}

function start_chat(from_me,to_mid){
        var tmp=new Image(); 
        tmp.src="/fast_updates..php?act=im&id="+to_mid+"&ni="+Math.random();
        window.open('im.php?do=2&from='+to_mid,'IM'+to_mid,'width=440,height=440,resizable=0');
}

function set_attention(from,info){
		  var msg,o=document.getElementById('attention');
        if (!o) return;
        var sp=info.split(';');
        msg="<center><div style='width:340px; padding:12px' class=med1B>"+
                "<div title=\""+sp[0]+"\r\n"+sp[2]+"-year-old\r\n"+sp[1]+"\"><i id=org>"+
                sp[0]+"</i> is trying to chat with you...<br>"+
                "Click the [Accept] to start the IM chat, or the "+
                "[Decline] if you want us to let him/her know that "+
                "you are not intrested.</div><br><table width=290 id=login class=med2B><tr>"+
                "<td><a href=\"javascript:popim("+from+")\">Accept</a></td>"+
                "<td align=right><a href=\"javascript:importent(0,'attention',"+
                from+",1)\">Decline</a></td></tr>"+
                "<tr><td colspan=2 class=small><center style='font-weight:400'>Or, to stop all IM, click "+
                "<a href=\"javascript:importent(0,'attention',"+from+",2)\">here</a></center></td></tr></table>"+
                "</div><OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' WIDTH=1 HEIGHT=1>"+
                "<PARAM NAME=movie VALUE='http://image.sugardaddysite.com/images/menu/attention.swf'>"+
                "<EMBED src='http://image.sugardaddysite.com/images/menu/attention.swf' WIDTH=1 HEIGHT=1 "+
                "TYPE='application/x-shockwave-flash'></EMBED></OBJECT></center>";
        o.innerHTML=msg;
        importent(1,'attention');
}

function FlashRequest(a,b,c,d,e){ return; } // eliminate google video errors
var cnt=0,imWin=new Array();


function chatWin(mid,pass) {
        var width = 800;
        var height = 600;

        // the x,y position of the popup window
        // NOTE: this formula will auto-center the popup on the screen
        var y = (screen.height - height) / 2;
        var x = (screen.width - width) / 2;

        var url = "flashchat/flashchat.php?mid=" + mid + "&password=" + pass;
        var options = "width=" + width + ",height=" + height + ",top=" + y + ",left=" + x + ",resizable";
        window.open( url, "chat", options );
}
