


/*
function cost_submit(){
	document.getElementById('cost_list').innerHTML = '<img src="'+image_url+'/images/loading.gif"/>';
	document.getElementById('cost_submit_button').disabled = true;
	var country = document.FORMCOST.country.value;
	var number = document.FORMCOST.number.value;
	var shipping_project_id = document.FORMCOST.shipping_project_id.value;
	var pack_weight = document.FORMCOST.pack_weight.value;
	var goods_weight = document.FORMCOST.goods_weight.value;
	calculate_request(country,number,shipping_project_id,pack_weight,goods_weight);
	return false;
}
*/
/*function calculate_request(country,goods_number,shipping_project_id,pack_weight,goods_weight){
	var arg = 'shipping_project_id=' + shipping_project_id
			 +'&seller_id=' + seller_id
			 +'&country=' + country
			 +'&pack_weight=' + pack_weight
			 +'&goods_number=' + goods_number	
			 +'&goods_weight=' + goods_weight;

		$.ajax({
		type: "POST",
		url: "/transport.php",
		data: "act=shipping_cost"+"&"+arg,
		success: function(result){
			var obj;	
			eval("obj="+result);
			calculate_response(obj);

		}
	});
	
}
*/

/*function calculate_response(result){
	
	var str = '<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#d0d0d0" class="table04" ><tr><td bgcolor="#f4f4f4" class="td06">Carrier</td><td bgcolor="#f4f4f4" class="td06">EstimatedTransit Time</td><td bgcolor="#f4f4f4" class="td06">Shipping Cost</td></tr>';
	if(result.content.length == 0){ 
	}else{
		for(var i = 0 ; i < result.content.length; i++){
			var v = result.content[i];
					
			str += '<tr><td bgcolor="#FFFFFF"><a href="'+v.url+'" target="_blank">'+v.shipping_name+'</a></td><td bgcolor="#FFFFFF">'+v.transit_time+'</td><td bgcolor="#FFFFFF" class="red">'+v.shipping_format_price+'</td></tr>';
		}
	}
	str +='</table><b class="orange">Note:</b> <span class="ash">Credit card or PayPal cannot be used as a payment method for shipping methods other than DHL, UPS, TNT and EMS</span>';
	document.getElementById('cost_list').innerHTML = str;
	document.getElementById('cost_submit_button').disabled = false;
}
*/

	





$(function() {
       $('#gallery a').lightBox();
 });

function showbigimage(){
	var indexvalue=$("#a_big_img").attr("title");
	
	var id = '#gallery_sub_a'+indexvalue;
	$(id).click();

	
}

 function show_image(obj)
 {

	var s_img=obj.src;
	
	var b_src=$("#"+obj).attr("alt");
	var num=$("#"+obj).attr("title");

	$('#gallery img').attr("class",'pic01');
	$("#"+obj).addClass('pic02');
		
	
	$("#a_big_img").attr("title",num);



	$("#big_img").attr("src",b_src);


 }

/* function show_country()
 {
	$("#country_list").fadeIn(200); 
	$("#spec").hide(); 
 }

function hide_country()
 {
	$("#country_list").fadeOut(200); 
	$("select").show(); 
 }
	*/
/* function show_star()
 {
	$("#star_list").fadeIn(200); 
 }

*/

//
//function hide_star(e,o) { 
//        /* FF 下判断鼠标是否离�?DIV */
//        if(window.navigator.userAgent.indexOf("Firefox")>=1) { 
//            var x = e.clientX + document.body.scrollLeft;
//            var y = e.clientY + document.body.scrollTop ;
//            var left = o.offsetLeft;
//            var top = o.offsetTop;
//            var w = o.offsetWidth;
//            var h = o.offsetHeight;
//            
//            if(y < top || y > (h + top) || x > left + w || x<left ) { 
//               $("#star_list").fadeOut(200); 
//            }
//        }
//        /* IE */
//		else if(o.contains(event.toElement ) == false)
//		{
//			$("#star_list").fadeOut(200);
//		}
//        
//    }

