//{literal}
/* <![CDATA[ */
$(document).ready(function() {
BlogProduct.LoadSwitch(showtype);
})
/**
*描述：复制到粘贴板
*/
var BlogProduct={"CopytoClip":function(data)
				{	
					try{
						window.clipboardData.setData("Text",data);
						alert("地址已复制到粘贴板中!");
					}catch(e)
					{
						alert("未复制成功");
					}
					
				},
				"saveFavoriteMsg":function(data)/***描述：添加到收藏*/
				{
					if(confirm("确定要收藏吗？"))
					{
						var url=phpbase+"/threads/AddFavorite";
						$.ajax({
							 type: "POST",
							 url: url,
							 data:  "ThreadID="+ThreadID+"&type="+type,
							 success: function(msg){
										 alert(msg);
										 //$("#Reviewscontent").val();
								 } 
							});
					}

				},
				"Favoritemark":function(title,url)
				{
					var title=title;
					var url=url;
					if (window.sidebar) window.sidebar.addPanel(title, url,"");
					else if( window.opera && window.print ){
					var mbm = document.createElement('a');
					mbm.setAttribute('rel','sidebar');
					mbm.setAttribute('href',url);
					mbm.setAttribute('title',title);
					mbm.click();}
					else if( document.all ) window.external.AddFavorite( url, title);
				},
				"Productlist":function(page)
				{
					if (page==null||page==0) page=1;
					var url=phpbase+"/blog/productlist";
					var strhtml='';
					var strhtmlsub='';
					var i=0;
					var sUID=UID;
					var sMID=MID;
					var sTypeid='';
					$.ajax({
						type: "POST",
			 			url: url,
			 			data: "page="+page+"&uid="+sUID+"&mid="+sMID+"&typeid="+Typeid,
					    success: function(msg){
						 if(msg==-1)
							{
							$("#ProductManMorePage").hide();
						     return;
							}
												var ob;
												var ob0;
												var imgurl;
												var Extend;
												var Name="";
												var imgurl;
												var tdi=0;
												var Info;
												var rmbchar='￥';
												try{eval("ob=" +msg);} catch(e){}
												if(ob){
													pageinfo=ob['pageinfo'];
													contents=ob['contents'];
													page=ob['pageinfo']['pagenow'];	
										for(counter=contents.length;i<counter;i++)//分解JSON数据
											{
		if (tdi>3) 
			tdi=1;
		else
			tdi++;
		if(contents[i].imageurl!=-1)
			imgurl=contents[i].imageurl;
		else
			imgurl='/images/temp_ad_logo_5.jpg';
		if(contents[i].Extend!="")	
		{
			Extend=contents[i].Extend;
			if(Extend=='面议' || Extend=='免费') 
				rmbchar='';
			else
				rmbchar='￥'
		}
		else
			Extend='暂无标价';
		if(contents[i].Info!=null)	
			Info=contents[i].Info;
		else
			Info='';	
        strhtml=strhtml+'<div class="PD_info PD_i_'+tdi+'">';
        strhtml=strhtml+'<table width="150" border="0" cellpadding="0" cellspacing="2" class="f12 list_h18">';
        strhtml=strhtml+'<tr><td align="center" bgcolor="#FFF3EC"><table border="0" align="center" cellpadding="0" cellspacing="5">';
		strhtml=strhtml+'<tr><td width="130" height="100" align="center" valign="middle" bgcolor="#FF9900">';
		strhtml=strhtml+'<a href="'+phpbase+'/product/content/'+sUID+'/'+sMID+'/'+contents[i].ID+'" target="_self">';
		strhtml=strhtml+'<img src="/blog/getResizedImage.php'+imgurl+'?120*90" width="120" height="90" class="CPointer"/></a></td>';
		strhtml=strhtml+'</tr><tr><td align="center"><span class="color_7 bf CPointer" >';
		strhtml=strhtml+'<a href="'+phpbase+'/product/content/'+sUID+'/'+sMID+'/'+contents[i].ID+'" title="'+contents[i].Titles+'" target="_self"><font color="#e34f00">'+contents[i].Title+'</font></a>';
		strhtml=strhtml+'</span></td></tr></table></td></tr><tr><td><span class=" color_3 bf">价格：</span><font color="#0000FF" class="bf">'+rmbchar+'</font><font color="#0000FF">'+Extend+'</font></td>';
		strhtml=strhtml+'</tr><tr><td><span class=" color_3 bf">说明：</span><br />';
		strhtml=strhtml+'<span class="color_3">'+Info+'</span> </td>';
		strhtml=strhtml+'</tr></table></div>';
											}
													//alert(strhtml);
													pagecount=ob['pageinfo']['pagecount'];
													$("#ProductmantotalPage").text('共'+pagecount+'页');

													if(page>1) $("#ProductListPage").html(strhtml);//把数据加载到页0页
													//$("#YPMore").focus();
													$("#Productmanupdataup").unbind();
													$("#Productmannextdataup").unbind();
													$("#Productmanupdataup").bind("click", function() {BlogProduct.Productlist(parseInt(page)-1)});
													$("#Productmannextdataup").bind("click", function() {BlogProduct.Productlist(parseInt(page)+1)});
													var curPages=$("#Productmannowcount");
													option='<select id="ProductcurPage" onchange="BlogProduct.Productlist($(this).val())" name="curPage" class="f12">';
													for (i=1; i<=pagecount; i++){
														if (i==page){
															option=option+'<option value="'+i+'"  selected="selected">'+i+'页</option>';
														}else{
															option=option+'<option value="'+i+'">'+i+'页</option>';
														}
													}
													
													curPages.html(option);
												}
												
											  } 
					});
				},
				"Newslist":function(page)
				{
					if (page==null||page==0) page=1;
					var url=phpbase+"/blog/newslist";
					var strhtml='';
					var strhtmlsub='';
					var i=0;
					var sUID=UID;
					var sMID=MID;
					var sTypeid='';
					$.ajax({
						type: "POST",
			 			url: url,
			 			data: "page="+page+"&uid="+sUID+"&mid="+sMID+"&typeid="+Typeid,
					    success: function(msg){
						 if(msg==-1)
							{
							$("#NewsManMorePage").hide();
						     return;
							}
												var ob;
												var ob0;
												var imgurl;
												var Extend;
												var Name="";
												var imgurl;
												var tdi=1;
												var Info;
												try{eval("ob=" +msg);} catch(e){}
												if(ob){
													pageinfo=ob['pageinfo'];
													contents=ob['contents'];
													page=ob['pageinfo']['pagenow'];	
										for(counter=contents.length;i<counter;i++)//分解JSON数据
											{
		if (tdi>4) 
			tdi=0;
		else
			tdi++;
		if(contents[i].imageurl!=-1)
			imgurl=contents[i].imageurl;
		else
			imgurl='/images/temp_ad_logo_5.jpg';
		if(contents[i].Extend!="")	
			Extend=contents[i].Extend;
		else
			Extend='暂无标价';
		if(contents[i].Info!=null)	
			Info=contents[i].Info;
		else
			Info='';			
		strhtml=strhtml+'<div class="ED_info f12"><ul><li class="line f14"><div class="particular f12">';
		strhtml=strhtml+'<a href="'+phpbase+'/news/content/'+sUID+'/'+sMID+'/'+contents[i].ID+'" target="_self">查看详细>> </a>';
		strhtml=strhtml+'</div><span>'+formatDate(contents[i].Cdate)+'</span>　<span class="bf"><a href="'+phpbase+'/news/content/'+sUID+'/'+sMID+'/'+contents[i].ID+'" target="_self">'+contents[i].Title+'</a></span></li>';
		strhtml=strhtml+'<li class="bgc_3" style="margin-top:1px; cursor:pointer;">';
		strhtml=strhtml+'<a href="'+phpbase+'/news/content/'+sUID+'/'+sMID+'/'+contents[i].ID+'" target="_self">'+contents[i].Body+'</a>';
		strhtml=strhtml+'</li></ul></div>';
		
											}
													//alert(strhtml);
													pagecount=ob['pageinfo']['pagecount'];
													$("#NewsmantotalPage").text('共'+pagecount+'页');

													$("#NewsListPage").html(strhtml);//把数据加载到页0页
													//$("#YPMore").focus();
													$("#Newsmanupdataup").unbind();
													$("#Newsmannextdataup").unbind();
													$("#Newsmanupdataup").bind("click", function() {BlogProduct.Newslist(parseInt(page)-1)});
													$("#Newsmannextdataup").bind("click", function() {BlogProduct.Newslist(parseInt(page)+1)});
													var curPages=$("#Newsmannowcount");
													option='<select id="NewscurPage" onchange="BlogProduct.Newslist($(this).val())" name="curPage" class="f12">';
													for (i=1; i<=pagecount; i++){
														if (i==page){
															option=option+'<option value="'+i+'"  selected="selected">'+i+'页</option>';
														}else{
															option=option+'<option value="'+i+'">'+i+'页</option>';
														}
													}
													
													curPages.html(option);
												}
												
											  } 
					});
				},	
				"Showlist":function(page)
				{
					if (page==null||page==0) page=1;
					var url=phpbase+"/blog/showlist";
					var strhtml='';
					var strhtmlsub='';
					var i=0;
					var sUID=UID;
					var sMID=MID;
					var sTypeid='';
					$.ajax({
						type: "POST",
			 			url: url,
			 			data: "page="+page+"&uid="+sUID+"&mid="+sMID+"&typeid="+Typeid,
					    success: function(msg){
						//alert(msg);
						 if(msg==-1)
							{
							$("#YPMorePage").hide();
						     return;
							}
												var ob;
												var ob0;
												var imgurl;
												var Extend;
												var Name="";
												var imgurl;
												var tdi=1;
												var Info;
												try{eval("ob=" +msg);} catch(e){}
												if(ob){
													pageinfo=ob['pageinfo'];
													contents=ob['contents'];
													page=ob['pageinfo']['pagenow'];	
										for(counter=contents.length;i<counter;i++)//分解JSON数据
											{
 strhtml=strhtml+'<div class="moreP f12 list_h18">';
 strhtml=strhtml+'<a href="'+phpbase+'/scene/content/'+sUID+'/'+sMID+'/'+contents[i].ID+'" target="_self">';
 strhtml=strhtml+'<img class="img_s" src="/blog/getResizedImage.php'+contents[i].imageurl[0]+'?120*90" alt="tu" /></a>';
 strhtml=strhtml+'<a href="'+phpbase+'/scene/content/'+sUID+'/'+sMID+'/'+contents[i].ID+'" target="_self">'+contents[i].Title+'</a></div>';
		
											}
													//alert(strhtml);
													pagecount=ob['pageinfo']['pagecount'];
													$("#showMorePagetotalPage").text('共'+pagecount+'页');

													if(page>1) $("#showlistpage").html(strhtml);//把数据加载到页0页
													//$("#YPMore").focus();
													$("#showupdataup").unbind();
													$("#shownextdataup").unbind();
													$("#showMorePageupdataup").bind("click", function() {BlogProduct.Showlist(parseInt(page)-1)});
													$("#showMorePagenextdataup").bind("click", function() {BlogProduct.Showlist(parseInt(page)+1)});
													var curPages=$("#showMorePagecurPageselect");
													option='<select id="showcurPage" onchange="BlogProduct.Showlist($(this).val())" name="curPage" class="f12">';
													for (i=1; i<=pagecount; i++){
														if (i==page){
															option=option+'<option value="'+i+'"  selected="selected">'+i+'页</option>';
														}else{
															option=option+'<option value="'+i+'">'+i+'页</option>';
														}
													}
													
													curPages.html(option);
												}
												
											  } 
					});
				},	
				"Productshow":function(page)//产品显示页分页 
				{
					if (page==null||page==0) page=1;
					var url=phpbase+"/blog/productlist";
					var strhtml='';
					var strhtmlsub='';
					var i=0;
					var sUID=UID;
					var sMID=MID;
					var sTypeid='';
					$.ajax({
						type: "POST",
			 			url: url,
			 			data: "page="+page+"&uid="+sUID+"&mid="+sMID+"&typeid="+Typeid,
					    success: function(msg){
						//alert(msg);
						 if(msg==-1)
							{
							$("#YPMorePage").hide();
						     return;
							}
												var ob;
												var ob0;
												var imgurl;
												var Extend;
												var Name="";
												var imgurl;
												var tdi=1;
												var Info;
												try{eval("ob=" +msg);} catch(e){}
												if(ob){
													pageinfo=ob['pageinfo'];
													contents=ob['contents'];
													page=ob['pageinfo']['pagenow'];	
										for(counter=contents.length;i<counter;i++)//分解JSON数据
											{
if (contents[i].imageurl!=-1)
		imgurl=contents[i].imageurl;
else
		imgurl='/images/temp_new_pic.gif';
 strhtml=strhtml+'<div class="moreP f12 list_h18">';
 strhtml=strhtml+'<a href="'+phpbase+'/product/content/'+sUID+'/'+sMID+'/'+contents[i].ID+'" target="_self">';
 strhtml=strhtml+'<img class="img_s" src="/blog/getResizedImage.php'+imgurl+'?120*90"  /></a>';
 strhtml=strhtml+'<a href="'+phpbase+'/product/content/'+sUID+'/'+sMID+'/'+contents[i].ID+'" target="_self">'+contents[i].Title+'</a></div>';
		
											}
													//alert(strhtml);
													pagecount=ob['pageinfo']['pagecount'];
													$("#showMorePagetotalPage").text('共'+pagecount+'页');
													if(page>1) $("#showlistpage").html(strhtml);//把数据加载到页0页
													//$("#YPMore").focus();
													$("#showMorePageupdataup").unbind();
													$("#showMorePagenextdataup").unbind();
													$("#showMorePageupdataup").bind("click", function() {BlogProduct.Productshow(parseInt(page)-1)});
													$("#showMorePagenextdataup").bind("click", function() {BlogProduct.Productshow(parseInt(page)+1)});
													var curPages=$("#showMorePagecurPageselect");
													option='<select id="showcurPage" onchange="BlogProduct.Productshow($(this).val())" name="curPage" class="f12">';
													for (i=1; i<=pagecount; i++){
														if (i==page){
															option=option+'<option value="'+i+'"  selected="selected">'+i+'页</option>';
														}else{
															option=option+'<option value="'+i+'">'+i+'页</option>';
														}
													}
													
													curPages.html(option);
												}
												
											  } 
					});
				},					
				"Changeimgurl":function(imgname,url)
				{
				//alert($("#"+imgname).attr("id"));
				//setTimeout(function(){alert($("#"+imgname).attr("id"))},1000);
					setTimeout(function(){$("#productshowimg").attr("src",url)},10);
					//$("#"+imgname).html('<img src="'+url+'" width="400"  id="productshowimg"/>');
					//alert(document.getElementById("productshowimg").src);
					// document.getElementById("productshowimg").src=url;
					//alert(document.getElementById("imgprint123").innerHTML);
					  //var   oImage=new Image() ;
					  //oImage.src=url;   
					//$("#productshowimg").bind("onerror", function(event1){ 	alert(11);
					//var aevent=event1||event;
					//var tempobj=aevent.srcElement||aevent.target; 
					  
					//  alert(tempobj.src);  }); 


					 // document.getElementById("productshowimg").src=url; 
					//document.getElementById("imgprint123").innerHTML='<img src="'+url+'" width="400"  id="productshowimg" name="productshowimg"/>';
					
					
				},
				"LoadSwitch":function(type)
					{
						switch(type)
						{
							case "product":
								BlogProduct.Productlist(1);
								break;
							case "news":
								BlogProduct.Newslist(1);
								break;
							case "showlist":
								BlogProduct.Showlist(1);
								break;
							case "productshow":
								BlogProduct.Productshow(1);
								break;
							default:
								break;
							
							
						}
					}
			}
