/**
 * Author:殘雪易冷 | E-mail: xueruos520@163.com                   
 * Copyright (c) 版权所有 无锡君通软件                                   
 * 2010.9.25
 * blog.csnowy.com
 */
 
/**
 * 弹出DIV层核心开始
 */
function showWindow(width,height,m,n,o,p){    
location.href="#";     
var windowstr= document.getElementById(p).innerHTML;   
document.getElementById(o).innerHTML=windowstr;    
document.getElementById(o).style.left=((document.body.clientWidth - width)>0?(document.body.clientWidth - width):0) / 2 + "px";    
document.getElementById(o).style.top=(window.screen.availHeight - 500) / 2 + "px";
document.getElementById(o).style.zIndex=10001;   
document.getElementById(o).style.width=width+"px";    
document.getElementById(o).style.height=height+"px";    
document.getElementById(m).style.height=document.body.clientHeight+ "px";    
document.getElementById(m).style.width=document.body.clientWidth+ "px";    
document.getElementById(m).style.display="";    
document.getElementById(n).style.display="";    
document.getElementById(n).style.zIndex=10000;   
document.getElementById(o).style.display="";    
}    


function closeWindow(q){   
document.getElementById(q).style.display="none";    
}
//弹出DIV层核心结束

/**
 * 弹出二级分类
 */
function alerttowcat(ob) {
var cat_id = ob.id;
document.getElementById("catVal").value = cat_id;
CX.getInfo('ajax.php','POST',"app",'action=cat&id='+cat_id,_outin);
closeWindow("tranDiv");
}

function _outin(res) {
document.getElementById("infoDiv").innerHTML = '';  
var innerDom = document.getElementById("mesWindowContent");
innerDom.innerHTML = res;
showWindow(300, 260, 'tranDiv', 'tranDivBack', 'infoDiv', 'popLayer');
}

/**
 * 输出分类信息
 * 单击二级分类事件
 */
function incat(ob) {
var incat_id = ob.id;
document.getElementById("catVal").value = incat_id;
CX.getInfo('ajax.php','POST',"app",'action=save_incat&id='+incat_id,_save_incat);
closeWindow("tranDiv");
returnTheBefore();
}

function _save_incat(){
	return true;
}

/**
 * 重新加载一级分类
 */
function returnTheBefore(){
	CX.getInfo('ajax.php','POST',"app",'action=return',_return);
	}
	
function _return(ret){
document.getElementById("infoDiv").innerHTML = '';  
var retDom = document.getElementById("mesWindowContent");
retDom.innerHTML = ret;
window.location = "post.php";
	}

/**
 * 页面跳转时数据通过Cookie传递
 * AJAX输出类型
 * 输出该模型下的Options
 */	
function retcookie(){
    CX.getInfo('ajax.php','POST',"app",'action=get_incat',_get_incat);
}

function _get_incat(ret){
   var id = ret;
   if(typeof(id) == 'undefined'){
		showWindow(450,260, 'tranDiv', 'tranDivBack', 'infoDiv', 'popLayer');
		return false;
	}
	CX.getInfo('ajax.php','POST',"app",'action=getpostcat&id='+id,_getpostcat);
}
	
function _getpostcat(ret){
	document.getElementById('poscat').innerHTML = ret;
	//获取本模型下的详细信息OPTION
	var opid = document.getElementById('catid').value;
	CX.getInfo('ajax.php','POST',"app",'action=getoption&id='+opid,_getoption);
	}
	
function _getoption(ret){
	document.getElementById('detail').innerHTML = ret;
    }

/**
 * 上传窗体开始
 */
function alertImgDiv(){
	var c = '<form method="post" target="UploadThumb" enctype="multipart/form-data" action="upload.php" ><input type="hidden" name="from" value="thumb"/><input type="hidden" name="fid" value=""/><table cellpadding="3"><tr><td><input id="upthumb" class="inputs" type="file" size="40" name="file"/></td></tr><tr><td><input type="submit" class="but" style="float:right" value="上 传" /></td></tr></table></form>';
	document.getElementById('upform').innerHTML = c;
	showWindow(450, 260, 'tranDiv_2', 'tranDivBack_2', 'infoDiv_2', 'popLayer_2');
	}
	
//上传回调
function changethumb(imgsrc, mid){
	$('#thumb').val(imgsrc);
	$('#thumbid').val(mid);
	$('#showthumb1').attr("src", imgsrc);
	$('#upimgspan').text("[重新上传]");
}
	
/**
 * AJAX加载窗体
 */
function alertloadDiv(){
	var c = '<li style="align:center"><img src="images/load.gif" /></li><li>正在加载信息,请稍后...</li>';
	document.getElementById('loading').innerHTML = c;
	showWindow(450, 260, 'tranDiv_3', 'tranDivBack_3', 'infoDiv_3', 'popLayer_3');
	}
	
/**
 * 提示信息
 */
function alerttishiDiv(msg, loca){
	document.getElementById('msgform').innerHTML = msg + '<br><img src="images/load.gif" />' + '&nbsp;&nbsp;3秒后进行跳转，请稍候...';
	showWindow(450, 260, 'tranDiv_5', 'tranDivBack_5', 'infoDiv_5', 'popLayer_5');
}

/**
 * 发送站内信息窗体
 */
function alertpostinDiv(){
	CX.getInfo('ajax.php','POST',"app",'action=check_postin_get',_check_postin_get);
}

function _check_postin_get(ret){
	if(ret == "false"){
	    messBox_common_p('请先登录！');
		return false;	
	}
	showWindow(650, 460, 'tranDiv_6', 'tranDivBack_6', 'infoDiv_6', 'popLayer_6');
	var $saved_arr = ret.split('#');
	for(i=0; i<$saved_arr.length; i++){
	  $saved_arr_arr = $saved_arr[i].split(',');
	  document.getElementById($saved_arr_arr[0]).value = $saved_arr_arr[1];	
	}
}

/**
 * 举报信息窗体
 */
function alertjubaonDiv(){
	CX.getInfo('ajax.php','POST',"app",'action=check_jubao_get',_check_jubao_get);
}

function _check_jubao_get(ret){
	showWindow(650, 400, 'tranDiv_7', 'tranDivBack_7', 'infoDiv_7', 'popLayer_7');
	var $saved_arr = ret.split('#');
	for(i=0; i<$saved_arr.length; i++){
	  $saved_arr_arr = $saved_arr[i].split(',');
	  document.getElementById($saved_arr_arr[0]).value = $saved_arr_arr[1];	
	}
}