/*function collect_category(cat_id , cat_name){
	
	var arg = 'cat_id=' + cat_id
			 +'&cat_name=' + cat_name;
	$.ajax({
		type: "POST",
		url: "/transport.php",
		data: "act=collect_category&"+arg,
		success: function(result){
			var obj;	
			eval("obj="+result);
			if(obj.valid == 0){
			//alert('Your don\'t have login.');
			var url = document.URL;
			location.href = 'http://www.tradetang.com/sign.php?act=login&return_url='+url;
			}else if(obj.valid == 1){
				//write_log(46);
				alert('Add to my favorite category success');
			}else if(obj.valid == 2){
				alert('Sorry, the same category has existed in your favorite list');
			}
		}
	});

}*/

/*function addToCart(goodsId,sellerId,foo)
{
  if(foo==undefined)foo=false;
  var goods        = new Object();
  var spec = "";
  //var fittings_arr = new Array();
  var number = 1;
  var formBuy      = document.forms['FORMBUY'];
  


  // �?查是否有商品规格
  if (formBuy)
  {
    if(formBuy.elements['spec']){
		spec = formBuy.elements['spec'].value;
	}
	

    if (formBuy.elements['number'])
    {
      number = formBuy.elements['number'].value;

	  if(number < min_quantity){
		  alert('Quantity error');
		  return;
	  }
    }
  }
  
  goods.spec     = spec;
  goods.goods_id = goodsId;
  goods.number   = number;
  goods.seller_id = sellerId;
  goods.is_bind = 0;

  spec = spec.replace(/\+/g, "%2B");   
  spec = spec.replace(/\&/g, "%26");   

  	var arg = 'spec=' + spec
			 +'&goods_id=' + goodsId
			 +'&number=' + number
			 +'&seller_id=' + sellerId
			 +'&is_bind=' + 0;
			 
	 


	$.ajax({
		type: "GET",
		url: "/flow.php",
		data: 'step=add_to_cart_new&'+arg,
		success: function(message,error,goods_id){	
				
				  var cart_count = document.getElementById('cart_count');
					if(message=="Sorry, the same product has existed in your cart.1"){
						alert(message);
						foo.innerHTML = 'Added To Cart';
						getCartNumber();
					}else{
						getCartNumber();
						$("select").hide(); 
					
							$.floatboxx({
					
								ajax: {
									  url: "/flow.php?step=goods_format_amount&"+arg,
									  cache: false
								},
					
							fade: true
							});
					}			
			}
		});


}


function getCartNumber(){
	Ajax.call('/transport.php?act=cart_number', '', getCartNumberResponse, 'GET', 'JSON');
}


function getCartNumberResponse(result){
	
	document.getElementById('cart_count').innerHTML = result.content;
}

function collect_goods(goods_name,goods_sn,goods_id,seller_id,seller_name,goods_img,goods_price){
	var arg = 'goods_name=' + goods_name
			 +'&goods_sn=' + goods_sn
			 +'&goods_id=' + goods_id
			 +'&seller_id=' + seller_id
			 +'&seller_name=' + seller_name
			 +'&goods_img=' + goods_img
			 +'&goods_price=' + goods_price;	


	$.ajax({
		type: "POST",
		url: "/transport.php",
		data:"act=collect_goods&"+arg,
		success: function(result){	
				var obj;	
					eval("obj="+result);
				collect_goods_response(obj);

				}
		});
}

function collect_goods_response(result){
	if(result.valid == 0){
		var url = document.URL;
		location.href = 'http://www.tradetang.com/sign.php?act=login&return_url='+url;
	}else if(result.valid == 1){
		//write_log(44);
		alert('Add to my favorite product success');
	}else if(result.valid == 2){
		alert('Sorry, the same product has existed in your favorite list');
	}
}

function collect_seller(seller_id, seller_name){
	var arg = 'seller_id=' + seller_id
			 +'&seller_name=' + seller_name;

		$.ajax({
		type: "POST",
		url: "/transport.php",
		data:"act=collect_seller&"+arg,
		success: function(result){	
				var obj;	
					eval("obj="+result);
				collect_seller_response(obj);

				}
		});
}

function collect_seller_response(result){
	if(result.valid == 0){
		var url = document.URL;
		location.href = 'http://www.tradetang.com/sign.php?act=login&return_url='+url;
	}else if(result.valid == 1){
		//write_log(45);
		alert('Add to my favorite seller success');
	}else if(result.valid == 2){
		alert('Sorry, the same seller has existed in your favorite list');
	}
}

function getjson(url,method){  
	jQuery(function($) {  
			$.getJSON(url,  
			function(data){  
					eval(method);  
					});   
		}); 
 }  


function check_is_login(return_fun,arg){


	
		$.ajax({
		type: "GET",
		url: "/transport.php?act=is_login",
		success: function(return_fun,arg){	
			 
				
				var obj = $.evalJSON(return_fun);
				check_is_login_response(obj,return_fun,arg)
				}
		});



}




function send_message(goods_name,goods_sn,goods_id,seller_id,cat_id){
	check_is_login(send_message_popup,arguments);

}

function check_is_login_response(result,return_fun,arg){
		
	if(result.valid == 1){
		send_message_popup(result);	
	}else{
		login_popup_request();	
	}
}


function send_message_popup(arg){
	
	
	var goods_id = $("#goods_id").val();
	var seller_id = $("#seller_id").val();
	
	var arg = 'goods_id='+goods_id
			 +'&seller_id='+seller_id;



	$("select").hide(); 

		$.floatbox({

			ajax: {
				  url: "/popup.php?act=send_message_new&"+arg,
				  cache: false
				},

			fade: true
		});
}

//////////////////////////////////////////////////////////6-28
function login_popup_request(arg){
	var return_url = '';
	
		
	var goods_id = $("#goods_id").val();
	var seller_id = $("#seller_id").val();
		
		return_url = '/popup.php?act=send_message_new&goods_id='+goods_id
				 +'&seller_id='+seller_id;
		return_url = encodeURIComponent(return_url);
			 


	$("select").hide(); 

		$.floatbox({

			ajax: {
				  url: "/popup.php?act=login_new&return_url="+return_url,
				  cache: false
				},

			fade: true
		});
	
	
}




function send_message_request(f){
	var formmsg = f;
	var goods_id = formmsg.goods_id.value;
	var seller_id = formmsg.seller_id.value;
	var comment = formmsg.comment.value;
	if(comment == ""){
		alert('please enter comment');	
		return false;
	}	
	if(!checkMsg(comment,'content error')){
		return false;
	}
	var arg = 'goods_id='+goods_id
			 +'&seller_id='+seller_id
			 +'&comment='+comment;


	
		$.ajax({
		type: "POST",
		url: "/transport.php",
		data: "act=send_message&"+arg,
		success: function(result){	
				var obj = $.evalJSON(result);
				send_message_response(obj)
				}
		});


	document.getElementById('popup_content').innerHTML = '<ul><li class="l32"><img src="'+image_url+'/images/loading.gif"/></li></ul>';
	
	
	return false;
}

function send_message_response(result){
	if(result.valid == 0){
		login_popup_request();
		
	}else if(result.valid == 1){
		//write_log(23);
		if(document.FORMMSG)document.FORMMSG.comment.value='';
		document.getElementById('popup_content').innerHTML = '<ul><li class="l32"><img src="'+image_url+'/images/text.gif" />Note: Message sent successfully.<br/></li></ul>';
	}
	
}*/

