
//get_Wretch();
//get_YAHOO();

function get_Wretch()
{

 	mng.action.value="get_Wretch";
	xajax_processForm(xajax.getFormValues("mng"));
}
function get_YAHOO()
{

 	mng.action.value="get_YAHOO";
	xajax_processForm(xajax.getFormValues("mng"));
}



function ReturnList()
{
	opener.window.show_list();	
	
	//opener.window.location.reload();
	self.close();
}

function addNewAlias()
{
 	mng.action.value="addNewAlias";
	xajax_processForm(xajax.getFormValues("mng"));
}

function getfromWretch()
{
	mng.getfromWretchBT.disabled=true;
	alert("執行此動作需要一段時間，請勿重覆按鍵");
 	mng.action.value="getfromWretch";
	xajax_processForm(xajax.getFormValues("mng"));
}

function DrawImage(ImgD,FitWidth,FitHeight){
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		if(image.width/image.height>= FitWidth/FitHeight){
			if(image.width>FitWidth){
				ImgD.width=FitWidth;
				ImgD.height=(image.height*FitWidth)/image.width;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		} else{
			if(image.height>FitHeight){
				ImgD.height=FitHeight;
				ImgD.width=(image.width*FitHeight)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
		}
	}
}



function mark_status(didi_uid,hunter_uid,action)
{
	mng.tmpVar.value=action;
 	mng.action.value="chang_didi_marker";
	xajax_processForm(xajax.getFormValues("mng"));
	return false;	
}

function window_open(url)
{
	window.open (url, '_blank');
}


window.onbeforeunload = function ()
{
	if(mng.modify.value=='0')
	{
		if(isModified("mng"))
		{
			try
			{
				event.returnValue = "內容已有變更尚未儲存，是否繼續？";  
			}
			catch(e)
			{
			}	    	
		}
	}
  
}

window.onerror = function(msg, url, line)
{
    window.status = "Script Error: " +msg + ", Ln: " + line;
    return true;
};

 function jump(user_next_id)
 {
 	location.href="dd.php?d="+user_next_id;
 }

 function search()
 {
 	location.href="dd.php?page="+mng.page.value+"&select="+mng.select.value;
 }
 
function logout()
{
 	location.href="dd.php?action=logout";
}

 function showdetail(item) 
 {
 	mng.action.value=item;
 	//alert(mng.action.value); 	
	xajax_processForm(xajax.getFormValues("mng"));
	return false;
 }
 
 function update_user_data()
 {
  	mng.action.value="update_user_data";	
	xajax_processForm(xajax.getFormValues("mng"));
	return false;
 }

 function update_user_data1()
 {
  	mng.action.value="update_user_data1";	
	xajax_processForm(xajax.getFormValues("mng"));
	return false;
 }
 
 function initPage()      
 {   
	 for(i=0;i<document.all.tags("select").length;i++)          
	 {      
	      var select = document.all.tags("select").item(i);   
	      if(select.defaultValue == undefined)   
	        select.defaultValue = select.options[select.selectedIndex].value;     
	 }      
 }   
  
function isModified(objID)      
{   
    isChange = false;   
       
    if(document.getElementById(objID) == undefined || document.getElementById(objID) == null)   
    {   
        return false;   
    }   
       
    var clInput = document.getElementById(objID).all.tags("input");           
    var clArea  = document.getElementById(objID).all.tags("textarea");   
    var clSelect= document.getElementById(objID).all.tags("select");   
       
    for (i=0;i<clInput.length;i++)          
    {   
        if (isChange == true) {      
            break;              
        }                 
       
        switch (clInput.item(i).type)                  
        {                        
            case "text" :   
                if (clInput.item(i).value != clInput.item(i).defaultValue)                          
                {                  
                    isChange = true;                                  
                    break;                             
                }                            
            case "radio" :                             
                if (clInput.item(i).checked != clInput.item(i).defaultChecked)                         
                {                                  
                    isChange = true;                                  
                    break;   
                }                       
            case "checkbox" :                             
                if (clInput.item(i).checked != clInput.item(i).defaultChecked)   
                {   
                    isChange = true;                                   
                    break;                              
                }                    
        }           
    }                   
       
    for (i=0;i<clArea.length;i++)          
    {                
        if (isChange ==true) {   
            break;     
        }                              
            
        if (clArea.item(i).value != clArea.item(i).defaultValue)              
        {                      
            isChange = true;                      
            break;                 
        }           
    }   
       
    for (i=0;i<clSelect.length;i++)          
    {                
        if (isChange ==true) {   
            break;   
        }   
           
        if (clSelect[i].defaultValue != clSelect[i].options[clSelect[i].selectedIndex].value)              
        {                      
            isChange = true;                      
            break;                 
        }           
    }   
  
    return isChange;   
} 
 

 
 ////////
 

function gototest()
{
 	location.href="index.php";
}
function logout()
{
 	location.href="didi.php?action=logout";
}

function show_detail(id)
{
 	url="dd.php?page="+mng.gotopage.value+"&d="+id+"&select="+mng.L_List.value;
	window.open (url, '_blank');
}

function selall()
{
	if(mng.sel.value=='0')
	{
		mng.sel.value=1;
		mng.allsel.value="全不選";
		
		  		
		for(i=0;i<26;i++)
		{
			var objForm = document.getElementById("L_City_"+String.fromCharCode(65+i));
			objForm.checked = true;

		}
	}
	else
	{
		mng.sel.value=0;	
		mng.allsel.value="全選";	
		for(i=0;i<26;i++)
		{
			var objForm = document.getElementById("L_City_"+String.fromCharCode(65+i));
			objForm.checked = false;
		}		
	}
}

function addnew(obj)
{
 	
	//yourname=prompt("請輸入您要新增的帳號", "") //get the name
 	if(document.getElementById("L_keyword").value=="")
 	{
  		alert("你沒有輸入帳號")
 	}
 	else
 	{ 	if(validate_email(document.getElementById("L_keyword").value))
 		{
 
	 		CallXajaxWithParameter('add_new_account_check',obj,'s_user_email='+document.getElementById("L_keyword").value);

			return false;
		}
		else
		{
			alert('error email');
		}
 	}
}

function go_to_page(page)
{	
	mng.gotopage.value=page;
	show_list();
	/*
  	mng.action.value="show_list";	
	xajax_processForm(xajax.getFormValues("mng"));
	return false;
	*/	
}

function sort(str)
{

	field=str+'_order';
	now_order=document.getElementById(field).value;
	if(now_order=='DESC')
	{
		neworder='ASC';
	}
	else
	{	
		neworder='DESC';
	} 
	document.getElementById(field).value=neworder;
	mng.tmpVar.value=str+' '+neworder;
	mng.action.value='sortlist';
	xajax_processForm(xajax.getFormValues("mng"));
	return false;
}

function search()
{
	document.getElementById('gotopage').value=1;
	show_list();
}

function show_list1()
{
	alert("OK");
}



function show_list()
{
	document.getElementById("search_button").disabled=true;
  	mng.action.value="show_list";	
	xajax_processForm(xajax.getFormValues("mng"));
	return false;	
}

