var userAgent = navigator.userAgent.toLowerCase();
var is_webtv = userAgent.indexOf('webtv') != -1;
var is_kon = userAgent.indexOf('konqueror') != -1;
var is_mac = userAgent.indexOf('mac') != -1;
var is_saf = userAgent.indexOf('applewebkit') != -1 || navigator.vendor == 'Apple Computer, Inc.';
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko' && !is_saf) && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ns = userAgent.indexOf('compatible') == -1 && userAgent.indexOf('mozilla') != -1 && !is_opera && !is_webtv && !is_saf;
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera && !is_saf && !is_webtv) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
var Point = function(x, y) {
return { x: parseInt(x), y: parseInt(y)};
}
var Dimension = function(width, height) {
return { width:parseInt(width), height:parseInt(height) };
}
var ShanliaoLite = function () {
var type, containerSize, position, maximize;
var lastStatus = {widht:0, height:0};
this.lite = new function() {
this.id = "shanliao_lite_window";
};
try {
type = shanliao_liteType;
} catch (e) {
type = "blue";
}
try {
containerSize = new Dimension(shanliao_liteWidth, shanliao_liteHeight);
} catch(e) {
containerSize = new Dimension(202, 318);
}
try {
position = shanliao_litePosition;
} catch (e) {
position = 4;
}
try {
maximize = shanliao_maximize;
} catch (e) {
maximize = 1;
}
var user_pwd = '';
try {
user_pwd = '&init_user=' + shanliao_username;
try {
user_pwd += '&init_pass=' + shanliao_password;
} catch(e) {
}
} catch (e) {
}
this.domain = 'http://www.shanliao.com';
this.liteUrl = this.domain + '/lite/lite.swf?themeColor=' + type + user_pwd + '&show_quit=1' + '&isbig=' + maximize;
var dh = document.body.clientHeight || document.documentElement.clientHeight;
var bodySize = new Dimension(document.body.clientWidth, dh);
this.setVisiable = function() {
//this.setModel();
if(document.body == null) return;
var cdiv = document.createElement("DIV");
//cdiv.id = this.lite.id;
cdiv.id = 'shanliao_lite_window';
with(cdiv.style) {
if(is_moz) {
position = "fixed";
} else {
position = "absolute";
}
}
lastStatus.width = containerSize.width;
lastStatus.height = containerSize.height;
var initHeight = containerSize.height;
var initY;
if(maximize == "0")
{
initHeight = "32";
initY = bodySize.height - 32;
} else {
initY = bodySize.height - containerSize.height;
}
var pos = new Point(bodySize.width - containerSize.width, initY);
var innerHTML = '
';
document.write(innerHTML);
this.lite = document.getElementById(this.lite.id);
with(this.lite.style) {
if(is_moz || is_opera) {
position = "fixed";
} else {
position = "absolute";
}
}
//document.body.appendChild(cdiv);
//this.lite = cdiv;
_shanliaoLite.moveTo(position);
if(is_ie) {
setInterval('_shanliaoLite.moveTo(' + position + ')', 20);
}
}
this.setModel = function () {
document.write('');
}
this.setLocation = function (point) {
document.getElementById(this.lite.id).style.left = parseInt(point.x) + "px";
document.getElementById(this.lite.id).style.top = parseInt(point.y) + "px";
}
this.getRect = function() {
this.lite = document.getElementById(this.lite.id);
//return new Dimension(parseInt(this.lite.style.width), parseInt(this.lite.style.height));
}
this.moveTo = function(type) {
var margin = 0, scrollTop = 0, clientHeight;
if (document.compatMode=="CSS1Compat") {
if(is_opera) {
clientHeight = document.body.clientHeight || document.documentElement.clientHeight;
} else {
clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
}
} else {
clientHeight = document.body.clientHeight || document.documentElement.clientHeight;
}
if (document.documentElement && document.documentElement.scrollTop) {
scrollTop = document.documentElement.scrollTop;
} else if (document.body && document.body.scrollTop) {
scrollTop = document.body.scrollTop;
} else {
scrollTop = document.body.scrollTop;
}
if(is_moz && is_ie!="7.0") {
margin = 15;
scrollTop = 0;
}
if(type==3) {
document.getElementById(this.lite.id).style.left = 0;
document.getElementById(this.lite.id).style.top = clientHeight - document.getElementById('shanliao_lite_window').offsetHeight + scrollTop + "px";
} else if(type==2) {
document.getElementById(this.lite.id).style.left = bodySize.width - containerSize.width - margin + "px";
document.getElementById(this.lite.id).style.top = scrollTop + "px";
} else if(type==1) {
document.getElementById(this.lite.id).style.left = 0;
document.getElementById(this.lite.id).style.top = scrollTop + "px";
} else {
document.getElementById(this.lite.id).style.left = bodySize.width - containerSize.width - margin + "px";
document.getElementById(this.lite.id).style.top = clientHeight - this.lite.offsetHeight + scrollTop + "px";
}
}
this.min = function() {
this.lite.style.height = "32px";
document.getElementById('shanliao_lite_o').style.height = "32px";
this.moveTo(position);
}
this.res = function() {
this.lite.style.height = lastStatus.height + "px";
document.getElementById('shanliao_lite_o').style.height = lastStatus.height + "px";
this.moveTo(position);
}
this.close = function() {
this.setDisplay(false);
}
this.setDisplay = function(flag) {
if(flag == true) {
this.lite.style.display = "block";
} else {
this.lite.style.display = "none";
}
}
this.setInitSize = function() {
this.lite.style.width = containerSize.width;
if(maximize==0) {
this.lite.style.height = "32px";
document.getElementById('shanliao_lite_o').style.height = "32px";
} else {
this.lite.style.height = containerSize.height;
document.getElementById('shanliao_lite_o').style.height = containerSize.height;
}
this.moveTo(position);
}
}
function shanliao_maxWindow(rid, username, password) {
var NewWindow = window.open ('http://www.shanliao.com/' + rid + '?username=' + username + '&password=' + password, 'newWin', 'width=641,height=582,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=Yes,resizable=Yes,fullscreen=No');
NewWindow.focus();
}
var _shanliaoLite = new ShanliaoLite();
_shanliaoLite.setVisiable();
function shanliao_FrameClose() {
_shanliaoLite.close();
}
function shanliao_FrameMin() {
_shanliaoLite.min();
}
function shanliao_FrameRes() {
_shanliaoLite.res();
}
function shanliao_FrameShow() {
_shanliaoLite.setInitSize();
}