﻿
function ajaxSubmitForm(name){
	var hasError = false;
	var formobj=document.getElementById(name);
	var items=formobj.elements;
	for (var i=0;i<items.length;i++){
		if(validFormItem(items[i],true) != null) hasError = true;
	}
	if(hasError) return;
	try{
		publish_article();
	}catch(e){}
	
	var pars = $("#"+name).formSerialize(); 
	var formObject = $("#"+name);
	var submitUrl = formObject[0].action;
	$.ajax({
	  		type:"POST",
	  		url:submitUrl,
	  		data:pars,	
	  		success:function(html){
	  			$('#ajax_form_div').html(html).hide().show('slow');
	  		},
	  		error:function(){
	  			$('#ajax_form_div').html('很抱歉！现在服务器忙，请稍后访问 ! ');
	  		} 
  	})
}
function changeProductLink()
{
	var loadUrl = 'http://func.ey800.com/user/changeProduct.shtml?'+Math.random();
	$('#ajax_form_div').load(loadUrl);
}
function showProductList()
{
	var loadUrl ='http://func.ey800.com/user/list.shtml?'+Math.random();
	$.ajax({
		type:"POST",url:loadUrl,
		beforeSend:function(){
    	$('#menber_product_list').html('<br><img src=\"/images/loading.gif\">&nbsp;正在加载......');
    },
		success:function(html){
		  $('#menber_product_list').html(html).hide().show('slow');
		},
		error:function(){
			$('#menber_product_list').html('很抱歉！现在服务器忙，请稍后访问！');
		} 
	})
		
}

function  ModifyOrd(PID,ORDID)
{
   		var loadUrl = 'http://func.ey800.com/user/ModifyOrd.shtml?RID='+Math.random();
		var pars='pid='+PID+'&ordid='+document.getElementById(ORDID).value;
		$.ajax({
			  		type:"Get",
			  		url:loadUrl,
			  		data:pars,	
		  		success:function(html){
		  			$('#ModifyOrdHint').html(html);
		  		},
		  		error:function(){
		  			$('#ModifyOrdHint').html('很抱歉！现在服务器忙，请稍后访问！');
		  		} 
		})  
}

function showImageUploadTwoPic()
{
	$('#showUpload').css({width:'480px',height:'80px',FRAMEBORDER:'0',scrolling:'no',visibility:'visible' });
	$('#upfile').slideToggle('slow');
}


function showProductTypeSelect(){
	var loadUrl = 'http://func.ey800.com/user/producttype.shtml?RID='+Math.random();
	$('#productType').load(loadUrl);
}
//根据大类的值显示小类的值
	function showSmallType(bigtype){
		var loadUrl = 'http://func.ey800.com/user/producttype2.shtml?RID='+Math.random();
		var pars='bigtypeId='+bigtype;
		$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
		  		success:function(html){
		  			$('#productSmallType').html(html);
		  		},
		  		error:function(){
		  			//$('#productSmallType').html('很抱歉！现在服务器忙，请稍后访问！');
		  		} 
		})
  }

	function showSmallTypeClassAgent(bigtype,areaname){
		var loadUrl = 'http://'+areaname+'.agentsearch.ey800.com/user/producttypeAgent.shtml?RID='+Math.random();
		var pars='bigtypeId='+bigtype;
		$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
		  		success:function(html){
		  			$('#productSmallType').html(html);
		  		},
		  		error:function(){
		  			//$('#productSmallType').html('很抱歉！现在服务器忙，请稍后访问！');
		  		} 
		})
        }
	
        function showSmallTypeClassAgent2(bigtype,areaname){
		var loadUrl = 'http://product.ey800.com/user/producttypeAgent.shtml?RID='+Math.random();
		var pars='bigtypeId='+bigtype;
		$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
		  		success:function(html){
		  			$('#productSmallType').html(html);
		  		},
		  		error:function(){
		  			//$('#productSmallType').html('很抱歉！现在服务器忙，请稍后访问！');
		  		} 
		})
        }

	function showSmallTypeClass_AgentList(bigtype,areaname){
                $('#productSmallType').html('<div><img src="http://www.ey800.com/images/wait.gif" style="width:16px;height:16px;" />数据加载中...</div>');
		var loadUrl = 'http://'+areaname+'.agentlist.ey800.com/user/producttype_AgentList.shtml?RID='+Math.random();
		var pars='bigtypeId='+bigtype+'&pareapy='+areaname;
		$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
		  		success:function(html){
  					//alert(html);
		  			$('#productSmallType').html(html);
		  		},
		  		error:function(){
		  			//$('#productSmallType').html('很抱歉！现在服务器忙，请稍后访问！');
		  		} 
		})
        }

	function showSmallTypeClass(bigtype,CLASSID){
		var loadUrl = 'http://'+[CLASSID]+'.class.ey800.com/user/GetType2.shtml?RID='+Math.random();
		var pars='bigtypeId='+bigtype;
		$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
		  		success:function(html){
					//$('#initType').style.visibility = 'hidden';
		  			$('#productSmallType').html(html);
		  		},
		  		error:function(){
		  			//$('#productSmallType').html('很抱歉！现在服务器忙，请稍后访问！');
		  		} 
		})
      }

       function showSmallTypeClass2(bigtype,CLASSID){
         var loadUrl = 'http://product.ey800.com/user/GetType2.shtml?RID='+Math.random();
		var pars='bigtypeId='+bigtype;
		$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
		  		success:function(html){
					//$('#initType').style.visibility = 'hidden';
		  			$('#productSmallType').html(html);
		  		},
		  		error:function(){
		  			//$('#productSmallType').html('很抱歉！现在服务器忙，请稍后访问！');
		  		} 
		})
         
		
        }
       function showSmallTypeClass3(bigtype,CLASSID){
         var loadUrl = 'http://func.ey800.com/user/GetType3.shtml?RID='+Math.random();
		var pars='bigtypeId='+bigtype;
		$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
		  		success:function(html){
					//$('#initType').style.visibility = 'hidden';
		  			$('#productSmallType').html(html);
		  		},
		  		error:function(){
		  			//$('#productSmallType').html('很抱歉！现在服务器忙，请稍后访问！');
		  		} 
		})
         
		
        }
       function shuxingshow(shuxing)
       {
          window.location.href="http://www.ey800.com/fenlei/"+shuxing+".shtml";
       }
       function jixing(jixing)
       {
         
	  window.location.href="http://product.ey800.com/jixing.shtml?dosetypeid="+jixing+"&pageno=1";
       }
       function quyu(areapy)
       {
         
	  window.location.href="http://product.ey800.com/quyu.shtml?areapy="+areapy+"&pageno=1";
       }


	function DispClass(smalltype,CLASSID){

		var loadUrl = 'http://'+smalltype+'.class.ey800.com/1/';                
	        window.location.href= loadUrl;
		
        }

        function DispAgent(smalltype,areaname){

		var loadUrl = 'http://'+areaname+'.agentsearch.ey800.com/'+smalltype+'/1/';               
	        window.location.href= loadUrl;
		
        }

