try {
        _location = top.location;
} catch(e) {
        _location = window.location;
}

document.write('<style>');
document.write('.friends img {');
document.write('	border: 1px solid #000;');
document.write('}');
document.write('.friends td, .font12 {');
document.write('	font-size: 12px;');
document.write('	text-align: center;');
document.write('	font-family: 宋体;');
document.write('}');
document.write('.friends td a {');
document.write('	color:#000fff; text-decoration: underline;');
document.write('	font-family: 宋体;');
document.write('}');
document.write('#outborder { position: relative; width: 618px; height: 80px} .union_url {  font-size: 12px;  right: 0px;bottom: 0px;position:absolute;} .union_url a { color: #000fff; padding: 2px; background: #FFF; line-height: 22px; text-decoration: underline}');
document.write('#demoI { FILTER: revealTrans(transition=4,duration=2); VISIBILITY: visible; WIDTH: 100%; }');
document.write('</style>');

document.write('<div id="outborder"><div id=demoI style="overflow:hidden; width:618px;">');
document.write('<table width=1520 border=0 cellpadding=0 cellspacing=0 class=friends>');
document.write('<tr>');
document.write('<td id=demo11>');
document.write('<table border=0 width=1520><tr>');
document.write('<tr>');

<?php    
error_reporting(7);

function getip() {
        if (isset($_SERVER)) {
                if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
                        $realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
                } elseif (isset($_SERVER["HTTP_CLIENT_IP"])) {
                        $realip = $_SERVER["HTTP_CLIENT_IP"];
                } else {
                        $realip = $_SERVER["REMOTE_ADDR"];
                } 
        } else {
                if (getenv('HTTP_X_FORWARDED_FOR')) {
                        $realip = getenv('HTTP_X_FORWARDED_FOR');
                } elseif (getenv('HTTP_CLIENT_IP')) {
                        $realip = getenv('HTTP_CLIENT_IP');
                } else {
                        $realip = getenv('REMOTE_ADDR');
                }
        }
        return $realip;
}



$size = trim($_GET['size']);
if (!$size) {
        $size = '120x90';
}

$names = array();

$sex = trim($_GET['sex']);
if ($sex != 'boy') {

        $sex = 'girl';
        $sex_text = "女";        
} else {
        $sex = 'boy';
        $sex_text = "男";
}                                       


require_once "class.ip2location.php";


//

$id = trim($_GET['id']);
if (!$id) {
        $id = 'g884372'; // 亚交 id#             
}

$ip = getip();
//$ip = "218.5.18.6";
$o = new Ip2Location();
$o->qqwry($ip);
$location = str_replace('CZ88.NET', '', ($o->Country));
//print_r($o);
//$location = mb_convert_encoding($location, 'utf-8', 'gbk');           

//$tpl->assign("location", $location);


if ($size == "120x90") {
        $_images = 163;
} else if ($size == "107x80") {
        $_images = 200;  
}
$images = range(0, $_images);
shuffle($images);  
$num = intval($_GET['num']);

if ($num < 1 OR $num > 20) {
        $num = 5;
}
$num = 8;
//$tpl->assign("num", $num);  
//$tpl->assign("width", (156*$num));


require_once "makefriends_config.php";

$text = $_TODO;
$todo_num = count($text);




if ($_GET['target'] != "_blank") {
        $target="_top";   
} else {
        $target="_blank";
}                         

$target="_blank";       

$img_base_url = "/images/all";
if ($_REQUEST['img_base_url']) {
        $img_base_url = trim($_REQUEST['img_base_url']);
}

//$tpl->assign("target", $target);

$results = array();
for ($i = 0; $i < $num; $i++) {

        $result['name'] = trim($names[$i]);
        $result['old'] = rand(18, 23);                                    
        $result['src'] = "$img_base_url/$size/".$images[$i].".jpg";
        $result['location'] = $location;
        $result['url'] = "http://chinesefriendfinders.com/go/g988247-pmem.subnosubid+reg";
        $result['sex'] = $sex_text;
        $r = rand(0, $todo_num - 1);
        $result['text'] = $text[$r];
        $result['target'] = $target;
        //$tpl->append("results", $result);
        echo "        
        document.write('<td align=\"center\" width=\"120\">');
        document.write('<div class=\"fimage\"><a href=\"".$result['url']."\" onclick=\"pv(this.href);\" target=\"".$result['target']."\"><img src=\"".$result['src']."\" /></a></div>');
        document.write('</td>');
        document.write('<td align=\"center\" width=\"70\" class=font12>');
        document.write('<a href=\"".$result['url']."\" onclick=\"pv(this.href);\" target=\"".$result['target']."\">".$result['location']."<br /> ".$result['old']."岁 单身<br /><font color=\"red\"><b>".$result['text']."</b></font></a>');
        document.write('</td>');
        ";        
}

//$tpl->output();
?>
document.write('</tr></table></td><td width=618 id=demo12></td></tr></table>');
document.write('</div></div>');


try {
	var speed=15
	document.getElementById('demo12').innerHTML=document.getElementById('demo11').innerHTML
	function Marquee11(){
		if(document.getElementById('demo12').offsetWidth-document.getElementById('demoI').scrollLeft<=0)
			document.getElementById('demoI').scrollLeft-=document.getElementById('demo11').offsetWidth
		else{
			document.getElementById('demoI').scrollLeft++
		}
	}
	var MyMar1=setInterval(Marquee11,speed)
	document.getElementById('demoI').onmouseover=function() {clearInterval(MyMar1)}
	document.getElementById('demoI').onmouseout=function() {MyMar1=setInterval(Marquee11,speed)}
} catch(e) {

}