//Json
//jQuery.extend(
// {
//  /**
//   * @see  将json字符串转换为对象
//   * @param   json字符�?
//   * @return 返回object,array,string等对�?
//   */
//  evalJSON : function (strJson)
//  {
//   return eval( "(" + strJson + ")");
//  }
// });
// jQuery.extend(
// {
//  /**
//   * @see  将javascript数据类型转换为json字符�?
//   * @param 待转换对�?,支持object,array,string,function,number,boolean,regexp
//   * @return 返回json字符�?
//   */
//  toJSON : function (object)
//  {
//   var type = typeof object;
//   if ('object' == type)
//   {
//    if (Array == object.constructor)
//     type = 'array';
//    else if (RegExp == object.constructor)
//     type = 'regexp';
//    else
//     type = 'object';
//   }
//      switch(type)
//   {
//         case 'undefined':
//       case 'unknown':
//     return;
//     break;
//    case 'function':
//       case 'boolean':
//    case 'regexp':
//     return object.toString();
//     break;
//    case 'number':
//     return isFinite(object) ? object.toString() : 'null';
//       break;
//    case 'string':
//     return '"' + object.replace(/(\\|\")/g,"\\$1").replace(/\n|\r|\t/g,
//       function(){  
//                 var a = arguments[0];                   
//        return  (a == '\n') ? '\\n':  
//                       (a == '\r') ? '\\r':  
//                       (a == '\t') ? '\\t': "" 
//             }) + '"';
//     break;
//    case 'object':
//     if (object === null) return 'null';
//        var results = [];
//        for (var property in object) {
//          var value = jQuery.toJSON(object[property]);
//          if (value !== undefined)
//            results.push(jQuery.toJSON(property) + ':' + value);
//        }
//        return '{' + results.join(',') + '}';
//     break;
//    case 'array':
//     var results = [];
//        for(var i = 0; i < object.length; i++)
//     {
//      var value = jQuery.toJSON(object[i]);
//           if (value !== undefined) results.push(value);
//     }
//        return '[' + results.join(',') + ']';
//     break;
//      }
//  }
// });
//
//
// function isLogin(return_fun){
//	if(!return_fun)return_fun=isLoginResponse;
//	if(location.search){
//		
//		if(!document.getCookie('PSESSION')){
//			var arg = location.search.substring(1);
//			
//			var arg_array = arg.split("&");
//			
//			for(var i = 0 ; i < arg_array.length; i++){
//				var psession_array = arg_array[i].split("=");
//				var name = psession_array[0];
//				var value = psession_array[1];
//				if(name=="PSESSION"){
//					Ajax.call('/transport.php?act=valid_area', '', '', 'POST', 'JSON');
//				}
//			}
//			
//			
//		}
//			
//	}
//	
//	if(!document.getCookie('PSESSION')){
//		if(document.getCookie('login_name')){
//			var email = document.getCookie('login_name');
//			Ajax.call('/valid_user.php', 'email='+email, '', 'POST', 'JSON');
//		}
//	}
//	
//	if(!document.getCookie('PSESSION')){
//		Ajax.call('/transport.php?act=valid_country', '', '', 'POST', 'JSON');
//	}	
//	
//	Ajax.call('/transport.php?act=is_login', '', return_fun, 'GET', 'JSON');
//}
//
//var department = 1;
//var marqueeContent=new Array();
//var marqueeInterval=new Array();
//var marqueeId=0;
//var marqueeDelay=3000;
//var marqueeHeight=19;
//
//function isLoginResponse(result){
//	if(result.valid == 1){
//		/*已登�?*/	
//		if(document.getElementById('welcome_info')){
//			document.getElementById('welcome_info').innerHTML = 'Hi '+ result.user_name + '&nbsp;  <a href="/sign.php?act=logout" class="orange u">logout</a>&nbsp;&nbsp;';
//		}
//		if(result.is_vip == 1){
//			if(document.getElementById("livehelp")){
//				Ajax.call("/search/service/csc/grouponline.jsp?g=vipservice","", livehelp_response, "GET", "TEXT");
//			}
//		}
//	}
//}