//大图显示与隐  
function showfilter(obj) {
		$('#'+obj).toggle();
}
function editProducts(pars)
{
	var loadUrl = 'http://func.ey800.com/user/editproduict.shtml?'+Math.random();
	var pars='pid='+pars;
	$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
			  		success:function(html){
			  			$('#menber_product_list').html(html).hide().show('slow');
			  		},
			  		error:function(){
			  			$('#menber_product_list').html('很抱歉！现在服务器忙，请稍后访问！');
			  		}
		})
}

//产品重发
function redirectProduct(pid,cid,number){
	if(CK.Cookie.Get("Product_"+cid)=="false")
		{
			alert("抱歉,两个小时内,您只能重发一次产品!,请见谅.");
		}
		else
		{		
		var expdate = CK.Cookie.ExpDate(0,2,0);
		CK.Cookie.Set("Product_"+cid,"false",expdate);
		var loadUrl = 'http://func.ey800.com/user/redirectproduct.shtml?'+Math.random();
		var pars='pid='+pid+'&cid='+cid+'&number='+number;
		$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
			  		success:function(html){
			  			$('#menber_product_list').html(html);
			  		},
			  		error:function(){
		  				$('#menber_product_list').html('很抱歉！现在服务器忙，请稍后访问！');
		  			}
		});
	}
}
//删除产品
function deleteProduct(pid){
	alert(pid);
		var loadUrl = 'http://func.ey800.com/user/delete.shtml?'+Math.random();
		var pars='id='+pid;
		$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
			  		success:function(html){
			  			$('#menber_product_list').html(html);
			  		},
			  		error:function(){
			  			$('#menber_product_list').html('很抱歉！现在服务器忙，请稍后访问！');
			  		}
		})
}
function ajaxSubmitFormGetResult(name,showdiv){
	var pars = $("#"+name).formSerialize(); 
	var formObject = $("#"+name);
	var submitUrl = formObject[0].action;
	$.ajax({
	  		type:"POST",
	  		url:submitUrl,
	  		data:pars,
	  		//beforeSend:function(){
		    //	$('#'+showdiv).html('<br><img src=\"/MedicalCenter/images/loading.gif\">&nbsp;正在加载......');
		    //},
	  		success:function(html){
	  		//	$('#'+showdiv).html('');
	  			$('#'+showdiv).html(html).hide().slideDown("slow");
	  		},
	  		error:function(){
	  			$('#'+showdiv).html('很抱歉！现在服务器忙，请稍后访问！');
	  		}
  	})
}
function DateDiff(sDate1,sDate2){
	  var aDate,oDate1,oDate2,iDays ;
	  aDate =sDate1.split('-');  
	  oDate1 = new Date(aDate[1]+'-'+aDate[2]+'-'+aDate[0]) ;
	  aDate = sDate2.split('-');  
	  oDate2 = new Date(aDate[1]+'-'+ aDate[2] +'-'+aDate[0]);  
	  iDays = parseInt(Math.abs(oDate1 -oDate2)/1000/60/60/24);
	   return iDays ;
	}
