﻿/*
 * common.js
 * public function defined
 *
 * require jQuery support
 */
(function(){
	GetCookie=function(n) /* n->name */
	{  
		var a=n+"=",
			  an=arg.length,
			  c=document.cookie,
			  cn=c.length,
			  i=0, j;
		
		while (i<cn) 
		{
			j=i+an;	
			if (c.substring(i, j)==a) return getCookieVal(j);  
			i=c.indexOf(" ", i)+1;	
			if (i==0) break;   
		}  
		return null
	};

	getCookieVal=function(i) /* i->offset*/
	{
		var c=document.cookie,
			  n=c.indexOf(";", i);
		
		if (n==-1) n=c.length;
		return unescape(c.substring(i, n))
	};

	SetCookie=function(n, v) /*n->name, v->value*/ 
	{  
		var av=arguments,
			  ac=av.length,
			  expires=(ac>2 ? av[2] : null),
			  path=(ac>3 ? av[3] : null),
			  domain=(ac>4 ? av[4] : null),
			  secure=(ac>5 ? av[5] : false);
		
		document.cookie=n + "=" + escape (v) +
			(expires==null ? "" : "; expires=" + expires.toGMTString()) +
			(path==null ? "" : "; path=" + path) +
			(domain==null ? "" : "; domain=" + domain) +
			(secure==true ? "; secure" : "")
	};

	DeleteCookie=function(n) /* n->name */
	{  
		var t=new Date(),
			  v=GetCookie(n);
			  
		t.setTime(t.getTime()-1);   
		document.cookie=n + "=" + v + "; expires=" + t.toGMTString()
	};
	
	/*
	*  @desc: Convert string to it boolean representation
	*  @param: s - string for covertion
	*  @return: true or false
	*/
	ToBoolean=function(s)
	{
		if (typeof s=="string") s=s.toLowerCase();

		switch (s)
		{
			case "1":
			case "true":
			case "yes":
			case "y":
			case 1:
			case true:
				return true;
				break;

			default: return false
		}
	};
	
	/*
	*  @desc: make sure var is undefined
	*  @param: o - object var
	*  @return: true or false
	*/
	undef=function(o) {return typeof(o)==="undefined"};
	
	/*
	*  @desc: insert a element into array
	*  @param: n->index, o->object
	*  @return: 
	*/
	Array.prototype.insertAt=function(n, o)
	{
		if (-1<i && n<this.length && null!=o)
		{
			for (var i=this.length-1; i>=n; i--)
			{
				this[i+1]=this[i];
			}
			this[n]=o
		}  
	};

	/*
	*  @desc: remove a element from array
	*  @param: n->index
	*  @return: 
	*/
	Array.prototype.removeAt=function(n)
	{
		if (-1<n && n<this.length)
		{
			for (var i=n; i<this.length; i++)
			{
				this[i] = this[i+1];
			} 
			this.length -= 1
		}  
	};

	/*
	*  @desc: remove a element from array
	*  @param: o->element object
	*  @return: 
	*/
	Array.prototype.remove=function(o) 
	{ 
		if(null==o) return;

		var i, n=0, k=0;
		
		for(i=0; i<this.length; i++) 
		{
			if (this[i]==o)
				k++;
			else
				this[n++] = this[i]; 
		}

		this.length -= k
	};

	/*
	*  @desc: make sure a exists element in array
	*  @param: o->element object
	*  @return: true or false
	*/
	Array.prototype.contains=function(o) 
	{ 
	   if(null != o)
	   {
			for(var i=0; i<this.length; i++) 
			{ 
				if(this[i]==o) return true
			}
		} 
		
		return false
	}; 

	/*
	*  @desc: get a exists element index in array
	*  @param: o->element object
	*  @return: index
	*/
	Array.prototype.indexOf=function(o) 
	{ 
	   if(null!=o)
	   {
			for(var i=0; i<this.length; i++) 
			{ 
				if(this[i]==o) return i
			}
		} 
		
		return -1
	};

	/*
	*  @desc: get a exists element index in array
	*  @param: o->element object
	*  @return: index
	*/
	Array.prototype.swap=function(x, y) 
	{
		var t=this[x];
		this[x]=this[y];
		this[y]=t;
		
		return this
	};

	/*
	*  @desc: clear all elements of array
	*/
	Array.prototype.clear=function() {this.length=0};  

	String.prototype.trim=function(){return $.trim(this)};
	//String.prototype.isEmail=function(){return /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(this)};
	String.prototype.isEmail=function(){return /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/.test(this)};
	String.prototype.isDate=function(){return /\b(1[0-2]|0?[1-9])[\-\/](0?[1-9]|[12][0-9]|3[01])[\-\/]((19|20)\d{2})\b/.test(this)};
	String.prototype.isValidString=function(){return /^([a-zA-Z0-9_\-])+([a-zA-Z0-9_\-])+([a-zA-Z0-9_\-])+$/.test(this)};
	String.prototype.isNumeric=function(){var n=parseFloat(this); return (n==this && !isNaN(n))};
	String.prototype.isInteger=function(){var n=parseInt(this); return (String(n)==this && !isNaN(n))}; 
	String.prototype.htmlEncode=function()
	{
		var i, s=this, reg=[
			{r: "&", v: "&amp;"},
			{r: "<", v: "&lt;"},
			{r: ">", v: "&gt;"},
			{r: "  ", v: "&nbsp; "},
			{r: "\'", v: "&#39;"},
			{r: "\"", v: "&quot;"},
			{r: "\n", v: "<br />"}
		];
		
		for (i=0; i<reg.length; i++) s=s.replace(new RegExp(reg[i].r, "gi"), reg[i].v);
		
		return s
	};
	
	/*
	*  @desc: parse image size
	*  @param: o->image object
	*/
	ParseImageSize=function(o)
	{
		if (o.tagName != "IMG") return;
		
		o=$(o);
		
		var w=o.width(),
			  h=o.height(),
			  s=o.attr("src"),
			  a, b;
		
		if (w==0 || h==0) return;
		
		if (w > 125 || h > 94)
		{
			b = ((h / w) > (94 / 125));
			o.width(b ? (94 / h) * w : 125);
			o.height(b ? 94 : (125 / w) * h);
			
			if (o.parent()[0].tagName=="A")  o=o.parentElement;
			
			$("<a>", {
				text: "View Image",
				title: "Click here view source image", 
				href: s,
				target: "_blank",
				css: {"margin-left": 5}
			}).appendTo(o.parent())
		}
	};

	/*
	*  @desc: dateAdd
	*  @param: interval, number
	*  @return: date
	*/
	Date.prototype.dateAdd=function(interval, number) 
	{ 
		var d=this, 
			  n={"q": 3, "w": 7},
			  k={"y":"FullYear", "q": "Month", "m":"Month", "w":"Date", "d":"Date", "h":"Hours", "n":"Minutes", "s":"Seconds", "ms":"MilliSeconds"}; 
			  
		eval("d.set" + k[interval] + "(d.get" + k[interval] + "()+" + ((n[interval] || 1) * number) + ")");
		
		return d
	};

	/*
	*  @desc: dateDiff
	*  @param: interval, objDate2
	*  @return: number
	*/
	Date.prototype.dateDiff=function(interval, objDate2) 
	{ 
		var d=this, r=0, 
			  t=d.getTime(), 
			  t2=objDate2.getTime(),
			  m=d.getMonth(),
			  m2=objDate2.getMonth(),
			  dy=objDate2.getFullYear()-d.getFullYear(); 
		
		switch (interval)
		{
			case "y": r=dt; break;
			case "q": r=dy*4 + Math.floor(m2/4) - Math.floor(m/4); break;
			case "m": r=dy*12 + m2 - m; break;
			case "ms": r=t2-t; break;
			case "w": r=Math.floor((t2+345600000)/(604800000))-Math.floor((t+345600000)/(604800000)); break;
			case "d": r=Math.floor(t2/86400000)-Math.floor(t/86400000); break;
			case "h": r=Math.floor(t2/3600000)-Math.floor(t/3600000); break;
			case "n": r=Math.floor(t2/60000)-Math.floor(t/60000); break;
			case "s": r=Math.floor(t2/1000)-Math.floor(t/1000); break;
		}
		
		return r
	};
   
	Refer=
	{
		_isShow: function(o)
		{
			if (o.css)
			{
				return o.css("display")=="block" ||
						   o.css("display")=="inline"
			}
			return false
		},
		
		_dWidth: function()
		{
			return $.browser.mozilla || $.browser.safari ? 
				document.body.clientWidth : 
				$(document.body).width()
		},
	   
		_dHeight: function()
		{
			return $.browser.mozilla || $.browser.safari ? 
				document.body.clientHeight : 
				$(document.body).height()
		},
	   
		_getEvent: function(fn)
		{
			var e=window.event;
			
			return (undef(e) || e===null) ? 
				fn.caller.arguments[0] :
				e
		},
					
		_removeElement: function(o)
		{
			if (o.parentElement) o.parentElement.removeChild(o);
			else if (o.parentNode)
			{
				if (o.parentNode.removeNode) o.parentNode.removeNode(o);
				else if (o.parentNode.removeChild) o.parentNode.removeChild(o);
			} 
		},
		
		_screenLeft: function() {return window.screenLeft||window.screenX},
		_screenTop: function() {return window.screenTop||window.screenY},
		
		_dd: function(n) {return undef(n)||n===null ? 0:n},
		_deta: function(d)
		{
			if ($.browser.msie) return this._dd(d.ie);
			if ($.browser.opera) return this._dd(d.op);
			if ($.browser.safari) return this._dd(d.sa);
			if ($.browser.mozilla) return this._dd(d.mo);
			return this._dd(d.ot)
		},
		
		_isWnd: function(w)
		{
			return (w && (
			   ($.browser.msie && !w.closed) ||
			   ($.browser.opera && !w.closed) ||
			   ($.browser.safari && !w.closed) ||
			   ($.browser.mozilla && !w.closed)))
		}
	}; 

	var HelpWin = null;
	ShowHelp=function(u, w, h, s) /*u: url, w: width, h: height, s: status */
	{
		try {
			HelpWin = window.open(u, "HelpWin", "width=" + w + ",height=" + h + ",left=" + ((screen.width-w)/2) + ",top=" + ((screen.height-h)/2) + ",toolbar=no,directories=no,status=" + (s ? s : "yes") + ",scrollbars=no,resizable=no,menubar=no"); 
			HelpWin.moveTo((screen.width-w)/2, (screen.height-h)/2);
			HelpWin.focus()
		} catch (e) {}
	};
	
	ShowWindow=function(u, w, h, t, s, r) /*u: url, w: width, h: height, t: title, s: status, r: resizable */
	{
		try {
			var cWin = window.open(u, t, "width=" + w + ", height=" + h + ", left=" + ((screen.width-w)/2) + ", top=" + ((screen.height-h)/2) + ",toolbar=no,directories=no,status=" + (s ? s:"yes") + ",scrollbars=no,resizable=" + (r ? r:"no") + ",menubar=no"); 
			cWin.moveTo((screen.width-w)/2, (screen.height-h)/2);
			cWin.focus()
		} catch (e) {}
	};
	
	/*
	*  @desc: build <LI> index(s), show or hide selected index <DD>
	*  @param: array list of <LI>
	*/
	menuList=function(o)
	{
		var n=(o.size()/3);
		if (parseInt(n) != n || n==0) return;
		
		for (var i=0; i<n; i++) o.slice(3*i, 3*i+3).attr("m", i);
		
		o.bind({
			mouseover: function() {
				var o=$(this),
					p=o.parent(),
					m=o.attr("m"),
					n=p.attr("n") || 0;
					
				if (m!=n)
				{
					o=p.find("[m='" + n + "']").attr("class", "b2");
					o.first().attr("class", (n==0 ? "b4":"b1"));
					o.last().attr("class", "b3");
					
					o=p.find("[m='" + m + "']").attr("class", "a2");
					o.first().attr("class", "a1");
					o.last().attr("class", "a3");
					
					p.parent().siblings("dd:eq(" + n + ")").hide();
					p.parent().siblings("dd:eq(" + m + ")").fadeIn("slow");
					
					p.attr("n", m);
				}
			}
		})
	};
	
	/*
	*  @desc: today focus lunbo by <LI> <P> index(s),
	*  bind mouseover or mouseout on tag <LI> <P>, 
	*  show or hide selected index
	*/
	lunBo = {
		p: null, tid: null, idx: 0, cnt: 0, b: false, d: false,
		init: function(o) {
			with (lunBo)
			{
				p=o;
				b=true;
				d=((cnt=p.children().size()) == p.siblings().size());
				
				if (!d) return; 
				
				p.children().bind({
					mouseover: function(){lunBo.stop(); lunBo.next($(this).index())},
					mouseout: function(){lunBo.start()}
				})
			}
		},
		start: function(o) {with (lunBo) {if (!b) init(o); if (d) tid=setInterval(next, 5000)}},
		next: function(n) {
			with (lunBo)
			{
				var b=!undef(n);
				
				if (b && n==idx) return;
				
				p.siblings().eq(idx).hide();
				p.children().eq(idx).removeClass();
				
				idx = (b ? n : idx+1);
				
				if (idx>cnt-1) idx=0;
				
				p.siblings().eq(idx).show(); //fadeIn("slow");
				p.children().eq(idx).addClass("active")
			}
		},
		stop: function() {with (lunBo) {if (tid) {clearInterval(tid);tid=null}}}
	};	
	
	/*
	*  @desc: random generator
	*  @param: seed number
	*  @return: random number
	*/
	Random = function(n) {return Math.ceil(Math.random() * (typeof(n) == "number" ? n:100000000))};
	
	/*
	*  @desc: guid generator
	*  @return: random string
	*/
	GUID = function() {return (Math.random() * (1 << 30)).toString(16).replace('.', '')};

	/*
	*  @desc: building iframe in window
	*  @param: u -> url, w -> width, h -> height
	*  @return: none
	*/
	WinIframe = {
		_p_: null, _u_: null,
		
		init: function() {
			with (this)
			{
				var wnd=$(window), bdy=$("body"), w=wnd.width(), h=wnd.height();
				var ie6=($.browser.msie && $.browser.version=="6.0");
				
				if (bdy.width() > w) w=bdy.width();
				if (bdy.height() > h) h=bdy.height();
				
				_u_ = $("<div>", {
					id: "pWin" + Random(), 
					css: {position: "absolute", left: 0, top: 0, width: w, height: h, backgroundImage: "url(/files/images/alpha_60.png)", display: "none", textAlign: "center"},
					html: "<iframe src='about:blank' frameborder='0' scrolling='no' style='position: " + (ie6 ? "absolute":"fixed") + "; width:400px; height:300px;'></frame>"
				}).appendTo("body");

				_p_ = _u_.find("iframe");
				
				$(window).bind("resize" + (ie6 ? " scroll":""), function() {
					var wnd=$(window), bdy=$("body"), w=wnd.width(), h=wnd.height();
					
					if (bdy.width() > w) w=bdy.width();
					if (bdy.height() > h) h=bdy.height();
					
					_u_.css({width: w, height: h});
					_p_.css({left: (wnd.width() - _p_.width())/2 + (ie6 ? wnd.scrollLeft() : 0), top: (wnd.height() - _p_.height())/2 + (ie6 ? wnd.scrollTop() : 0)})
				})
			}
		},
		
		show: function(u, w, h, p) {
			with (this)
			{
				if (_u_==null) init();
				
				var wnd=$(window);
				
				w = (undef(w) ? 400:w);
				h = (undef(h) ? 300:h);
				
				_p_.css({width: w, height: h, left: (wnd.width()-w)/2, top: (wnd.height()-h)/2}).attr("src", u+"?t="+Random()+(undef(p) ? "" : "&"+p)).show();
				_u_.show().focus();
			}
		},
		
		hide: function() {this._p_.fadeOut(300, function() {with(WinIframe){_u_.hide(); _p_.attr("src", "about:blank")}})}
	};
	
	/*
	*  @desc: build loading div in window
	*  @param: t -> title, w -> width, h -> height
	*  @return: none
	*/
	WinLoading = {
		_p_: null, _u_: null, 
		
		init: function(t) {
			with (this)
			{
				var wnd=$(window), bdy=$("body"), w=wnd.width(), h=wnd.height();
				var ie6=($.browser.msie && $.browser.version=="6.0");
				
				if (bdy.width() > w) w=bdy.width();
				if (bdy.height() > h) h=bdy.height();
				
				_u_ = $("<div>", {
					id: "pWinLoading", 
					css: {left: 0, top: 0, width: w, height: h},
					html: "<dl><dt><span>" + (undef(t) ? "Loading" : t) + "</span><p></p></dt><dd>&nbsp;</dd></dl>",
					"class": "WinLoading"
				}).appendTo("body");
				
				_p_ = _u_.find("dl");
				
				if (ie6) _p_.css({position: "absolute"});
				
				_p_.find("dt p").css({opacity: 0.5}).bind({click: function(){WinLoading.hide()}, mouseover: function(){$(this).css({opacity: 1})}, mouseout: function(){$(this).css({opacity: 0.5})}});
				
				$(window).bind("resize" + (ie6 ? " scroll":""), function() {
					var wnd=$(window), bdy=$("body"), w=wnd.width(), h=wnd.height();
					
					if (bdy.width() > w) w=bdy.width();
					if (bdy.height() > h) h=bdy.height();
					
					_u_.css({width: w, height: h});
					_p_.css({left: (wnd.width() - _p_.width())/2 + (ie6 ? wnd.scrollLeft() : 0), top: (wnd.height() - _p_.height())/2 + (ie6 ? wnd.scrollTop() : 0)})
				})
			}
		},
		
		show: function(t, w, h) {
			with (this)
			{
				if (_u_==null) init(t);
				
				var wnd=$(window);

				w = (undef(w) ? 300:w);
				h = (undef(h) ? 180:h);
				
				_p_.css({width: w, height: h, left: (wnd.width()-w)/2, top: (wnd.height()-h)/2}).show();
				_u_.show()
			}
		},
		
		hide: function() {this._p_.fadeOut(500, function(){WinLoading._u_.hide()})}
	};

	/*
	*  @desc: force input field numeric
	*/
	$.fn.ForceNumericOnly = function()
	{
		return this.each(function()
		{
			$(this).keydown(function(e)
			{
				// allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
				var key = (e.keyCode || e.which || 0), o = $(this);
				var ret = (
					key == 8 ||
					key == 9 ||
					key == 13 ||
					key == 46 ||
					(key >= 37 && key <= 40) ||
					(key >= 48 && key <= 57) ||
					(key >= 96 && key <= 105));
				
				if ($.browser.opera) o.attr("key", o.attr("key") + (ret ? "" : String.fromCharCode(key)));
				
				return ret
			});
			
			if ($.browser.opera)
			{
				$(this).keyup(function()
				{
					var o=$(this), key=String(o.attr("key")), re;
					if (key !== "")
					{
						re = new RegExp("[" + key + "]", "gi");
						o.val(o.val().replace(re, ""));
						o.attr("key", "")
					}
				})
			}
		})
	}; 
	
	/*
	*  @desc: force input field charactors [a-z, A-Z]
	*/
	$.fn.ForceCharOnly = function()
	{
		return this.each(function()
		{
			$(this).keydown(function(e)
			{
				// allow backspace, tab, delete, arrows, charactors[a-z, A-Z] ONLY
				var key = (e.keyCode || e.which || 0), o = $(this);
				var ret = (
					key == 8 ||
					key == 9 ||
					key == 13 ||
					key == 46 ||
					(key >= 65 && key <= 90));
				
				if ($.browser.opera) o.attr("key", o.attr("key") + (ret ? "" : String.fromCharCode(key)));
				
				return ret
			});
			
			if ($.browser.opera)
			{
				$(this).keyup(function()
				{
					var o=$(this), key=String(o.attr("key")), re;
					if (key !== "")
					{
						re = new RegExp("[" + key + "]", "gi");
						o.val(o.val().replace(re, ""));
						o.attr("key", "")
					}
				})
			}
		})
	}; 

	/*
	*  @desc: building supercam
	*/
	SuperCam = {
		tid: null, url: null, b: false, sec: 5,
		init: function(u, t) 
		{
			with (this)
			{
				if (!undef(u)) url = u;
				if (!undef(t)) sec = t; 
				
				if (sec > 10) sec = 10;
				if (sec < 1) sec = 1;
				
				$(window).load(function(){if ($.browser.msie) $(".cam .capture").css({filter: "revealTrans(duration=2, transition=6)"})});
				$("body").bind({
					contextmenu: function(event) {var o=$(event.target||event.srcElement); return (o.attr("class") == "capture")},
					selectstart: function() {return false}, 
					unload: function() {SuperCam.stop()}
				});
				
				$("body .func input").click(function(){
					var o=$(this), s=o.attr("class");
					
					if (s=="start" || s=="stop") {var b=(s=="start"); (SuperCam[s])(); o.attr("class", b ? "stop" : "start"); o.attr("title", b ? "Stop" : "Start")}
					else if (s=="help") {ShowHelp("/webcam/webcam.help.aspx", 600, 420)}
					else if (s=="chat" || s=="chat a") {var act=o.attr("act"); if (!undef(act)) (new Function(act))()}
				});
				
				b = true
			}
		},
		start: function() {with (this) {if (!b) init(); if (b) {next(); tid=setInterval(next, sec * 1000)}}},
		next: function() {
			var o=$("body .capture");
			if (o.size() !=0)
			{
				try {with (o[0].filters.revealTrans) {Transition=6; apply(); play()}} catch (e) {}
				
				o.attr("src", SuperCam.url + "?t=" + Random())
			}
		},
		stop: function() {with(this) {if (tid) {clearInterval(tid); tid=null}}}
	};

	/*
	*  @desc: building view other scroll div
	*/
	pViewOther = {
		pLiCnt: 0, pIdx: 0, pCnt: 4, nCnt: 0, bInit: false, oLeft: null, oMain: null, oRight: null,
		init: function() {
			with (this)
			{
				var oList;
				
				oMain = $("dl dd.other .main");
				oList = oMain.find("div ul li");
				pLiCnt = oList.size();

				if (pLiCnt == 0) return;
				
				oList.bind({mouseover: function(){$(this).fadeTo(300, 1.0)}, mouseout: function(){$(this).fadeTo(300, 0.6)}}).css("opacity", 0.6);

				nCnt = Math.ceil(pLiCnt / pCnt);

				oLeft = $("dl dd.other .left").bind({
					mouseover: function() {var o=$(this); if (pViewOther.pIdx > 0) o.fadeTo(300, 1.0)},
					mouseout: function() {var o=$(this); if (pViewOther.pIdx > 0) o.fadeTo(300, 0.6)},
					click: function() {var p=pViewOther; if (p.pIdx > 0) p.go(-1)}
				}).css("opacity", 0.6);
				
				oRight = $("dl dd.other .right").bind({
					mouseover: function() {var o=$(this), p=pViewOther; if (p.pIdx < p.nCnt-1) o.fadeTo(300, 1.0)},
					mouseout: function() {var o=$(this), p=pViewOther; if (p.pIdx < p.nCnt-1) o.fadeTo(300, 0.6)},
					click: function() {var p=pViewOther; if (p.pIdx < p.nCnt-1) p.go(1)}
				}).css("opacity", 0.6);
				
				bInit = true
			}
		},
		go: function(direct) {
			with (this)
			{
				if (!bInit) {init()}
				else if (pLiCnt == 0) {return}
				else
				{
					var o, w, cur = pIdx + (undef(direct) ? 0 : direct);
					if (cur < 0) cur = 0;
					if (cur > nCnt-1) cur = nCnt-1;
					if (cur != pIdx)
					{
						o = oMain.find("div ul");
						w = oMain.find("div").width();
						if (o && !o.is(":animated")) 
						{
							pIdx = cur;
							o.animate({left: (direct > 0 ? "-=" : "+=") + w}, "slow")
						}
					}
				}

				if (oLeft) oLeft.css({"background-image": "url(/files/images/left" + (pIdx==0 ? "_dis" : "") + ".png)"});
				if (oRight) oRight.css({"background-image": "url(/files/images/right" + (pIdx==nCnt-1 ? "_dis" : "") + ".png)"})
			}
		}
	};
	
	/*
	*  @desc: building view business plan picture, video
	*/
	pViewPic = {
		id: "", path: "", video: "", img: [], cur: 0, oView: null, oPage: null,
		go: function(o) {
			with (this) {
				var s = $(o).attr("class");
				if (s == "prev" || s == "next") {
					cur += (s=="prev" ? -1 : 1);
					
					if (cur < 0) {cur = 0; return}
					if (cur > img.length-1) {cur = img.length-1; return}
					
					gopage()
				}
				else if (s=="video") {
					if (video.trim() != "") {
						oView.html(
							(/youku/gi).test(video) ?
								"<embed type='application/x-shockwave-flash' src='" + video + "' bgcolor='#ffffff' quality='high' allowfullscreen='true' " +
								"flashvars='isShowRelatedVideo=false&showAd=0&show_pre=1&show_next=1&isAutoPlay=false&isDebug=false&UserID=&winType=interior&playMovie=true&MMControl=false&MMout=false&" +
								"RecordCode=1001,1002,1003,1004,1005,1006,2001,3001,3002,3003,3004,3005,3007,3008,9999' pluginspage='http://www.macromedia.com/go/getflashplayer' style='width: 610px; height: 310px; margin: 4px; border: 1px solid #ccc;'></embed>"
								:
								"<embed type='application/x-shockwave-flash' src='" + video + "' allowscriptaccess='always' allowfullscreen='true'  style='width: 610px; height: 310px; margin: 4px; border: 1px solid #ccc;'></embed>"
						)
					}
				}
			}
		},
		
		gopage: function() {
			with (this) {
				if (cur > -1 && cur < img.length) {
					if (img[cur] && img[cur] != "") {
						oPage.html((cur+1) + " / " + img.length);
						oView.html("<img src='" + path + id + "_" + img[cur] + "' border='0' />")
					}
				}
			}
		},
		
		init: function(o) {
			with (this) {
				id = o.id || "";
				path = o.path || "";
				video = o.video || "";
				
				if (o.img) {
					for (var i=0; i<o.img.length; i++) {
						if (o.img[i].trim() != "") img.push(o.img[i])
					}
				}
				
				oView = $(".main .right .infoview dl dd p.pic");
				oPage = $(".main .right .infoview dl dd p.func tt");
				
				gopage()
			}
		}
	};
	
	/*
	 * desc: make right's bottom same as left obj's bottom
	 * params: o->left obj, p->right obj
	 */
	Left_Bottom_Right = function(o, p) {
		if (o.size() > 0 && p.size() > 0) {
			var h=o.offset().top + o.height() - p.offset().top;
			if (h > p.height()) p.height(h)
		}
	};
	
})()

