function accordion(nav,content,on,type){
	$(nav).bind(type, function(){
		var $cur = $(this);	
		$(nav).removeClass(on);
		$(content).hide();
		$cur.addClass(on);
		$cur.next(content).fadeIn();
	})
}

function switchIndex(nav,content,on,index){
		var $tab=$(nav).children().eq(index);
		var $content = $(content).children();
		$(nav).children().removeClass(on);
		$(nav).children().removeClass("next");
		$tab.addClass(on);
		$tab.next().addClass("next");
		$content.hide();
		$content.eq(index).show();
		$('html,body').animate({
			scrollTop:700
		},1000);
}


function menu(nav){	
	$('li:has(> div)',nav).addClass('parent');
	$("li.parent",nav).hover(function(){
		$(this).addClass('on'); $('> a', this).addClass('hover'); 
		$(this).children("div").stop(true,true).show();
	}, function(){
		$(this).children("div").stop(true,true).hide();
		$(this).removeClass('on'); $('> a', this).removeClass('hover'); 
	});
}

function menu2(nav){	
	$('li:has(> ul)',nav).addClass('parent');
	$("li.parent",nav).hover(function(){
		$(this).addClass('on'); $('> a', this).addClass('hover'); 
		$(this).children("ul").stop(true,true).slideDown();
	}, function(){
		$(this).children("ul").stop(true,true).slideUp();
		$(this).removeClass('on'); $('> a', this).removeClass('hover'); 
	});
}


function tab(nav,content,on,type)
{
	$(nav).children().bind(type,(function(){
		var $tab=$(this);
		var tab_index=$tab.prevAll().length;
		var $content = $(content).children();
		$(nav).children().removeClass(on);
		$(nav).children().removeClass("next");
		$tab.addClass(on);
		$tab.next().addClass("next");
		$content.hide();
		$content.eq(tab_index).show();
		//$content.eq(tab_index).fadeIn();
	}));
}




function inputSelect(){
var g_DefaultText=[];
var g_DefaultTextColor=[];
var g_NormalTextColor=[];
var g_o_num=0; 

function setDefaultText(oInputElement, sDefaultText, sDefaultTextColor, sNormalTextColor)
{
	//save information in array
	g_DefaultText.push(sDefaultText);
	g_DefaultTextColor.push(sDefaultTextColor);
	g_NormalTextColor.push(sNormalTextColor);
	
	//set tip
	oInputElement.value=sDefaultText;
	oInputElement.style.color=sDefaultTextColor;
	
	//set switch
	oInputElement.isDefault=true;  
	oInputElement.index=g_o_num++;
	
	//add event
	oInputElement.onfocus=input_onFocus;
	oInputElement.onblur=input_onBlur;
}

function setText(oInputElement, text)
{
	oInputElement.isDefault=false;
	oInputElement.value=text;
	oInputElement.style.color=g_NormalTextColor[oInputElement.index];
}

function input_onFocus(event)
{
	if(this.isDefault)
	{
		this.value='';
		this.style.color=g_NormalTextColor[this.index];
	}
}

/* Select */
function input_onBlur(event)
{
	if(this.value.length)
	{
		this.isDefault=false;
	}
	else
	{
		this.isDefault=true;
		this.value=g_DefaultText[this.index];
		this.style.color=g_DefaultTextColor[this.index];
	}
}

$$=function(id)
{
   return "string" == typeof id ? document.getElementById(id) : id;   
}

window.onload=function ()
{
	var oInputKeyword=$$('keywordinput');
	setDefaultText(oInputKeyword, 'Enter your keywords', '#9D9D9D', '#000');
	var oInputEmail=$$('emailInput');
	setDefaultText(oInputEmail, 'Enter Email Address', '#9D9D9D', '#000');
}
}


$(function(){
inputSelect();
tab("#tab1_nav ul","#tab1_con","on","mouseover");
tab("#tab3-nav ul","#tab3-con","on","mouseover");
tab("#tab2-nav ul","#tab2-con","on","mouseover");


$("#feedback_btn").toggle(
function(){$(".feedback").animate({left:"0"});
$(this).addClass("on"); },
function(){$(".feedback").animate({left:"-215px"});
$(this).removeClass("on");
})

$("#fb_comment").click(function(){ $(this).animate({height:"120px"},300)});
$("#fb_comment2").click(function(){ $(this).animate({height:"120px"},300)});

$("#feedback").validate(
$.extend(formSettings,{
    rules: {
        name:"required",
        email:{required: true,email: true},
        subject: "required",
        message: "required"
    }}))
    
})

function rate(obj,oEvent){
    var imgSrc = '/images/starblank.gif'; //blank-star
    var imgSrc_2 = '/images/starfull.gif'; //full-star
    var e = oEvent || window.event;
    var target = e.target || e.srcElement;
    var imgArray = obj.getElementsByTagName("img");
    for(var i=0;i<imgArray.length;i++){
        imgArray[i]._num = i;
        imgArray[i].onclick=function(){
            obj.rateFlag=true;
            $("#grade").attr('value',this._num+1);
            //	alert(this._num+1);       //this._num+1 Write to the database this figure as the basis of score
            if(target.tagName=="IMG"){
                for(var j=0;j<imgArray.length;j++){
                    if(j<=target._num){
                        imgArray[j].src=imgSrc_2;
                    } else {
                        imgArray[j].src=imgSrc;
                    }
                }
            } else {
                for(var k=0;k<imgArray.length;k++){
                    imgArray[k].src=imgSrc;
                }
            }
        };
    }
    if(obj.rateFlag) return;

    if(target.tagName=="IMG"){
        for(var j=0;j<imgArray.length;j++){
            if(j<=target._num){
                imgArray[j].src=imgSrc_2;
            } else {
                imgArray[j].src=imgSrc;
            }
        }
    } else {
        for(var k=0;k<imgArray.length;k++){
            imgArray[k].src=imgSrc;
        }
    }
    return false;
}
function disable_add2cart(yes){}