function ajaxSubmitData(name,showdiv)
{
	var begin=$('#beginTime').val();
	var end=$('#endTime').val();
	if(DateDiff(begin,end) > 30 ){
		alert("只提供导出一个月的数据！请您重新选择日期！");
		return ;	
	}
	var pars = $("#"+name).formSerialize(); 
	var formObject = $("#"+name);
	var submitUrl = formObject[0].action;
	$.ajax({
	  		type:"POST",
	  		url:submitUrl,
	  		data:pars,	
	  		success:function(html){
	  			$('#'+showdiv).html(html).hide();
	  		},
	  		error:function(){
	  			$('#'+showdiv).html('很抱歉！现在服务器忙，请稍后访问！');
	  		}
  	})
}

function showAgentBooksListByUserList(index,beginTime,endTime)
{
	var loadUrl = 'http://func.ey800.com/user/AgentBooksListByUser.shtml?'+Math.random();
	var pars = 'size=8&index='+ index+'&beginTime='+beginTime+'&endTime='+endTime;
	$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
			  		success:function(html){
			  			$('#QueryList').html(html).hide().slideDown("slow");
			  		},
			  		error:function(){
			  			$('#QueryList').html('很抱歉！现在服务器忙，请稍后访问！');
			  		}
		})
}
//
function showAgentBooksListBySuperUserList(index,beginTime,endTime,province,city,type,proname)
{
	var loadUrl = 'http://func.ey800.com/user/agentBooksListBySuperUser.shtml?'+Math.random();
	var pars = 'size=8&index='+ index+'&beginTime='+beginTime+'&endTime='+endTime+'&province='+province+'&city='+city+'&type='+type+'&proname='+proname;
	$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
			  		success:function(html){
			  			$('#QueryList').html(html).hide().slideDown("slow");
			  		},
			  		error:function(){
			  			$('#QueryList').html('很抱歉！现在服务器忙，请稍后访问！');
			  		}
		})
}

function showPublicAgentBooksList(index,beginTime,endTime,province,city,type,proname)
{
	var loadUrl = 'http://func.ey800.com/user/publicAgentBooksList.shtml?'+Math.random();
	var pars = 'size=8&index='+ index+'&beginTime='+beginTime+'&endTime='+endTime+'&province='+province+'&city='+city+'&type='+type+'&proname='+proname;
	$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
			  		success:function(html){
			  			$('#QueryList').html(html).hide().slideDown("slow");
			  		},
			  		error:function(){
			  			$('#QueryList').html('很抱歉！现在服务器忙，请稍后访问！');
			  		}
	})
}

	//大类
      function showAgentTypeSelect(args,arg){
		var loadUrl = 'http://func.ey800.com/user/producttype.shtml?rid='+Math.random();
		$('#productType').load(loadUrl);      
      }
      function showAgentTypeSelect_yys(bigtype){
               
		var loadUrl = 'http://func.ey800.com/user/producttype.shtml?rid='+Math.random()+'&bigtype='+bigtype;
		$('#productType').load(loadUrl); 
              

	}

function showAgentTypeSelect2(args,arg){
	var loadUrl = 'http://func.ey800.com/user/producttype3.shtml?bigtype='+args+'&'+'smalltype='+arg+'&rand='+Math.random();
	$('#productType').load(loadUrl);
}

	
	//根据大类的值显示小类的值
	function showAgentSmallType(bigtype){
		var loadUrl = 'http://func.ey800.com/user/smalltype.shtml?rid='+Math.random();
		var pars='bigtypeName='+bigtype;
		$.ajax({
			  		type:"POST",
			  		url:loadUrl,
			  		data:pars,	
			  		success:function(html){
			  			$('#productSmallType').html(html).hide().show('slow');
			  		},
			  		error:function(){
			  			$('#productSmallType').html('很抱歉！现在服务器忙，请稍后访问！');
			  		}
	 })
	}













//全选   反选

function checkAll()
{
            var doc=document.getElementById("dgProduct");
            var items= doc.getElementsByTagName("input");
            for(var i=0;i<items.length;i++)
            {
                if(items[i].type=="checkbox")
                {
                      items[i].checked=true;
                }
             }
}
function checkedback()
{
      var items=document.getElementById("dgProduct").getElementsByTagName("input");
      for(var i=0;i<items.length;i++ )
      {
           if(items[i].type=="checkbox")
           {
              if(items[i].checked)
                   items[i].checked=false;
              else
                   items[i].checked=true;
           }
      }
}




