﻿var obj_fprt=$('floatprint');
var offsetLeft=0;
function autoresize() {
	offsetLeft=parseInt((document.body.clientWidth-800)/2);
	if(offsetLeft<0) offsetLeft=0;
	automove();
}
function automove() {
	if (obj_fprt!=null && typeof(obj_fprt)=='object') {
		obj_fprt.style.left=offsetLeft+755;
		obj_fprt.style.top=document.body.scrollTop+84+document.documentElement.scrollTop;
	}
	if (obj_fpage!=null && typeof(obj_fpage)=='object') {
		obj_fpage.style.left=offsetLeft-45;
		obj_fpage.style.top=document.body.scrollTop+79+document.documentElement.scrollTop;
	}
}
function myPrint() {
	var nameList=new Array('nav_layer','nav_layer2','nav_layer3','scaleArea','floatpage','floatpage2','floatprint','pageMove');
	var objList=new Array();
	var i,obj_target;
	for(i=0; i<nameList.length; i++) {
		obj_target=$(nameList[i]);
		if (obj_target!=null && typeof(obj_target)=='object') {
			obj_target.style.display='none';
			objList.push(obj_target);
		}
	}
	//alert(objList.length);
	window.print();
	for(i=0; i<objList.length; i++) {
		(objList[i]).style.display='';
	}
}

function initPrtObj() {
	if (obj_fprt==null || typeof(obj_fprt)!='object') {
		var offsetLeft=0;
		offsetLeft=parseInt((document.body.clientWidth-800)/2);
		document.writeln('<div id="floatprint" style="position:absolute; left:'+(offsetLeft+755)+'px; top:84px; display:none;"><img src="../../../common/images/print.gif" width="16" height="16" border="0" style="cursor:hand;" onClick="myPrint();" alt="Print" /></div>');
	
		obj_fprt=$('floatprint');
		obj_fprt.style.display='';
	} else {
		if(is_ie && is_ie<7)
			try {
				obj_fprt.style.position='absolute';
			} catch (e) {
			}
		obj_fprt.style.display='';
		if(obj_fprt.childNodes.length>0) {
			obj_fprt.childNodes[0].onclick=function(e) {
				myPrint();
			}
		}
	}
	if(is_ie && is_ie<7)
		try {
			$('floatpage').style.position='absolute';
		} catch (e) {
		}
}
initPrtObj();
autoresize();
window.onscroll=automove;
window.onresize=autoresize;

//-----------------------------------------------------------------------------------------------------
function SetRecomPara() {
	try {
		var obj=$('recommend_i');
		if (obj!=null && typeof(obj)=='object') {
			var list,str,cookieid='';
			list=document.URL.split('/');
			str='';
			if(list.length) {
				if(parseInt(list[list.length-1])) {
					currpage=parseInt(list[list.length-1]);
					if(list[list.length-3]=='c' || list[list.length-3]=='e') {
						for(i=list.length-4; i<list.length-1; i++) {
							str += list[i]+'/';
							if(i==list.length-3 && list[i]=='e')
								cookieid += 'c/';
							else	cookieid += list[i]+'/';
						}
						str += currpage;
						cookieid += currpage;
					}
				}
			}
			if(str!='') {
//need to be correct
				obj.src = '/re/banyan_recom/recommend.php?curissue='+str;
			}
		}
	} catch(e) {};
}
SetRecomPara();
