﻿// JScript 文件
var $ = function(ID){ return document.getElementById(ID); };
function formToString(formname){
 var _string='';
 var form_eleobj = $(formname);
 if(!form_eleobj) return form_eleobj;
 var form_obj = $(formname).elements;
 sub:for (var i=0;i<form_obj.length ;i++){
     var e=form_obj[i];
     if (e.name!=''&&e.name!='Editor1')
     {
         var element_value = "";
         if (e.type.toLowerCase()=='select'){
            element_value=e.options[e.selectedIndex].value;
         }
         else if (e.type.toLowerCase()=='hidden'|| e.type.toLowerCase()=='button'){
             continue;
         }
         else if (e.type.toLowerCase()=='checkbox'){
             if (e.checked==true)
                 element_value='1';
             else
                 element_value='0';
         }
         else if (e.type.toLowerCase()=='radio'){
             if (e.checked==true)
                 element_value='1';
             else
                 element_value='0';
         }
         else{
            element_value=e.value;
         }
         var s = element_value.indexOf('_value_');
         if(s>0){
            alert('您输入的字符不能含有“_value_”！');
            _string = null;
            break sub; 
         }
        _string+=element_value.replace(/\&/g,"%26")+'_value_';
     }
 }
 return _string;
}
var msg	;
var reg_ok='images/reg_ok.gif';
var reg_err='images/reg_err.gif'
var $ = function(ID){ return document.getElementById(ID); };
function getProvince(obj1,obj2,obj3){                                  
   var dropMyCountry = $(obj1);
   var country = dropMyCountry.value;
  
   if(country == "") country = "86";
   var i;
   var j=1;
   var dropMyProv = $(obj2);
   dropMyProv.length=0;
   dropMyProv[0]=new Option("任意", "-1");
   
   for(var i = 0; i<f_city.length; i++) {
	   var _mtp = f_city[i].split("|")[0];
	   if (_mtp == country) {	
		  dropMyProv.options[j]=new Option(f_city[i].split("|")[1], f_city[i].split("|")[2]);
		  if(f_city[i].split("|")[2] == 8611 )
			   dropMyProv.options[j].selected=true;
		  j++;
	   }
   }
   getCity(obj2,obj3);  
}
 
function getCity(obj1,obj2){ 
   var dropMyProv = $(obj1);
   var prov = dropMyProv.value;
   var dropMyCity = $(obj2);
   var i;
   var j=1;
   dropMyCity.length=0;
   dropMyCity[0]=new Option("任意", "-1");
   
   for(var i = 0; i<f_city1.length; i++) {
	   var _mtp = f_city1[i].split("|")[0];
	   var _mtp1 = f_city1[i].split("|")[1];

	   if ( _mtp1 == prov) {
	   
		   dropMyCity.options[j]=new Option(f_city1[i].split("|")[2],  f_city1[i].split("|")[3]);
		   j++;
	   }
   } 
}

function initlocation(obj1,obj2,city1,city,city2){
	var i;
       var j=1;
	var dropMyProv = $(obj1);
    dropMyProv.length=0;
    dropMyProv[0]=new Option("任意", "-1");
    for(var i = 0; i<f_city.length; i++) {
    	var _mtp = f_city[i].split("|")[0];

        if (_mtp == city1) {
        	dropMyProv.options[j]=new Option(f_city[i].split("|")[1], f_city[i].split("|")[2]);  
	    	if(f_city[i].split("|")[2] == city)
		    	dropMyProv.options[j].selected=true;
        	j++;
        }
    }

    var prov = city;
    var dropMyCity = $(obj2);
    var i;
    var j=1;
	
    dropMyCity.length=0;
    dropMyCity[0]=new Option("任意", "-1");
  
    for(var i = 0; i<f_city.length; i++) {
		var _mtp = f_city1[i].split("|")[0];
		var _mtp1 = f_city1[i].split("|")[1];
		if ( _mtp1 == prov) {
		  dropMyCity.options[j]=new Option(f_city1[i].split("|")[2],  f_city1[i].split("|")[3]);
		  
		  if(f_city1[i].split("|")[3] == city2)
			  dropMyCity.options[j].selected=true;
		  j++;
		}
    }
}

function getcitytotext()
{
   var txt = $('A_Province').options[$('A_Province').selectedIndex].text+$('A_City').options[$('A_City').selectedIndex].text;
   $('CompanyAreaName').value = txt;
   return txt;
}
function getcontentFCK(){
var editor1 = document.getElementById('CE_Editor1_ID');
var content = editor1.getHTML();
return content;
}
function subUserReg(type){
$("s1").disabled = true;
var utp = parseInt(type);
var sss = formToString('form1')+getcitytotext();
Marry.Ajax.reg.subUserReg(utp,sss,subCompanyUser_callback);  
}
function subCompanyUser_callback(rel){
if(rel.value!=""){
alert(rel.value);
window.location.href='../../';
}
else
{
alert("操作失败.请稍后再试！");
$("s1").disabled = false;
return false;
}
}

function modifyComInfo(){
$("s1").disabled = true;
var hid = $('H_uid').value;
var sss = formToString('form1')+getcitytotext()+"_value_"+getcontentFCK()+"_value_"+hid;
Marry.Ajax.compro.modifyComInfo(sss,modifyComInfo_callback);  
}

function modifyComInfo_callback(rel){
if(rel.value=="true"){
$("s1").disabled = false;
alert('修改成功!');
}
else
{
alert("操作失败.请稍后再试！~~~~~~~");
$("s1").disabled = false;
return false;
}
}
/************************************************************************************************/
function gopageindex()
{
var pi = $("gopage").value;
SeachMessage(pi);
}
function SeachMessage(val)
{
    var uid=$("u_id").value;
    if(uid==null||uid==""){alert('您还没有登陆请先登陆');return false;}
    var type=$("tp").value;
    var _pid=1;
    if(val!=null&&val!=""){_pid=parseInt(val);}
    var str=uid+"_value_"+type;
    //alert(_pid+'-'+str);
    Marry.Ajax.friend.SeachMessage(_pid,str,SeachMessage_callback);
}
function SeachMessage_callback(rel)
{
    if(rel.value!=null&&rel.value!="")
    {
       // $("td1").innerHTML=rel.value;
        var aa=$("tp").value;
       switch(aa)
       {
            case '1':$("td1").innerHTML=rel.value; break;
            case '2':$("td2").innerHTML=rel.value;break;
            case '3':$("td3").innerHTML=rel.value; break;
            case '4':$("td4").innerHTML=rel.value; break; 
       }
    }
}
function lookmessage(val,type)
{
    //alert('在建设中.......'+val+'-'+type);
    //$("Div1").className='dis';
    var aa=parseInt(val);
    var bb=parseInt(type);
    Marry.Ajax.friend.showMessage(aa,bb,lookmessage_callback);
}
function lookmessage_callback(rel)
{
    if(rel.value!=null&&rel.valu!=""){$("Div1").className='dis'; $("td5").innerHTML=rel.value;}
    else{alert("操作失败.请稍后再试！~~~~~~~");$("Div1").className='undis'; 
return false;}    
}
