﻿$(function () {
	$('.closebox').click(function () {
		/* alert(jQuery.browser.version);*/
		$('.boxcontent',$(($(this).parent()).parent())).css({display:"block"});
		$('.openbox',$(this).parent()).css({display:""});
		$(this).css({display:"none"});
		$('.boxcontent',$(($(this).parent()).parent())).toggle('slow');
		$($($(this).parent()).parent()).attr('class','');
	});
	$('.openbox').click(function () {
		$('.boxcontent',$(($(this).parent()).parent())).css({display:"none"});
		$(this).css({display:"none"});
		$('.closebox',$(this).parent()).css({display:""});
		//Add by timmy @ 2009/11/13 for count
		var ids="";
		$('.boxcontent',$(($(this).parent()).parent())).each(function () {
			ids+=this.id+',';
		});
		ids=ids.substring(0,ids.length-1);
		count(ids);
		//Add by timmy @ 2009/11/13 for count
		$('.boxcontent',$(($(this).parent()).parent())).toggle('slow');
		if($($($($($(this).parent()).parent()).parent()).parent()).attr('id')=='links'||$($($($($(this).parent()).parent()).parent()).parent()).attr('id')=='comparison')
		{
			$($($(this).parent()).parent()).attr('class','now');
		}
		else
		{
			$($($(this).parent()).parent()).attr('class','scroll');
		}
	});
	//for /product/comparison.asp
	//show even/odd lines
	$('ul.compare-product:eq(0) li:gt(1):odd').css("background","#efece6");
	$('ul.compare-product:eq(0) li:gt(1):even').css("background","#e5e2da");
	$('ul.compare-product:eq(1) li:gt(1):odd').css("background","#efece6");
	$('ul.compare-product:eq(1) li:gt(1):even').css("background","#e5e2da");
	$('ul.compare-product:eq(2) li:gt(1):odd').css("background","#efece6");
	$('ul.compare-product:eq(2) li:gt(1):even').css("background","#e5e2da");
	//init height
	var atscccc=jQuery.makeArray($('ul.compare-product:first li'));
	var liClassName=new Array();
	for(var i=0;i<atscccc.length;i++)
	{
		var eKey=$(atscccc[i]).attr('class');
		var eValue=$(atscccc[i]).css('height');
		liClassName[eKey]=eValue;
	}
	//init open status
	$('.compare-list span').click(function () {
		var liid=$($(this).parent()).attr('class');
		//alert(liid);
		if($(this).attr('class').toLowerCase()=='open')
		{
			$('ul.compare-product li.'+liid).css('height',liClassName[liid]);
			//alert(liClassName[liid]);
			$('ul.compare-product-btn li.'+liid).css('height',liClassName[liid]);
			$('.compare-product .'+liid+' .speci-content').css('display','');
			$(this).attr('class','close');
			$(this).html('close');
			//show even/odd lines
			$('ul.compare-product:eq(0) li:gt(1):odd').css("background","#efece6");
			$('ul.compare-product:eq(0) li:gt(1):even').css("background","#e5e2da");
			$('ul.compare-product:eq(1) li:gt(1):odd').css("background","#efece6");
			$('ul.compare-product:eq(1) li:gt(1):even').css("background","#e5e2da");
			$('ul.compare-product:eq(2) li:gt(1):odd').css("background","#efece6");
			$('ul.compare-product:eq(2) li:gt(1):even').css("background","#e5e2da");
		}
		else
		{
			$('ul.compare-product .'+liid).attr('style','');
			$('ul.compare-product-btn li.'+liid).attr('style','');
			$('.compare-product .'+liid+' .speci-content').css('display','none');
			$(this).attr('class','open');
			$(this).html('open');
			//show even/odd lines
			$('ul.compare-product:eq(0) li:gt(1):odd').css("background","#efece6");
			$('ul.compare-product:eq(0) li:gt(1):even').css("background","#e5e2da");
			$('ul.compare-product:eq(1) li:gt(1):odd').css("background","#efece6");
			$('ul.compare-product:eq(1) li:gt(1):even').css("background","#e5e2da");
			$('ul.compare-product:eq(2) li:gt(1):odd').css("background","#efece6");
			$('ul.compare-product:eq(2) li:gt(1):even').css("background","#e5e2da");
		}
	});
})
//expand-all
$(function () {
	$('.expand-btn').click(function () {
		var w_url=window.location.toString ();
		$(this).css({display:"none"});
		$('.contract-btn').css({display:""});
		//Add by timmy @ 2009/11/13 for count
		var ids="";
		$('.boxcontent').each(function () {
			ids+=this.id+',';
		});
		ids=ids.substring(0,ids.length-1);
		count(ids);
		//Add by timmy @ 2009/11/13 for count
		var t_url="pageid=663";
		if(w_url.indexOf(t_url)>0)
		{
			$('.about-container .boxcontent').slideDown();
		}
		else
		{
			$('.boxcontent').slideDown();
		}
		$('.openbox').css({display:"none"});
		$('.closebox').css({display:""});
	});
});
//contract-all
$(function () {
	$('.contract-btn').click(function () {
		var w_url=window.location.toString ();
		$(this).css({display:"none"
		});
		$('.expand-btn').css({display:""});
		var t_url="pageid=663";
		if(w_url.indexOf(t_url)>0)
		{
			$('.about-container .boxcontent').slideUp();
		}
		else
		{
			$('.boxcontent').slideUp();
		}
		$('.openbox').css({display:""});
		$('.closebox').css({display:"none"});
		//add by HI1/timmy wang @ 2009/11/11
		if(w_url.indexOf(t_url)>0)
		{
			$('.about-container .boxcontent').css({display:"none"});
		}
		else
		{
			$('.boxcontent').css({display:"none"});
		}
		//add by HI1/timmy wang @ 2009/11/11 end
	});
});
function count(id) {
	$.get("/modules/article_count.cfm?r="+Math.random()+"&id="+id);
}