/*******************************************
功能：格式化日期
调用说明：
date_obj为时间对象，
date_templet为返回的日期格式模版
（如：date_obj为2006-9-23 12:34:10 date_templet为yy年mm月，返回：06年9月）
*******************************************/
function parseDate(str){   
  if(typeof str == 'string'){ 
    var results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);   
    if(results && results.length>3)   
      return new Date(parseInt(results[1]),parseInt(results[2]) -1,parseInt(results[3]));    
    results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/);
    if(results && results.length>6)   
      return new Date(parseInt(results[1]),results[2]-1,results[3],results[4],results[5],results[6]);    
    results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/);   
    if(results && results.length>7)   
      return new Date(parseInt(results[1]),parseInt(results[2]) -1,parseInt(results[3]),parseInt(results[4]),parseInt(results[5]),parseInt(results[6]),parseInt(results[7]));    
  }   
  return null;   
} 
function formatDate(v){  
  if(typeof v == 'string') v = parseDate(v); 
  if(v instanceof Date){   
    var y = v.getFullYear();   
    var m = v.getMonth()+1 ; 
	if(m<10) m="0"+m;
    var d = v.getDate();   
    var h = v.getHours();   
    var i = v.getMinutes();   
    var s = v.getSeconds();   
    var ms = v.getMilliseconds();      
    if(ms>0) return y + '-' + m ;   
    if(h>0 || i>0 || s>0) return y +'年'+m + '月' + d +'日';   
    return y + '-' + m + '-' + d;   
  }   
  return '';   
} 
	