var CCC =
{
	memberTL: null,
	partnerTimer: null,
	tmp:{},
	ajax: new Ajax('index.php', 'post', true, 'url'),
	
	scrollRibbon: function(direction, id, itemWidth)
	{
		//if(this.memberTL) this.memberTL.destroy();
		//this.memberTL = new TimeLine(60, 10);
		
		var ribbon 	= document.getElementById(id);
		if(!ribbon) return false;
		var area	= ribbon.getElementsByTagName('div').item(0);
		var content	= ribbon.getElementsByTagName('div').item(1);
		var ncWidth	= itemWidth || 76;
		var origLeft = (!isNaN(parseInt(content.style.marginLeft)) ? parseInt(content.style.marginLeft) : 0);
		var newLeft = origLeft + direction * ncWidth;
		
		if(newLeft <= area.offsetWidth - content.offsetWidth + 9) newLeft = area.offsetWidth - content.offsetWidth + 9;
		if(newLeft >= 0) newLeft = 0;		
		
		/*this.memberTL.addEvent(TIME_LINE_EVENT.ON_ENTER_FRAME, new CallBack(function(TimeLine, param)
		{
			content.style.marginLeft = Math.round(origLeft - (origLeft - newLeft) / TimeLine.frame * TimeLine.currentFrame) + 'px';
		}));
		this.memberTL.addEvent(TIME_LINE_EVENT.ON_END, new CallBack(function(TimeLine)
		{
			CCC.memberTL = null;
		}));
		this.memberTL.play();*/
		
		content.style.marginLeft = newLeft + 'px';
		return true;
	},
	
	scrollPartnerRibbon: function(direction, id, itemWidth, interval)
	{
		var ribbon 	= document.getElementById(id);
		if(!ribbon) return false;
		var content	= ribbon.getElementsByTagName('table').item(0);
		var area	= ribbon;
		var ncWidth	= itemWidth || 133;
		//alert(parseInt(content.style.marginLeft));
		
		var newLeft = (!isNaN(parseInt(content.style.marginLeft)) ? parseInt(content.style.marginLeft) : 0) + direction * ncWidth;
		if(area.offsetWidth + content.offsetWidth <= Math.abs(newLeft) ){ newLeft = (area.offsetWidth + content.offsetWidth) * -1; if(CCC.partnerTimer) clearInterval(CCC.partnerTimer);}
		if(newLeft >= 0) newLeft = 0;
		
		content.style.marginLeft = newLeft + 'px';
		
		if(interval)
			CCC.partnerTimer = setInterval(function()
			{
				CCC.scrollPartnerRibbon(direction, id, itemWidth);
			}, interval);
		
		return true;
	},
	
	writeVideoPlayer: function(url_video,name_video, _width, _height, title, stillimage)
    {
        var video_url = _URL_ROOT+'flash/player.swf?src='+url_video+'&s='+_URL_ROOT+'flash/skin.swf'+
		(stillimage ? '&simg='+stillimage : '')+
		(title ? '&t='+title : '');
		
        document.write('<object id="video" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" style="width:'+(_width != '' ? _width : 400)+'px; height:'+(_height != '' ? _height : 300)+'px;">');
        document.write('<param name="movie" value="'+video_url+'">');
        document.write('<param name="src" value="'+video_url+'">');
        document.write('<param name="quality" value="High">');
        document.write('<param name="allowScriptAccess" value="sameDomain">');
        document.write('<param name="bgcColor" value="FFFFFF">');        
        document.write('<embed src="'+video_url+'" quality="high" bgcolor="#ffffff" name="video" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" style="width:'+(_width != '' ? _width : 400)+'px; height:'+(_height != '' ? _height : 300)+'px; text-align:middle;">');
        document.write('</object>');
    },
	
	writeBanner: function(url_banner, w, h)
	{
		document.write('<object id="banner" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" style="width:'+(w != '' ? w : 400)+'px; height:'+(h != '' ? h : 300)+'px;">');
        document.write('<param name="movie" value="'+url_banner+'">');
        document.write('<param name="src" value="'+url_banner+'">');
        document.write('<param name="quality" value="High">');
        document.write('<param name="allowScriptAccess" value="sameDomain">');
        document.write('<param name="bgcColor" value="FFFFFF">');        
        document.write('<embed src="'+url_banner+'" quality="high" bgcolor="#ffffff" name="video" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" style="width:'+(w != '' ? w : 400)+'px; height:'+(h != '' ? h : 300)+'px; text-align:middle;">');
        document.write('</object>');
	},
	
	closeWelcomeBox: function(md5)
	{
		if( (box = document.getElementById('box-welcome')) )
			box.parentNode.removeChild(box);
		
		setCookie('welcome_box_state', md5, 365);
	},
	
	switchTab: function(elm, idPrefix)
	{
		var liList = elm.parentNode.getElementsByTagName('li');
		for(var i=0, node ; node = liList[i] ; i++)
		{
			DOMElement.proto(node);
			var tabID = idPrefix +'-'+ node.className.split(' ')[0].split('-')[1];
			if(node.className == elm.className)
			{
				node.addClassName('active');
				if( (tab = $(tabID)) )
					tab.style.display = 'block';
			}
			else
			{
				node.delClassName('active');
				if( (tab = $(tabID)) )
					tab.style.display = 'none';
			}
		}
		
	},
	
	climintelExpandGroup: function(elm)
	{
		var dataContainer = elm.nextSibling;
		while( dataContainer && dataContainer.className != 'data' )
			dataContainer = dataContainer.nextSibling;
		
		DOMElement.proto(elm);
		if( elm.className.indexOf('expanded') != -1 )
		{
			dataContainer.style.display = 'none';
			elm.delClassName('expanded');
		}
		else
		{
			dataContainer.style.display = 'block';
			elm.addClassName('expanded');
		}
	},
	
	climintelHeaderFlash: function(text)
	{
		document.write(
			'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="287" height="42" align="middle">'+
			'<param name="allowScriptAccess" value="sameDomain" />'+
			'<param name="allowFullScreen" value="false" />'+
			'<param name="movie" value="./flash/climintel_header.swf?headerInput='+text+'" />'+
			'<param name="menu" value="false" />'+
			'<param name="quality" value="high" />'+
			'<param name="wmode" value="window" />'+
			'<param name="bgcolor" value="#ffffff" />'+
			'<embed src="./flash/climintel_header.swf?headerInput='+text+'" menu="false" quality="high" wmode="window" bgcolor="#ffffff" width="287" height="42" name="header_flash" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
			'</object>'
		);
	},
	
	setStateSubmitForm: function(name, state)
	{
		if( !(form = document.forms[name]) ) return false;
		var btn = $('btn-submit-show');
		
		if(state)
		{
			form.parentNode.style.display = 'block';
			form.style.display = 'block';
			if(btn) btn.style.display = 'none';
			
			var inputList = getElementsByTagNameList(form, ['input', 'textarea']);
			for(var i=0, node ; node = inputList[i] ; i++)
			{
				switch(node.tagName.toLowerCase())
				{
					case 'input': if(node.type != 'hidden') node.value = ''; break;
					case 'textarea': node.value = ''; node.innerHTML = ''; break;
				}
			}
			
			var orangeBoxList = getElementsByClassName('orange-box', 'div', form.parentNode);
			for(var i=0, node ; node = orangeBoxList[i] ; i++)
			{
				if( (row = getElementsByClassName('row', 'div', node, true)) )
				{
					if( row.nodeType == 1 )
						node.parentNode.insertBefore(row, node);					
				}
				
				node.del();
			}
			
			var node = form.previousSibling;
			while(node)
			{
				if( node.nodeType == 1 && node.tagName == 'FORM' )
				{
					node.style.display = 'none';
					break;
				}
				node = node.previousSibling;
			}
		}
		else
		{
			form.style.display = 'none';
			form.parentNode.style.display = 'none';
			if(btn) btn.style.display = 'block';
		}
		
		return true;
	},
	
	boxFilter:
	{
		tmp:{},
		
		expandGroup: function(elmTitle, forceHide)
		{
			if( !isElement(elmTitle) ) return false;
			
			var group = elmTitle.parentNode;
			var groupContainer = group.parentNode;
			var node = groupContainer.firstChild;
			while( node )
			{
				if( node.nodeType && node.nodeType == 1 && node.className.indexOf('group') != -1 )
				{
					DOMElement.proto(node);
					if(node === group)
					{
						node.addClassName('g-active');
						var ch = node.firstChild;
						while( ch )
						{
							if(ch.nodeType == 1 && ch.className.indexOf('tablist') != -1)
							{
								var listDiv = ch.getElementsByTagName('div');
								for( var k=0, div ; div = listDiv.item(k) ; k++ )
									if(isElement(div))
									{
										var action = div.getAttribute('action');
										if(action)eval(action);
									}
							}
							ch = ch.nextSibling;
						}
					}
					else
					{
						node.delClassName('g-active');
						var ch = node.firstChild;
						var cont = false;
						while( ch )
						{
							if(ch.nodeType == 1 && ch.className.indexOf('tablist') != -1)
								cont = true;
							if( cont && ch.nodeType == 1 && ch.className == 'c' )
							{
								if(ch.style.display){ ch.style.display = 'none'; }
							}							
							ch = ch.nextSibling;
						}
					}
				}
				node = node.nextSibling;
			}
			
			return true;
		},
		
		changeTab: function(key)
		{
			var idTab 		= 'box-filter-tab-'+key;
			var idContent 	= 'box-filter-content-'+key;
			var content 	= null;
			var tab 		= null;
			if( (tab = $(idTab)) )
			{
				if( (content = $(idContent)) )
				{
					var tabContainer 		= tab.parentNode;
					var contentContainer 	= content.parentNode;
					if( isElement(tabContainer) && isElement(contentContainer) )
					{
						var node = tabContainer.firstChild;
						
						for(var i=0 ; node ; i++)
						{
							
							if( node.nodeType && node.nodeType == 1 && node.className.indexOf('item') != -1 )
							{
								var currKey = node.id.split('-').pop();								
								this.setTabState('box-filter-flash-tab-'+currKey, (node.id == idTab ? 'active' : 'inactive'));
							}
							node = node.nextSibling
						}
						
						var node = contentContainer.firstChild;
						for(var i=0 ; node = node.nextSibling ; i++)
						{
							if( node.nodeType != 1 ) continue;
							if( node.className != 'c' ) continue;
							node.style.display = (node.id == idContent ? 'block' : 'none');
						}
					}
				}
			}
		},
		
		writeTab: function(state, label, btnAction, name, wide, ea)
		{
			var param = new Array(
				'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
				'width', (wide ? 95 : 59),
				'height', '35',
				'src', './flash/tab'+(wide ? '.w' : '')+'?label='+label+'&amp;state='+state+'&amp;btn_action='+btnAction+'&amp;exec_action='+(ea ? '1' : '0'),
				'quality', 'high',
				'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
				'align', 'middle',
				'play', 'true',
				'loop', 'true',
				'scale', 'showall',
				'wmode', 'transparent',
				'devicefont', 'false',
				'id', name,
				'bgcolor', '#ECF0F9',
				'name', name,
				'menu', 'false',
				'allowFullScreen', 'false',
				'allowScriptAccess','always',					
				'salign', 'top',
				'returnString', (getBrowser().ie)
			);
			if( getBrowser().ie )
			{
				var uid = 'flashtabiebug'+Math.random();
				document.write('<div id="'+uid+'"></div>');
				addEvent(window, 'load', null, function()
				{
					if( (c = $(uid)) )
						c.innerHTML = AC_FL_RunContent.apply(null, param);					
				});
			}
			else
				AC_FL_RunContent.apply(null, param);			
		},
		
		setTabState: function(tabName, state)
		{
			if( (flashTab = document[tabName]) )
			{
				try
				{
					if( getBrowser().ie && isObject(flashTab) && !flashTab.setState )
						flashTab['setState'] = function(){this.CallFunction('<invoke name="setState" returntype="javascript">' +__flash__argumentsToXML(arguments, 0) +'</invoke>');};
					
					if(flashTab.setState)
						flashTab.setState(state);
				}
				catch(e){}
			}
		},
		
		
		onChangeSelect: function(select, url_prefix, url_posfix)
		{
			var val = select.value;
			
			if( (dispSelect = $('box-filter-select-'+val)) )
			{
				var listOption = select.getElementsByTagName('option');
				for(var i=0, node ; node = listOption.item(i) ; i++)
				{
					if( node.value && (currSelect = $('box-filter-select-'+node.value)) )
					{
						currSelect.style.display = (node.value == val ? 'block' : 'none');
						currSelect.value = '';
					}						
				}
			}
			else if(url_prefix)
			{
				window.location = _URL_ROOT+url_prefix+val+(url_posfix ? url_posfix : '');
			}
		}
	},
	
	checkSearchTextLength: function(input)
	{
		if( input && input.value.trim() )
		{
			if( input.value.trim().length < 3 )
				alert('Please enter minimum 3 characters!');
			else
				return true;
		}
		return false;
	},
	
	setStateSendToFriendForm: function(state)
	{
		if( !(form = document.forms['frmTellFriend']) ) return false;
		var container = getParentBy(form, 'className', 'tellafriend');
		
		if(state)
		{
			container.style.display = 'block';
			form.style.display = 'block';
			
			var inputList = getElementsByTagNameList(form, ['input', 'textarea']);
			for(var i=0, node ; node = inputList[i] ; i++)
			{
				switch(node.tagName.toLowerCase())
				{
					case 'input': if(node.type != 'hidden' && node.getAttribute('noreset') != 'yes') node.value = ''; break;
					case 'textarea': node.value = ''; node.innerHTML = ''; break;
				}
			}
			
			var orangeBoxList = getElementsByClassName('orange-box', 'div', form.parentNode);
			for(var i=0, node ; node = orangeBoxList[i] ; i++)
			{
				if( (row = getElementsByClassName('row', 'div', node, true)) )
				{
					if( row.nodeType == 1 )
						node.parentNode.insertBefore(row, node);					
				}
				
				node.del();
			}
			
			var node = form.previousSibling;
			while(node)
			{
				if( node.nodeType == 1 && node.tagName == 'B' )
				{
					node.style.display = 'none';
					break;
				}
				node = node.previousSibling;
			}
		}
		else
		{
			container.style.display = 'none';			
		}
		
		return true;
	},
	
	reportOffensiveComment: function(elmA, id_comment, name, id_reporter)
	{
		var boxText 			= 'Thank you for reporting this comment. Our editors are looking at it and will take the approriate action.';
		var container 			= create.div(null, null, 'offensive-box');
			container.top 		= create.img(null, './images/1x1.gif', 'top', null, container);
			container.oc 		= create.div(null, boxText, 'oc', null, container);
			container.bottom 	= create.img(null, './images/1x1.gif', 'bottom', null, container);		
		
		insertAfter(elmA.parentNode.parentNode, container, elmA.parentNode);
		
		elmA.parentNode.removeChild(elmA);
		this.ajax.request({cmd:'report_offensive_comment', id_comment:id_comment, name:name, id_reporter:id_reporter}, null, 'oc_'+id_comment);
	},
	
	writeTLSHeader: function(number, title)
	{
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', 307,
			'height', 76,
			'src', './flash/tls_header?title='+title+'&number='+number,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'tls_header'+number,
			'bgcolor', '#445868',
			'name', 'tls_header'+number,
			'menu', 'false',
			'allowFullScreen', 'false',
			'allowScriptAccess','always',					
			'salign', 'top'
		);		
	},
	
	writeCLHeader: function(label, wide)
	{
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', (wide ? 1002 : 596),
			'height', 52,
			'src', './flash/cl_header'+(wide ? '_wide' : '')+'?label='+label,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'cl_header'+label,
			'bgcolor', '#445868',
			'name', 'cl_header'+label,
			'menu', 'false',
			'allowFullScreen', 'false',
			'allowScriptAccess','always',					
			'salign', 'top'
		);		
	},
	
	writeGinvH: function(label)
	{
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', 959,
			'height', 50,
			'src', './flash/ginv_header?label='+label,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'cl_header'+label,
			'bgcolor', '#445868',
			'name', 'cl_header'+label,
			'menu', 'false',
			'allowFullScreen', 'false',
			'allowScriptAccess','always',					
			'salign', 'top'
		);		
	},
	
	linkCount:0,
	signupAddLink: function(name, url, error, removeLink)
	{
		var tbody = $('signup-links');
		var copy = $('copy-add-link');
		if( !tbody || !copy ) return false;
		if( this.linkCount == 5 ) return alert('Maximum 5 websites can be added by clicking the Add another link');
		
		var clone = copy.cloneNode(true);
		clone.removeAttribute('id');
		clone.style.display = '';
		
		if( removeLink )
		{
			var tdCol_2 = clone.getElementsByTagName('td').item(1),
				listInput = clone.getElementsByTagName('input'),
				remLink = document.createElement('a');
				remLink.innerHTML = 'remove';
				remLink.href = 'javascript:;';
				remLink.setAttribute('style', 'vertical-align:middle; margin-left: 15px;');
				remLink.onclick = function()
				{
					CCC.linkCount--;
					clone.parentNode.removeChild(clone);
					var listInput = tbody.getElementsByTagName('input'),
						c = 0, ci = 1;
					
					for(var i=2, node ; node = listInput.item(i) ; i++)
					{
						if( node.nodeType != 1 ) continue;
						if( ci % 2 == 0 )
							node.name = 'web_url_'+(c++);							
						else
							node.name = 'web_name_'+c;
						
						ci++;
					}
					
					if(listInput.length == 2)
						CCC.signupAddLink(null, null, null, true);
				};
			tdCol_2.appendChild(remLink);
			for(var i=0, node ; node = listInput.item(i) ; i++)
			{
				if( node.nodeType != 1 ) continue;
				node.style.width = '180px';
				node.style.marginRight = '5px';
			}
		}
		
		var listInput = clone.getElementsByTagName('input');
		for(var i=0, node ; node = listInput.item(i) ; i++)
		{
			if( name && node.name == 'web_name' )
				node.value = name;
			if( url && node.name == 'web_url' )
				node.value = url;
			if( error && node.name == 'web_url' )
				node.className += ' input-error';
			if( node.name != 'web[]' )
				node.name += '_'+this.linkCount;
			node.style.width = (removeLink ? 180 : 225)+'px';
		}
		
		tbody.appendChild(clone);
		this.linkCount++;
		
		return true;
	},
	
	changeToProfileTab: function(nodeA, idTabpanel)
	{
		if( !(tabpanel = $(idTabpanel)) ) return false;
		
		var tabList = nodeA.parentNode.getElementsByTagName('a');
		for(var i=0, node ; node = tabList.item(i) ; i++)
			node.className = (node === nodeA ? 'selected' : '');			
		
		var tabpanelList = tabpanel.parentNode.childNodes;
		for(var i=0, node ; node = tabpanelList[i] ; i++)
			if(node.nodeType == 1) node.style.display = (node.id == idTabpanel ? 'block' : 'none');
		
		return true;
	},
	
	modUser:
	{
		removePic: function(nodeA)
		{
			var table = getParentBy(nodeA, 'tagName', 'TABLE'),
				form = document.forms['formSignUp'];
			if( form.remove_pic )
				form.remove_pic.value = 'yes';
			if( isElement(table) )
				table.parentNode.removeChild(table);
		}
	},
	
	//getScrollTop
	enlargeImage: function(url_img, static_text)
	{
		var body = document.getElementsByTagName('body').item(0);		
		var doc = {
			width	: (body.offsetWidth == getScrollWidth()) ? body.offsetWidth : body.offsetWidth + getScrollWidth(),
			height	: body.offsetHeight
		};
		var win = {
			width	: getWindowWidth(),
			height	: getWindowHeight()
		};
		
		var scrollTop 			= getScrollTop();
		var scrollLeft 			= getScrollLeft();
		var bg 					= create.div('layer-bg', null, 'layer-bg', {width:doc.width+'px', height:doc.height+'px'}, body);
		var viewer 				= create.div('img-viewer', null, 'layer-img-viewer', {display:'none', width:'400px', height:'200px', left:(win.width/2-200)+scrollLeft+'px', top:(win.height/2-100)+scrollTop+'px', display:'block'}, body);	
			viewer.header 		= create.div(null, null, 'h', null, viewer);
			viewer.header.close	= create.img(null, './images/btn.close.jpg', 'close', null, viewer.header);
			viewer.header.close.onclick = function(){bg.parentNode.removeChild(bg);viewer.parentNode.removeChild(viewer);}
			if(static_text)
			{
				viewer.content			= create.div(null, null, 'content', null, viewer);
				viewer.content.text		= create.div(null, null, 'text', null, viewer.content);
				viewer.content.text.h1	= create.div(null, 'Program overview', 'h1', null, viewer.content.text);
				viewer.content.text.p	= create.div(null, static_text, 'p', null, viewer.content.text);
			}
		
		var img = document.createElement('img');		
			img.src = url_img+'?t='+Math.random();
			if(!static_text) img.style.margin = '0 20px 0 20px';
			img.onclick = viewer.header.close.onclick;
			img.title = 'Click to close';
			if(static_text) viewer.content.appendChild(img);
			if(static_text) viewer.setStyle({visibility:'hidden'});
			img.onload = function()
			{
				if(!static_text)
				{
					var add_w = 100,
						add_h = 100,
						style_w	= 40,
						style_h	= 61,
						w  = (win.width <= this.width + add_w) ? true : false,
						h  = (win.height <= this.height + add_h) ? true : false,
						nw = this.width,
						nh = this.height;
						
					if( w || h )
					{
						switch( true )
						{
							case w && !h:
								nw = Math.ceil(win.width - add_w);
								nh = Math.ceil(nh * ( nw / this.width ));
							break;
						
							case !w && h:
								nh = Math.ceil(win.height - add_h);
								nw = Math.ceil(nw * ( nh / this.height ));
							break;
						
							case w && h:
								nw = Math.ceil(win.width - add_w);
								nh = Math.ceil(this.height * ( nw / this.width ));
								
								if( win.height <= nh + add_h)
								{
									nh = Math.ceil(win.height - add_w);
									nw = Math.ceil(this.width * ( nh / this.height ));	
								}								
							break;
						}
					}			
					
					viewer.setStyle({
						width	: nw + style_w + 'px',
						height  : nh + style_h + 'px',
						left	: (win.width / 2 - (nw+style_w) / 2) + scrollLeft + 'px',
						top		: (win.height / 2 - (nh+style_h) / 2) + scrollTop + 'px'						
					});
					this.style.width 	= nw + 'px';
					this.style.height 	= nh + 'px';
					var img = this;
					setTimeout(function(){viewer.appendChild(img);viewer.setStyle({visibility:'visible'});}, 100);					
				}
				else
				{
					img = this;
					setTimeout(function(){						
						viewer.setStyle({visibility:'visible'});
						var style_w	= 100,
							style_h	= 41 + 25 + viewer.content.text.offsetHeight,
							nw = img.width,
							nh = img.height,
							left = (win.width / 2 - (nw+style_w) / 2) + 20 + scrollLeft,
							top = (win.height / 2 - (nh+style_h) / 2) + 20 + scrollTop;
							
							if( left < 20 + scrollLeft )
								left = 20 + scrollLeft;
							if(scrollLeft > 0 && left + nw + style_w > doc.width)
								left = doc.width - 20 - (nw + style_w);
							if( top < 20 + scrollTop )
								top = 20 + scrollTop;
							if( scrollTop > 0 && top + nh + style_h > doc.height )
								top = doc.height - 20 - (nh + style_h);
							
						viewer.setStyle({
							width	: nw + style_w + 'px',
							height  : nh + style_h + 'px',
							left	: left + 'px',
							top		: top + 'px'							
						});
					}, 100);
				}
			}
	},
	
	vs:
	{
		showWG: function(id, nodeA)
		{
			var node = nodeA.parentNode.firstChild;				
			while( node )
			{
				if( node.nodeType == 1 )
					node.className = (node === nodeA ? 'active' : '');
				node = node.nextSibling;
			}
			
			var node = nodeA.parentNode;			
			while( node )
			{
				if( node.nodeType == 1 && node.id && node.id.indexOf('workgroup-') === 0)
					node.style.display = (node.id == 'workgroup-'+id ? 'block' : 'none');
				node = node.nextSibling;
			}
			
		},
		
		reply: function(id_wgpost, with_qoute)
		{
			if( $('reply-clone') ) $('reply-clone').parentNode.removeChild($('reply-clone'));
			if( !(table = $('p-'+id_wgpost)) ) return false;
			if( !(reply = $('reply')) ) return false;
			
			var reply = reply.cloneNode(true);
				reply.setAttribute('id', 'reply-clone');
				reply.style.display = 'block';
			var listInput = reply.getElementsByTagName('input');
			for(var i=0, node ; node = listInput.item(i) ; i++)
			{
				if(node.name == 'id_parent')
					node.value = id_wgpost;
				/*if(node.name == 'redirect')
					node.value = node.value+id_wgpost;*/
				if(node.name == 'quote')
					node.value = with_qoute ? 'yes' : 'no';
				if(node.name == 'email')
					node.value = '';					
				if(node.name == 'pass')
					node.value = '';
			}
			
			if(with_qoute)
			{
				var TextArea = reply.getElementsByTagName('textarea').item(0),					
					text = getElementsByClassName('t', 'div', table);
					for(var i=0, n ; n = text[i] ; i++)
						if(n.className == 't'){ text = n.innerHTML; break; }
					text = text.replace(/<!--ctrl-box-->(.|\s)*?<!--\/ctrl-box-->/mig, '').replace(/<br>/mig, '');
				
				if(TextArea)
					TextArea.innerHTML = '&lt;quote&gt;'+text+'&lt;/quote&gt;'+'\n';
			}
			
			var formAction = reply.getElementsByTagName('form').item(0).action,
				parts = formAction.split('#');
				parts[1] = parts[1].split('_').shift();
			
			reply.getElementsByTagName('form').item(0).action = parts.join('#') + '_' + id_wgpost;
			
			insertAfter(table.parentNode, reply, table);
			
			return true;
		},
		
		report: function(id_wgpost, nodeA)
		{
			var box 	= $('offensive_comment_text').cloneNode(true),
				date 	= nodeA.parentNode.parentNode.getElementsByTagName('span').item(0),
				fb		= nodeA.parentNode.parentNode.getElementsByTagName('b').item(0),
				br		= document.createElement('br');
			
			box.removeAttribute('id');
			box.style.display = 'block';
			//insertAfter(date.parentNode, box, (fb && fb.className == "p" ? fb : date));
			insertAfter(date.parentNode, br, (fb && fb.className == "p" ? fb : date));
			date.parentNode.insertBefore(box, br);
			
			nodeA.previousSibling.parentNode.removeChild(nodeA.previousSibling);
			nodeA.parentNode.removeChild(nodeA);
			
			CCC.ajax.request({cmd:'report_offensive_post', id_wgpost:id_wgpost}, null, 'op_'+id_wgpost);
		}
	}
};

function nogo(){};

addEvent(document, 'mouseup', null, function()
{
	if(CCC.partnerTimer)
		clearInterval(CCC.partnerTimer);
	CCC.partnerTimer = null;
});