function smartweb_share(type){
    if (type == 'facebook'){
        window.open('http://www.facebook.com/share.php?u='.concat(encodeURIComponent(location.href)).concat('').concat('&#38;t=').concat(encodeURIComponent(document.title)));
    }
    if (type == 'plurk'){
        window.open('http://www.plurk.com/?qualifier=shares&status='.concat(encodeURIComponent(location.href)).concat(' ').concat('(').concat(encodeURIComponent(document.title)).concat(')'));
    }
    if (type == 'twitter'){
        window.open('http://twitter.com/home/?status='.concat(encodeURIComponent(document.title)).concat(' ').concat(encodeURIComponent(location.href))); 
    }

    if (type == 'bookmark'){
        title = document.title;
        url = document.location;
        if (window.sidebar) {window.sidebar.addPanel(title, url,"");}
        else if(window.external ) {window.external.AddFavorite( url, title);}
        else if(window.opera && window.print) {return true;}
    }
}


function showMyCart(text){
        $('#show_my_cart').hide();
//        $('#show_my_cart').html(text).slideDown('slow');
        $('#show_my_cart').html(text).fadeTo('fast',1);

  //      $('#my_cart_sep').show();

}


function updateMyCart(data){
    if (data.url != undefined && data.url != null){
        alert(data.msg);
        window.location=data.url;
        return false;
    }
    if (data.out != undefined && data.out != null){
       $('#show_my_cart').show();
       $('#show_my_cart').css('background-color','red');
       $('#show_my_cart').css('color','white');
       $('#show_my_cart').html('購物車更新中....');
       if (data.msg != undefined && data.msg != null){
            alert(data.msg);
       }
       setTimeout(function(){ $('#show_my_cart').hide();$('#show_my_cart').css('background-color','#FFFFFF'); },500);
       setTimeout(function(){ showMyCart(data.out);},800);
    }else if (data.msg != undefined && data.msg != null){
        alert(data.msg);
    }
}

function getTown(value,id){
    if (id != null){
        var town_id = id;
    }else{
        var town_id = 'town';
    }

	$.getJSON(WEBURL+'/getTown.php',
	{county:value},
	function(data){
		updateSelectList(data,town_id);
	}
	);
}

function updateSelectList(obj,elementid){
	el = document.getElementById(elementid);
	len = el.options.length;
	if (len > 2){
		for(i=(len-1);i>0;i--){
			if (i!=0){
				el.options[i] = null;
			}
		}
	}
	var i = 1;
	jQuery.each(obj.name, function(index,name){
		el.options[i] = new Option(name,obj.id[index]);
		i++;
	}
	);
}

