/*
Author:Zero (Huang Xiangyang)
Data:2007-8-10
FileName:slide.js
*/
slide = function(){

	/* 定义基本参数 */
	var aLeft;
	var ObjWidth;
	var initWidth;
	var iii;
	var cols;
	var DragHeight;
	var drag_area_height;

	var dragTitleValue;
	var dragContent;

	/* 定义图片拖拽容器 */
    
    var dragId;
	var dragObjs;      //可以拖拽的元素数组
	var dragObjTops;

	var dragHelper;     //拖拽时位置框
	var dragObj;      //拖拽对象元素
	var dragObjPos;

	var dragObjOffset;  //拖拽对象原始位置
	var mouseInDragObjOffset; //鼠标在拖拽对象中的相对位置

	var ObjHelght;
	var initHeight;

	/* 定义slide的属性 */
	var _border;		//边框
	var _theme;			//装饰
	var _style;			//特效
	var _background;	//背景
	var _bgcolor;
	var _play_mode;		//1=幻灯片,2=3D
	var _music;			//音乐
	var _music_id;
	var _music_name;
	var _plus;			//仿旧
	var _images;		//图片
	var _width;			//宽度
	var _height;		//高度
	
	/* 定义slide字模属性 */
	var _caption_mode;
	var _caption_transparent;
	var _caption_fontsize;
	var _caption_fontcolor;
	var _caption_bgcolor;
	var _cation_speed;

	var _moliheid;

	var _thiseffect_area;

	var _sys_isalert;
	var _sys_iseffect;
}

var _s = slide.prototype;

_s.curtypeobj = null;

_s.dragId = 0;

_s._sys_isalert = 0;
_s._sys_iseffect = 0;

/* 定义slide的属性 */
_s._border = "";		//边框
_s._theme = "";			//装饰
_s._style = "";			//特效
_s._background = "";	//背景
_s._bgcolor = "";	//背景
_s._play_mode = 1;	//1=幻灯片,2=3D
_s._music = "";			//音乐
_s._music_id = "";
_s._music_name = "";
_s._plus = "";			//仿旧
_s._images = "";		//图片
_s._width = "";			//宽度
_s._height = "";		//高度


/* 定义slide字模属性 */
_s._caption_mode = "";
_s._caption_transparent = "";
_s._caption_fontsize = "";
_s._caption_fontcolor = "0x000000";
_s._caption_bgcolor = "0xffffff";
_s._caption_speed = "";

_s._width = "416";
_s._height = "312";

_s._moliheid = "";

_s._thiseffect_area = "";


_s.setmoliheid = function(v){
	_s._moliheid = v;
}

_s.getmoliheid = function(){
	return _s._moliheid;
}

_s.setborder = function(v){
	_s._border = v;
}

_s.settheme = function(v){
	_s._theme = v;
}

_s.setstyle = function(v){
	_s._style = v;
}

_s.setbackground = function(v){
	_s._background = v;
}

_s.setbgcolor = function(v){
	_s._bgcolor = v;
}

_s.setplay_mode = function(v){
	_s._play_mode = v;
}

_s.setmusic = function(v){
	_s._music = v;
}

_s.setmusic_id = function(v){
	_s._music_id = v;
}

_s.setmusic_name = function(v){
	_s._music_name = v;
}

_s.setplus = function(v){
	_s._plus = v;
}

_s.setwidth = function(v){
	_s._width = v;
}

_s.setheight = function(v){
	_s._height = v;
}

_s.setimages = function(v){
	_s._images = v;
}

_s.setcaption_fontsize = function(v){
	_s._caption_fontsize = v;
}

_s.setcaption_fontcolor = function(v){
	_s._caption_fontcolor = v;
}

_s.setcaption_bgcolor = function(v){
	_s._caption_bgcolor = v;
}

_s.setcaption_speed = function(v){
	_s._caption_speed = v;
}

_s.setcaption_mode = function(v){
	_s._caption_mode = v;
}

_s.setcaption_transparent = function(v){
	_s._caption_transparent = v;
}



_s.getborder = function(){
	return _s._border;
}

_s.gettheme = function(){
	return _s._theme;
}

_s.getstyle = function(){
	return _s._style;
}

_s.getbackground = function(){
	return _s._background;
}

_s.getbgcolor = function(){
	//alert("背景色："+_s._bgcolor);
	return _s._bgcolor;
}

_s.getplay_mode = function(){
	return _s._play_mode;
}

_s.getmusic = function(){
	return _s._music;
}

_s.getmusic_id = function(){
	return _s._music_id;
}

_s.getmusic_name = function(){
	return _s._music_name;
}

_s.getplus = function(){
	return _s._plus;
}

_s.getwidth = function(){
	return _s._width;
}

_s.getheight = function(){
	return _s._height;
}

_s.getimages = function(){
	return _s._images;
}

_s.getcaption_fontsize = function(){
	return _s._caption_fontsize;
}

_s.getcaption_fontcolor = function(){
	return _s._caption_fontcolor;
}

_s.getcaption_bgcolor = function(){
	return _s._caption_bgcolor;
}

_s.getcaption_speed = function(){
	return _s._caption_speed;
}

_s.getcaption_mode = function(){
	return _s._caption_mode;
}

_s.getcaption_transparent = function(){
	return _s._caption_transparent;
}

//初始化程序开始
_s.setaleft = function(){
	_s.aLeft =parseInt((parseInt(window.screen.width)- parseInt(document.getElementById("drag_area").offsetWidth))*0.5);
	if(_s.aLeft<0){
		_s.aLeft = 0;
	}
}

_s.setObjWidth = function(){
	_s.ObjWidth = _s.aLeft + 15
}

_s.setinitWidth = function(){
	_s.initWidth = _s.ObjWidth;
}

_s.setdragHelper = function(){
	_s.dragHelper = document.getElementById("dragHelper");
}

_s.setup = function(){
	_s.setaleft();
	_s.setObjWidth();
	_s.setinitWidth();
	_s.setdragHelper();
}
//初始化程序结束

_s.getimagecounts = function(){
	return _s.dragObjs.length;
}

_s.aLeft = "";
_s.ObjWidth = ""; 
_s.initWidth = "";

_s.iii = 0;
_s.cols = 8;
_s.DragHeight = 30;
_s.drag_area_height = _s.DragHeight;
_s.dragContent = "";
_s.dragTitleValue = "";
_s.dragObjs = [];
_s.dragObjTops = [];
//_s.dragHelper = document.getElementById("dragHelper");

_s.dragHelper = "";

_s.dragObj = null;
_s.dragObjPos = 0;
_s.dragObjOffset = {left:0,top:0};
_s.mouseInDragObjOffset = {x:0,y:0};
_s.ObjHelght = 600;
_s.initHeight = _s.ObjHelght;

_s.setup_stepbystep = function(){
	_s.ObjHelght = 715;
	_s.initHeight = _s.ObjHelght;
}

Number.prototype.NaN0=function(){return isNaN(this)?0:this;}

//保存slide(修改)
_s.editslide_save = function(issave){
    _s.resetDragId();
	if(!issave){
		var _ajax = new ajax;
		var result = _ajax.StartRequest("./index.asp?action=checklogin","text","");
		if(result=="0"){
			et.login("2");
			return;
		}
	}
	et.modsaveslide();
	obj = document.modsaveslide;
	obj.method = "post";
	obj.slide_tmp_border.value = _s._border;
	obj.slide_tmp_style.value = _s._style;
	obj.slide_tmp_theme.value = _s._theme;
	obj.slide_tmp_music_id.value = _s._music_id;
	obj.slide_tmp_music.value = _s._music;
	obj.slide_tmp_background.value = _s._background;
	obj.slide_tmp_bgcolor.value = _s._bgcolor;
	obj.slide_tmp_play_mode.value = _s._play_mode;
	obj.slide_tmp_plus.value = _s._plus;
	obj.slide_tmp_caption_mode.value = _s._caption_mode;
	obj.slide_tmp_caption_transparent.value = _s._caption_transparent;
	obj.slide_tmp_caption_fontsize.value = _s._caption_fontsize;
	obj.slide_tmp_caption_fontcolor.value = _s._caption_fontcolor;
	obj.slide_tmp_caption_bgcolor.value = _s._caption_bgcolor;
	obj.slide_tmp_caption_speed.value = _s._caption_speed;
	obj.slide_tmp_images.value = _s._images;
	//alert(obj.slide_tmp_images.value);
	obj.slide_tmp_width.value = _s._width;
	obj.slide_tmp_height.value = _s._height;
	obj.action = "index.asp?action=editslide_save&moliheid="+_s._moliheid;
	obj.submit();

}

//取得COOKIE
_s.GetCookie = function (sName)
{
    // cookies are separated by semicolons
	//alert(document.cookie);
    var aCookie = document.cookie.split("; ");
    for (var i=0; i < aCookie.length; i++)
    {
        // a name alue pair (a crumb) is separated by an equal sign
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
        {
            return aCrumb[1];
        }
    }
	//alert(document.cookie);
    // a cookie with the requested name does not exist
    return null;
}

//保存slide
_s.makeslide_save = function(obj){
	if(obj.name.value==""){
		alert("请输入魔豆名称");
		obj.name.focus();
		return false;
	}
	var name = _s.trans(obj.name.value);
	var tags = _s.trans(obj.tags.value);
	//start
	if (obj.name.value.replace(/ /g,'').length ==0) {
		alert("请为您的相册添加一个名称");
		obj.name.value='';
		obj.name.focus();
		return false;
	}
	//end
	var share_set;
	if(obj.share_set['0'].checked){
		share_set = "1";
	}else{
		share_set = "0";
	}
	var cate="";
	for(var i=0;i<obj.cate.length;i++){
		if (obj.cate[i].checked){
			cate= obj.cate[i].value;
		}
	}
	if(cate==""){
		alert("请为你的相册选择一个类别");
		return false;
	}

	if(!_s._images){
		alert("您还没有添加图片，不能进行保存！");
		return false;
	}else{
		obj.method = "post";
		obj.slide_tmp_border.value = _s._border;
		obj.slide_tmp_style.value = _s._style;
		obj.slide_tmp_theme.value = _s._theme;
		obj.slide_tmp_music_id.value = _s._music_id;
		obj.slide_tmp_music.value = _s._music;
		obj.slide_tmp_background.value = _s._background;
		obj.slide_tmp_bgcolor.value = _s._bgcolor;
		obj.slide_tmp_play_mode.value = _s._play_mode;
		obj.slide_tmp_plus.value = _s._plus;
		obj.slide_tmp_caption_mode.value = _s._caption_mode;
		obj.slide_tmp_caption_transparent.value = _s._caption_transparent;
		obj.slide_tmp_caption_fontsize.value = _s._caption_fontsize;
		obj.slide_tmp_caption_fontcolor.value = _s._caption_fontcolor;
		obj.slide_tmp_caption_bgcolor.value = _s._caption_bgcolor;
		obj.slide_tmp_caption_speed.value = _s._caption_speed;
		obj.slide_tmp_images.value = _s._images;
		//alert(obj.slide_tmp_images.value);
		obj.slide_tmp_width.value = _s._width;
		obj.slide_tmp_height.value = _s._height;
		obj.action = "index.asp?action=makeslide_save";
		var o1 = document.getElementById("save_slide_form");
		var o2 = document.getElementById("save_progress");
		o1.style.display = "none";
		o1.style.visibility = "hidden";
		o2.style.textAlign = "center";
		o2.style.paddingTop = "30px";
		o2.style.paddingBottom = "30px";
		o2.style.display = "block";
		o2.style.visibility = "visible";

	}

}

//音乐设置区显示
_s.displaymusic = function(){
	_s.layer_effect_make('n');
	var _ajax = new ajax;
	if(_s._music==null || _s._music==""){
		var content = _ajax.StartRequest("./win/music.html","text","");
		document.getElementById("effect_area").innerHTML = content;
		document.getElementById("effect_title").innerHTML = "您现在选择的音乐是：<span class=\"fweight fff3300\">您还没有选择音乐</span>";
	}else{
		var content = _ajax.StartRequest("./win/music_s.html","text","");
		document.getElementById("effect_area").innerHTML = content;
		document.getElementById("effect_title").innerHTML = "您现在选择的音乐是：<span class=\"fweight fff3300\">"+_s._music_name+"</span> <a href=\"javascript:sl.del_music();\">删除音乐</a>";
	}
	_s.effectmenuset('4');
	_s._thiseffect_area = "music";
}

//选择预设音乐
_s.selectmusic = function(id,name,url){
	_s._music_id = id;
	_s._music_name = name;
	_s._music = url;
	_s.setcookie("slide_tmp_music",_s._music);
	_s.setcookie("slide_tmp_music_id",_s._music_id);
	_s.Flash_Reload();
	_s.displaymusic();
	et.closewin();
}

//选择第三方音乐的url
_s.set_music_url = function(obj){
    obj.value = obj.value.replace(/^\s+|\s+$/g,'');
	var httpsplit = obj.value.split("//");
	if(httpsplit[0]==httpsplit[1])
	{
		var httpvalue = httpsplit[httpsplit.length-1].split("/");
		//alert('您输入了两个http://');
		//obj.focus();
		//return; 
	} else {
		var httpvalue = httpsplit[httpsplit.length-1].split("/");
	}
	var m=0;
	for(var s=0;s<httpvalue.length;s++)
	{
		if(httpvalue[s]=='http:')
		{
			m++;
		}
	}
	var mp3value = httpvalue[httpvalue.length-1];
	var mp3split = mp3value.split(".");
    var mp3last = mp3split[mp3split.length-1];
	if(obj.value=="" || obj.value=="http://"|| mp3last!="mp3" || m>1){
		alert("请输入正确的url");
		obj.focus();
		return;
	}
	_s._music = obj.value;
	var u =obj.value.split("/");
	_s._music_id = 0;
	_s._music_name = u[u.length-1];
	_s.setcookie("slide_tmp_music",_s._music);
	_s.setcookie("slide_tmp_music_id",_s._music_id);
	_s.Flash_Reload();
	_s.displaymusic();
}

//删除音乐
_s.del_music = function(){
	if(confirm("重新选择将删除原有音乐并不可恢复\n\n您确定要重新选择吗？")){
		_s._music = "";
		_s._music_id = "";
		_s._music_name = "";
		_s.setcookie("slide_tmp_music",_s._music);
		_s.setcookie("slide_tmp_music_id",_s._music_id);
		_s.Flash_Reload();
		_s.displaymusic();
	}
}

//颜色选择器
_s.CreateColor = function(obj,t){
	if(document.getElementById("caption_color")){
		document.body.removeChild(document.getElementById("caption_color"));
	}
	var ps = _s.getoffset(obj);
	var left = ps.x;
	var top = ps.y+obj.offsetHeight+3;
	var oResult	= document.createElement('div');
	oResult.id = "caption_color";
	document.body.appendChild(oResult);
	oResult.style.position = "absolute";
	oResult.style.left = left + "px";
	oResult.style.top = top + "px";
	oResult.innerHTML = "<iframe align=\"center\" frameborder=\"0\" height=\"160\" width=\"300\" scrolling=\"no\" src=\"color.asp?t="+t+"\" name=\"color\"></iframe>";;
}

//设置字幕模式
_s.SetCaptionMode = function(v){
	_s._caption_mode = v;
	_s.setcookie("slide_tmp_caption_mode",_s._caption_mode);
	_s.Flash_Reload();
}

//设置字幕大小
_s.SetCaptionFontSize = function(v){
	_s._caption_fontsize = v;
	_s.setcookie("slide_tmp_caption_fontsize",_s._caption_fontsize);
	_s.Flash_Reload();
}

//设置字幕切换速度
_s.SetCaptionSpeed = function(v){
	_s._caption_speed = v;
	_s.setcookie("slide_tmp_caption_speed",_s._caption_speed);
	_s.Flash_Reload();
}

//设置字幕背静透明度
_s.SetCaptionTransparent = function(v){
	_s._caption_transparent = v;
	_s.setcookie("slide_tmp_caption_transparent",_s._caption_transparent);
	_s.Flash_Reload();
}

//设置字模颜色
_s.SetCaptionColor = function(t,color){
	//color = color.replace("#","0x");
	//alert(color);
	if(t=="font_color"){
		_s._caption_fontcolor = color.replace("#","0x");
		_s.setcookie("slide_tmp_caption_fontcolor",_s._caption_fontcolor);
	}
	if(t=="bg_color"){
		_s._caption_bgcolor = color.replace("#","0x");
		_s.setcookie("slide_tmp_caption_bgcolor",_s._caption_bgcolor);
	}
	if(t=="backgroundcolor"){
		_s._bgcolor = color.replace("#","0x");
		_s.setcookie("slide_tmp_bgcolor",_s._bgcolor);
		_s.seteffect_title("background");
	}
	_s.Flash_Reload();
	document.getElementById(t).style.backgroundColor = color;
	document.body.removeChild(document.getElementById("caption_color"));

}

_s.getoffset = function (obj){
	var xx,yy;
	for(xx=0,yy=0; obj!=document.body; xx+=obj.offsetLeft, yy+=obj.offsetTop, obj=obj.offsetParent);
	return {x:xx,y:yy};
}

//字幕设置
_s.displaycaption = function(){
	_s.layer_effect_make('y');
	var _ajax = new ajax;
	var content = _ajax.StartRequest("./win/caption.html","text","");
	document.getElementById("effect_area").innerHTML = content;
	document.getElementById("effect_title").innerHTML = "字幕效果设置";
	_s.effectmenuset('7');
	
	if(_s._caption_fontcolor==""){
		_s._caption_fontcolor = "0xffffff";
		
	}

	if(_s._caption_bgcolor==""){
		_s._caption_bgcolor = "0x000000";
	}
	//alert(_s._caption_fontcolor);
	//alert(_s._caption_fontcolor);
	document.getElementById("font_color").style.backgroundColor = _s._caption_fontcolor.replace("0x","#");
	document.getElementById("bg_color").style.backgroundColor = _s._caption_bgcolor.replace("0x","#");
	_s.SetSelectValue(document.getElementById("caption_mode"),_s._caption_mode);
	_s.SetSelectValue(document.getElementById("caption_transparent"),_s._caption_transparent);
	_s.SetSelectValue(document.getElementById("caption_speed"),_s._caption_speed);
	_s.SetSelectValue(document.getElementById("caption_fontsize"),_s._caption_fontsize);

	_s._thiseffect_area = "caption";
}

_s.SetSelectValue = function(obj,v){
	for(var i=0;i<obj.length;i++){
		if(obj.options[i].value==v){
			obj.options[i].selected = true;
			break;
		}
	}
}

//特效区样式处理
_s.effectmenuset = function(index){
	var obj = document.getElementById("effect_menu").getElementsByTagName("li");
	for(var i=0;i<obj.length;i++){
		if (i==parseInt(index)){
			obj[i].className = "xiu_06";
		}else{
			obj[i].className = "";
		}
	}
}

//选择特效
_s.selecteffect = function(obj){
	var iss = 0;
	if(obj){
		iss = 1;	
	}else{
		if(_s._thiseffect_area !="" && _s._thiseffect_area != "tc" && _s._thiseffect_area != "music" && _s._thiseffect_area != "caption"){
			iss = 1;
		}
	}
	if(iss==1){
		//alert(iss);
		var o = document.getElementById("effect_area").getElementsByTagName("div");
		
		for(var i=0;i<o.length;i++){
			o[i].className = "";
			//o[i].onclick = "sl.selecteffect(this);";
			o[i].onmouseover=function(){this.className='xiu_08_02';};
			o[i].onmouseout=function(){this.className='';};
			o[i].onclick=function(){sl.selecteffect(this)};
		}
		if(obj){
			obj.className = "xiu_08_01";
			obj.onmouseover = "";
			obj.onmouseout = "";
		}
	}
}

_s.layerseteffect = function(v){
	if(v == '1'){
		document.getElementById('play_mode_a').style.backgroundColor='#E8E8E8';
		document.getElementById('play_mode_a').style.border='1px solid';
		document.getElementById('play_mode_a').style.fontweight='bold';
		document.getElementById('play_mode_a_txt').style.color='#333';
		document.getElementById('play_mode_a_txt').style.fontweight='bold';
	} else {
		document.getElementById('play_mode_a').style.backgroundColor='#F9F9F9';
		document.getElementById('play_mode_a').style.border='1px solid #ededed';
		document.getElementById('play_mode_a').style.fontweight='normal';
		document.getElementById('play_mode_a_txt').style.color='#808080';
		document.getElementById('play_mode_a_txt').style.fontweight='normal';
	}
	if(v == '2'){
		document.getElementById('play_mode_b').style.backgroundColor='#E8E8E8';
		document.getElementById('play_mode_b').style.border='1px solid';
		document.getElementById('play_mode_b').style.fontweight='bold';
		document.getElementById('play_mode_b_txt').style.color='#333';
		document.getElementById('play_mode_b_txt').style.fontweight='bold';
	} else {
		document.getElementById('play_mode_b').style.backgroundColor='#F9F9F9';
		document.getElementById('play_mode_b').style.border='1px solid #ededed';
		document.getElementById('play_mode_b').style.fontweight='normal';
		document.getElementById('play_mode_b_txt').style.color='#808080';
		document.getElementById('play_mode_b_txt').style.fontweight='normal';
	}
	if(v == '3'){
		document.getElementById('play_mode_c').style.backgroundColor='#E8E8E8';
		document.getElementById('play_mode_c').style.border='1px solid';
		document.getElementById('play_mode_c').style.fontweight='bold';
		document.getElementById('play_mode_c_txt').style.color='#333';
		document.getElementById('play_mode_c_txt').style.fontweight='bold';
	} else {
		document.getElementById('play_mode_c').style.backgroundColor='#F9F9F9';
		document.getElementById('play_mode_c').style.border='1px solid #ededed';
		document.getElementById('play_mode_c').style.fontweight='normal';
		document.getElementById('play_mode_c_txt').style.color='#808080';
		document.getElementById('play_mode_c_txt').style.fontweight='normal';
	}
	if(v == '4'){
		document.getElementById('play_mode_d').style.backgroundColor='#E8E8E8';
		document.getElementById('play_mode_d').style.border='1px solid';
		document.getElementById('play_mode_d').style.fontweight='bold';
		document.getElementById('play_mode_d_txt').style.color='#333';
		document.getElementById('play_mode_d_txt').style.fontweight='bold';
	} else {
		document.getElementById('play_mode_d').style.backgroundColor='#F9F9F9';
		document.getElementById('play_mode_d').style.border='1px solid #ededed';
		document.getElementById('play_mode_d').style.fontweight='normal';
		document.getElementById('play_mode_d_txt').style.color='#808080';
		document.getElementById('play_mode_d_txt').style.fontweight='normal';
	}
	
}

//特效设置
_s.seteffect = function(t,v){
	switch(t){
		case 'border':
			_s._border = v;
			_s.setcookie("slide_tmp_border",_s._border);
			_s.Flash_Reload();
			break;
		
		case 'style':
			_s._style = v;
			_s.setcookie("slide_tmp_style",_s._style);
			_s.Flash_Reload();
			break;
		
		case 'theme':
			_s._theme = v;
			_s.setcookie("slide_tmp_theme",_s._theme);
			_s.Flash_Reload();
			break;
		
		case 'background':
			_s._background = v;
			_s.setcookie("slide_tmp_background",_s._background);
			_s.Flash_Reload();
			break;
		case 'bgcolor':
			document.getElementById("backgroundcolor").style.backgroundColor = v;
			_s._bgcolor = v;
			_s.setcookie("slide_tmp_bgcolor",_s._bgcolor);
			_s.Flash_Reload();
			break;
		case 'play_mode':
			_s._play_mode = v;
			_s.layerseteffect(v);
            if (v >= 2)
            {
                _s.displaymusic();
                //alert("现在是非幻灯片模式，您将只能设置音乐选项！");
            }
            else
            {_s.displaytc(group[0]);}
			_s.setcookie("slide_tmp_play_mode",_s._play_mode);
			_s.Flash_Reload();
			break;
			
		case 'play_mode_pre'://作品预览效果 yt
			_s._play_mode = v;
			_s.layerseteffect(v);
			_s.Flash_Reload_pre();
			break;
		
		case 'plus':
			_s._plus = v;
			_s.setcookie("slide_tmp_plus",_s._plus);
			_s.Flash_Reload();
			break;

		default:
			break;
	}
	if (t == "bgcolor"){
		t = "background"; 
	}
	_s.seteffect_title(t);
}

//套餐显示
_s.displaytc = function(groups){
	_s.layer_effect_make('n');
    _s.curtypeobj = groups;
	var effect_array = groups;
	var effect_area_content = "";	
	
	for(var i=0;i<effect_array.length;i++){
		if(effect_array[i].length > 8){   //新加立体套餐  数量大于8
			if(effect_array[i][8].length > 0){
				effect_area_content += "<div onmouseover=\"this.className='xiu_08_02';\" onmouseout=\"this.className='';\"><a href=\"javascript:sl.seteffect_stereo('"+effect_array[i][1]+"','"+effect_array[i][2]+"','"+effect_array[i][3]+"','"+effect_array[i][4]+"','"+effect_array[i][5]+"','"+effect_array[i][6]+"','"+effect_array[i][7]+"','"+effect_array[i][8]+"');\"><img src=\""+effect_array[i][0]+"\" width=\"60px\" height=\"60px\" /></a></div>";
			}else{
				effect_area_content += "<div onmouseover=\"this.className='xiu_08_02';\" onmouseout=\"this.className='';\"><a href=\"javascript:sl.seteffect_group('"+effect_array[i][1]+"','"+effect_array[i][2]+"','"+effect_array[i][3]+"','"+effect_array[i][4]+"','"+effect_array[i][5]+"','"+effect_array[i][6]+"','"+effect_array[i][7]+"');\"><img src=\""+effect_array[i][0]+"\" width=\"60px\" height=\"60px\" /></a></div>";
			}
		}else{
			effect_area_content += "<div onmouseover=\"this.className='xiu_08_02';\" onmouseout=\"this.className='';\"><a href=\"javascript:sl.seteffect_group('"+effect_array[i][1]+"','"+effect_array[i][2]+"','"+effect_array[i][3]+"','"+effect_array[i][4]+"','"+effect_array[i][5]+"','"+effect_array[i][6]+"','"+effect_array[i][7]+"');\"><img src=\""+effect_array[i][0]+"\" width=\"60px\" height=\"60px\" /></a></div>";
		}
	}

	document.getElementById("effect_area").innerHTML = effect_area_content;

    _s.seteffect_title('group');
	_s.effectmenuset("0");
	_s._thiseffect_area = "tc";
}

//取消效果
_s.delalleffect = function(){
	if(confirm("您确定要清除所有效果吗？")){
		_s._border = 0;
		_s._theme = 0;
		_s._style = 0;
		_s._background = 0;
		_s._plus = 0;
		_s._bgcolor = "";
		_s._music = "";
		_s._play_mode = 1;
		_s.Flash_Reload();
		_s.seteffect_title(_s._thiseffect_area);
		_s.selecteffect();
	}
}

//设置套餐效果
_s.seteffect_group = function(border,theme,style,background,plus,bgcolor,music){

		
	if(_s._sys_isalert==0){
		if(_s._sys_iseffect==1){
			if(confirm("魔豆提示您：选择套餐后，你之前选择的背景、边框、特效等设置会被覆盖\n\n确定要进行这个操作吗？[之后你仍可以单独更换背景，边框等设置]")){
				_s._sys_isalert= 1;
			}else{
				return;
			}
		}
	}

	_s._border = border;
	_s._theme = theme;
	_s._style = style;
    _s._play_mode = 1;
	_s._background = background;
	_s._plus = plus;
	_s._bgcolor = bgcolor;
	_s._music = music;
	_s.setcookie("slide_tmp_border",_s._border);
	_s.setcookie("slide_tmp_theme",_s._theme);
	_s.setcookie("slide_tmp_style",_s._style);
	_s.setcookie("slide_tmp_background",_s._background);
	_s.setcookie("slide_tmp_plus",_s._plus);
	_s.setcookie("slide_tmp_bgcolor",_s._bgcolor);
    _s.setcookie("slide_tmp_play_mode",_s._play_mode);
	_s.Flash_Reload();
	_s.seteffect_title(_s._thiseffect_area);
	_s.selecteffect();
}
//设置立体套餐效果
_s.seteffect_stereo = function(border,theme,style,background,plus,bgcolor,music,playmode){

		
	if(_s._sys_isalert==0){
		if(_s._sys_iseffect==1){
			if(confirm("魔豆提示您：选择套餐后，你之前选择的背景、边框、特效等设置会被覆盖\n\n确定要进行这个操作吗？[之后你仍可以单独更换背景，边框等设置]")){
				_s._sys_isalert= 1;
			}else{
				return;
			}
		}
	}

	_s._border = border;
	_s._theme = theme;
	_s._style = style;
    _s._play_mode = 1;
	if(playmode!='') _s._play_mode = playmode;
	_s._background = background;
	_s._plus = plus;
	_s._bgcolor = bgcolor;
	_s._music = music;
	_s.setcookie("slide_tmp_border",_s._border);
	_s.setcookie("slide_tmp_theme",_s._theme);
	_s.setcookie("slide_tmp_style",_s._style);
	_s.setcookie("slide_tmp_background",_s._background);
	_s.setcookie("slide_tmp_plus",_s._plus);
	_s.setcookie("slide_tmp_bgcolor",_s._bgcolor);
    _s.setcookie("slide_tmp_play_mode",_s._play_mode);
	_s.Flash_Reload();
	_s.seteffect_title(_s._thiseffect_area);
	_s.selecteffect();
}

//特效展示
_s.displayeffect = function(t,index,t_id){
	_s._sys_iseffect = 1;
	var effect_array;
	var effect_default;
	var effect_area_content = "";
	var effect_title = "";
	switch(t){
		case 'border':
			_s.layer_effect_make('y');
			effect_type = border_type;
			effect_array = border;
			effect_default = _s._border;
			break;
		
		case 'style':
			_s.layer_effect_make('y');
			effect_type = style_type;
			effect_array = style;
			effect_default = _s._style;
			break;
		
		case 'theme':
			_s.layer_effect_make('y');
			effect_type = theme_type;
			effect_array = theme;
			effect_default = _s._theme;
			break;
		
		case 'background':
			_s.layer_effect_make('n');
			effect_type = background_type;
			effect_array = background;
			effect_default = _s._background;
			break;
		
		case 'plus':
			effect_array = plus;
			effect_default = _s._plus;
			break;

		default:
			break;
	}


	_s.displaysubeffect(t, effect_array[t_id])
	_s.effectmenuset(index);
}

_s.displaysubeffect = function(type,t_array){
    _s.curtypeobj = t_array;
	var effect_area_content = '';
	var effect_default = _s['_'+type];
	for(var j=0,x=t_array.length;j<x;j++){
		if(t_array[j][0]==effect_default){
			effect_area_content += "<div class=\"xiu_08_01\"><a href=\"javascript:sl.seteffect('"+type+"','"+t_array[j][0]+"')\"><img src=\""+t_array[j][1]+"\" width=\"52px\" height=\"52px\" /></a></div>";
		}else{
			effect_area_content += "<div onclick=\"sl.selecteffect(this);\"; onmouseover=\"this.className='xiu_08_02';\" onmouseout=\"this.className='';\"><a href=\"javascript:sl.seteffect('"+type+"','"+t_array[j][0]+"')\"><img src=\""+t_array[j][1]+"\" width=\"52px\" height=\"52px\" /></a></div>";
		}
	}	
	document.getElementById("effect_area").innerHTML = effect_area_content;
	_s.seteffect_title(type);
	if(type=='plus') _s.effectmenuset('6');
	_s._thiseffect_area = type;
	if(type=='plus' || t_array == 'plus' ){_s.layer_effect_make('y');}
}

//设置效果区标题
_s.seteffect_title = function(t){
	var effect_title = "";
	var isset = 0;
    var s_style = "class=\"selected\" style=\"color: #ff6d00;\" ";
	switch(t){
        case 'group':
			isset = 1;
			effect_title = '选择套餐分类: ';
            for(var i=0; i<group_type.length;i++)
			{
               t_style = _s.curtypeobj == group[group_type[i][0]]?s_style:"";
			   effect_title +=" <a "+t_style+" href=\"javascript:sl.displaytc(group["+group_type[i][0]+"]);\">";
               effect_title +=group_type[i][1];
			   effect_title +="</a>";
			}
			if(window.stereo_type){
				for(var i=1; i<stereo_type.length;i++){
				   t_style = _s.curtypeobj == stereo[stereo_type[i][0]]?s_style:"";
				   effect_title +=" <a "+t_style+" href=\"javascript:sl.displaytc(stereo["+stereo_type[i][0]+"]);\">";
				   effect_title +=stereo_type[i][1];
				   effect_title +="</a>";
				}
			}

            break;
		case 'border':
			isset = 1;
			effect_title = _s._border && _s._border != "0" ? "<a href=\"javascript:sl.selecteffect();sl.seteffect('"+t+"','');\">取消边框</a>" : "请选择边框";
            for(var i=0; i<border_type.length;i++)
			{
               t_style = _s.curtypeobj == border[border_type[i][0]]?s_style:"";
			   effect_title +=" <a "+t_style+" href=\"javascript:sl.displaysubeffect('border',border["+border_type[i][0]+"]);\">";
               effect_title +=border_type[i][1];
			   effect_title +="</a>";
			}   
			break;
		
		case 'style':
			isset = 1;
			var str = " 播放速度: <select id=\"caption_speed\" name=\"caption_speed\" onchange=\"sl.SetCaptionSpeed(this.value);\">";
			str += "<option value=\"1\"";
			if(_s._caption_speed=="1"){str+=" selected";}
			str += ">最快</option>";
			str += "<option value=\"2\"";
			if(_s._caption_speed=="2"){str+=" selected";}
			str += ">快速</option>";
			str += "<option value=\"3\"";
			if(_s._caption_speed=="3" || _s._caption_speed==""){str+=" selected";}
			str += ">中速</option>";
			str += "<option value=\"4\"";
			if(_s._caption_speed=="4"){str+=" selected";}
			str += ">慢速</option>";
			str += "<option value=\"5\"";
			if(_s._caption_speed=="5"){str+=" selected";}
			str += ">最慢</option>";
			str += "</select>";
			effect_title = _s._style && _s._style != "0" ? "<a href=\"javascript:sl.selecteffect();sl.seteffect('"+t+"','');\">取消特效</a>" : "请选择特效: ";
            for(var i=0; i<style_type.length;i++)
			{
               t_style = _s.curtypeobj == style[style_type[i][0]]?s_style:"";
			   effect_title +=" <a "+t_style+" href=\"javascript:sl.displaysubeffect('style',style["+style_type[i][0]+"]);\">";
               effect_title +=style_type[i][1];
			   effect_title +="</a>";
			}
            effect_title += str;
			break;
		
		case 'theme':
			isset = 1;
			effect_title = _s._theme && _s._theme != "0" ? "<a href=\"javascript:sl.selecteffect();sl.seteffect('"+t+"','');\">取消装饰</a>" : "请选择装饰: ";
			for(var i=0; i<theme_type.length;i++)
			{
               t_style = _s.curtypeobj == theme[theme_type[i][0]]?s_style:"";
			   effect_title +=" <a "+t_style+" href=\"javascript:sl.displaysubeffect('theme',theme["+theme_type[i][0]+"]);\">";
               effect_title +=theme_type[i][1];
			   effect_title +="</a>";
			} 
			break;
		
		case 'background':
			isset = 1;
			var str = "<button onclick=\"sl.CreateColor(this,'backgroundcolor');\" type=\"button\" id=\"backgroundcolor\" style=\"border:1px solid #666666; width:80px; height:20px; background-color:"+_s._bgcolor.replace("0x","#")+"\"><img src=\"images/xg.gif\" style=\"float:right; margin:0; padding:0; width:19; height:18; border:0;\" /></button>";
			effect_title = _s._background && _s._background != "0" ? "<a href=\"javascript:sl.selecteffect();sl.seteffect('"+t+"','');\">取消背景图片</a> " : "";
			effect_title += _s._bgcolor && _s._bgcolor != "0" ? "<a href=\"javascript:sl.seteffect('bgcolor','');\">取消背景颜色</a> " : "";
			effect_title += "背景颜色："+str;
			for(var i=0; i<background_type.length;i++)
			{
               t_style = _s.curtypeobj == background[background_type[i][0]]?s_style:"";
			   effect_title +=" <a "+t_style+" href=\"javascript:sl.displaysubeffect('background',background["+background_type[i][0]+"]);\">";
               effect_title +=background_type[i][1];
			   effect_title +="</a>";
			} 
			break;
		
		case 'plus':
			isset = 1;
			effect_title = _s._plus && _s._plus != "0" ? "<a href=\"javascript:sl.selecteffect();sl.seteffect('"+t+"','');\">取消仿旧</a>" : "请选择仿旧效果";
			break;

		case 'music':
			_s.displaymusic();
			break;

		default:
			break;
	}
	if(isset==1){
		document.getElementById("effect_title").innerHTML = effect_title;
	}
}

//设置大小
_s.resize_set = function(){
	var f=document.resize;
	_s.checknum(f.width);
	_s.checknum(f.height);
	if(f.isy.checked==true){
		f.height.value = parseInt(f.width.value*3/4);
	}
	
}

//检测数字类型input
_s.checknum = function(obj){
	var v = obj.value;
	var str = "";
	for(var i=0;i<v.length;i++){
		var thisv = v.substr(i,1);
		if (!isNaN(thisv)){
			str += "" + thisv;
		}
	}
	obj.value = str;
}

//设置cookie
_s.setcookie = function(cookiename,cookievalue){
	//document.cookie = cookiename+"="+cookievalue;
	/*
	var postDate = "sessionname="+cookiename+"&sessionvalue="+cookievalue;
	var _ajax = new ajax;
	alert(_ajax.StartRequest_Post("./SetSession.asp","text",postDate,""));
	*/
}

//重新加载Flash
_s.Flash_Reload = function (){
	//alert(document.getElementById("flash_slide").innerHTML);
	var vars = _s.getvars();
	document.getElementById("flash_slide").innerHTML = _s.FlashPlayer(vars,_s.getplay_mode());
	music_button_status = 1;
	if(document.getElementById("music_pause_button")){
		document.getElementById("music_pause_button").value = "暂停播放";
	}
	//10:30 2008-6-17s
	//alert(hasClass(document.getElementById('makeslide'),'normal'));
	if(_s.dragObjs.length>=1) {
		document.getElementById('img_wrap').style.display='block';
		document.getElementById('make_pic').setAttribute('src','images/makeZHtjtp.gif');
		document.getElementById('save_pic').setAttribute('src','images/makeZHbc_on.gif');
	} else {
		
		document.getElementById('img_wrap').style.display='none';
		document.getElementById('make_pic').setAttribute('src','images/makeZHtjtp_on.gif');
		document.getElementById('save_pic').setAttribute('src','images/makeZHbc.gif');
	}
	//10:30 2008-6-17e
	
}

_s.Flash_Reload_pre = function (){
	//alert(document.getElementById("flash_slide").innerHTML);
	var vars = _s.getvars_pre();
	///////document.getElementById("flash_slide").innerHTML = _s.FlashPlayer_pre(vars,_s.getplay_mode());
	
}

_s.getvars_pre = function(){
	var vars = "moliheid="+_s._moliheid;
	vars += "&referer=7"+"&playmode="+_s._play_mode;
	//alert(vars);
	return vars;
}

//flash播放器2
_s.FlashPlayer_pre = function(vars,play_mode){
	var id = "mainFlash";
	var swf = "main.swf";
	var width = 416;
	var height = 312;
    switch(play_mode)
    {
        case '2':
        case '3':
        case '4':    
            swf = "main2.swf";
            break;
        default:
            swf = "main.swf";
            break;
        
    }	
	if (isIE && isWin && !isOpera){
		var str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'">'+'<param name="movie" value="'+myurl+'/'+swf+'" />'+'<param name="wmode" value="opaque" />'+'<param name="quality" value="high" />'+'<param name="scale" value="noscale" />'+'<param name="FlashVars" value="'+vars+'" /></object>';
	}else{
		var str = '<embed src="'+myurl+'/'+swf+'" flashvars="'+vars+'" quality="high" wmode="opaque" scale="noscale" width="'+width+'" height="'+height+'" id="'+id+'" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	}
	
	return str;
}

//Flash播放器
_s.FlashPlayer = function(vars,play_mode){
	var id = "mainFlash";
	var swf = "main.swf";
	var width = 416;
	var height = 312;
    switch(play_mode)
    {
        case '2':
        case '3':
        case '4':    
            swf = "main2.swf";
            break;
        default:
            swf = "main.swf";
            break;
        
    }	
	if (isIE && isWin && !isOpera){
		var str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'">'+'<param name="movie" value="'+swf+'" />'+'<param name="wmode" value="opaque" />'+'<param name="quality" value="high" />'+'<param name="scale" value="noscale" />'+'<param name="FlashVars" value="'+vars+'" /></object>';
	}else{
		var str = '<embed src="'+swf+'" flashvars="'+vars+'" quality="high" wmode="opaque" scale="noscale" width="'+width+'" height="'+height+'" id="'+id+'" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	}
	
	
	return str;
}



//获取元素相对文档的绝对位置
_s.getPosition = function (e){  
	var left = 0;
	var top  = 0;
	
	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e = e.offsetParent;
	}
	
 	left += e.offsetLeft;
 	top  += e.offsetTop;
	
	return {x:left, y:top};
}

//获取鼠标相对文档的绝对位置
_s.mouseCoords = function (ev){  
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
 		x:ev.clientX + document.getElementsByTagName("body").item(0).scrollLeft - document.getElementsByTagName("body").item(0).clientLeft,
		y:ev.clientY + document.getElementsByTagName("body").item(0).scrollTop  - document.getElementsByTagName("body").item(0).clientTop
	};
}

// 获取鼠标相对元素的相对位置
_s.getMouseOffset = function (target, ev){  
	ev = ev || window.event;
	var elementPos    = _s.getPosition(target);
	var mousePos  = _s.mouseCoords(ev);
	return {x:mousePos.x - elementPos.x, y:mousePos.y - elementPos.y};
}

//鼠标按下时
_s.mouseDown = function (ev){
	if(document.getElementById("caption_color")){
		document.body.removeChild(document.getElementById("caption_color"));
	}
	//alert(_s.aLeft);
	ev = ev || window.event;
	target = ev.srcElement || ev.target;

	if(_s.dragObj){
		return;
	}

	var dragArea = false;
	if(target.getAttribute("dragArea")){
		dragArea = true;
	}
	//dragArea = true;
 	while(!target.getAttribute("isDragObj")){
		if(target.tagName=="HTML")
			break;
  			target = target.parentNode;
 	}

	if(dragArea && target.getAttribute("isDragObj")){
		_s.dragObj = target;
		//重写的目的是让当前对象在最上层
	
		document.body.removeChild(_s.dragObj);
		document.body.appendChild(_s.dragObj);
	
		//记录下拖拽对象原始位置
		_s.dragObjOffset.left = _s.dragObj.style.left;
		_s.dragObjOffset.top = _s.dragObj.style.top;
		_s.dragContent = _s.dragObj.innerHTML;
		//alert(dragContent);
		_s.dragTitleValue = _s.dragObj.getElementsByTagName("input")['0'].value;
		//alert(dragObj.getElementsByTagName("input")['0'].value);
		_s.dragObj.innerHTML = "";
		_s.dragObj.className = _s.dragObj.getAttribute("overClass");
		//鼠标在拖拽对象中的相对位置
		_s.mouseInDragObjOffset = _s.getMouseOffset(_s.dragObj, ev);
		//alert(dragObj.offsetWidth);
		//alert(dragObj.offsetHeight);
		_s.dragHelper.style.left = _s.dragObj.style.left;
		_s.dragHelper.style.top = _s.dragObj.style.top;
		//alert(dragObj.offsetWidth);
		_s.dragHelper.style.width = parseInt(_s.dragObj.offsetWidth-4)+"px";
		_s.dragHelper.style.height = parseInt(_s.dragObj.offsetHeight-4)+"px";
		_s.dragHelper.style.display = "";
		_s.dragHelper.innerHTML = _s.dragContent;
		_s.dragHelper.getElementsByTagName("input")['0'].value = _s.dragTitleValue;

	//alert(dragObj.offsetWidth+":"+dragObj.clientWidth);
	}
}

//鼠标松开事件
_s.mouseUp = function (ev){
	ev = ev || window.event;
	target = ev.srcElement || ev.target;

	if(_s.dragObj){


        for(i=0; i<_s.dragObjs.length; i++){
            if(_s.dragObjs[i] == _s.dragObj){
                _s.dragId = i;
                break;
            }
        }

		_s.dragObj.style.left = _s.dragHelper.style.left;
		_s.dragObj.style.top = _s.dragHelper.style.top;

		_s.dragHelper.style.display = "none";
		_s.dragObj.className = _s.dragObj.getAttribute("dragClass");
		_s.dragObj.innerHTML = _s.dragContent;
		_s.dragObj.getElementsByTagName("input")['0'].value = _s.dragTitleValue;
		_s.dragObj = null;
		_s.setID();
		_s.setcookie("slide_tmp_images",_s.getimginfo());
		_s.Flash_Reload();
	}
}

//鼠标移动事件
_s.mouseMove = function (ev){
	ev = ev || window.event;

	if(_s.dragObj) {
		var mousePos = _s.mouseCoords(ev);
	  
		var windowWidth = document.getElementsByTagName("body").item(0).offsetWidth;  //窗口宽度
		var windowHeight = document.getElementsByTagName("body").item(0).offsetHeight;  //窗口高度
	
		//拖拽对象应该所在当前位置
		var dragObjLeft = mousePos.x - _s.mouseInDragObjOffset.x;
		var dragObjTop  = mousePos.y - _s.mouseInDragObjOffset.y;
	
		//增加判断，不然拖拽对象拖出浏览器窗口
		
		var maxleft = _s.ObjWidth + (_s.dragObj.offsetWidth + 10)*(_s.cols-1) + 10;

		if(dragObjLeft >= 0 && dragObjLeft < maxleft && dragObjLeft <= windowWidth - _s.dragObj.offsetWidth - 20 && dragObjLeft>_s.ObjWidth-10)
			_s.dragObj.style.left = dragObjLeft+"px";

		if(dragObjTop >=0 && dragObjTop>_s.ObjHelght-5 && dragObjTop<_s.initHeight+5)
			_s.dragObj.style.top = dragObjTop+"px";

		_s.repaint();
	}
}

//克隆对象
_s.cloneObject = function (srcObj, destObj){
	destObj = srcObj.cloneNode(true);
}

//设置可拽区域
_s.makeDraggable = function (element){
	element.setAttribute("isDragObj", "y");
}

//处理拖拽换位
_s.repaint = function (){
	for(i=0; i<_s.dragObjs.length; i++){
		if(_s.dragObjs[i] == _s.dragObj){
			_s.dragObjPos = i;
			_s.dragObjs[i] = _s.dragHelper;
			break;
		}
	}
 
	if(_s.dragObjPos>0 && _s.dragObjPos % _s.cols !=  0 && parseInt(_s.dragObj.style.left.replace("px",""))<parseInt(_s.dragObjs[_s.dragObjPos-1].style.left.replace("px",""))){
		_s.dragObjs[_s.dragObjPos] = _s.dragObjs[_s.dragObjPos-1];
		_s.dragObjs[_s.dragObjPos-1] = _s.dragHelper;
		_s.dragObjPos = _s.dragObjPos - 1;
	}
 
	if(_s.dragObjPos<_s.dragObjs.length-1 && (_s.dragObjPos+1) % _s.cols !=  0 && parseInt(_s.dragObj.style.left.replace("px",""))>parseInt(_s.dragObjs[_s.dragObjPos+1].style.left.replace("px",""))){
		_s.dragObjs[_s.dragObjPos] = _s.dragObjs[_s.dragObjPos+1];
		_s.dragObjs[_s.dragObjPos+1] = _s.dragHelper;
		_s.dragObjPos = _s.dragObjPos + 1;
	}
 
	if(_s.dragObjPos>_s.cols-1 && parseInt(_s.dragObj.style.top.replace("px",""))<parseInt(_s.dragHelper.style.top.replace("px",""))-parseInt(_s.dragHelper.offsetHeight)){

		for(var j=0;j<_s.cols;j++){
			_s.dragObjs[_s.dragObjPos-j] = _s.dragObjs[_s.dragObjPos-j-1];
		}
		_s.dragObjs[_s.dragObjPos-_s.cols] = _s.dragHelper;
		_s.dragObjPos = _s.dragObjPos -_s. cols;
	}

	if(_s.dragObjPos<_s.dragObjs.length-_s.cols && parseInt(_s.dragObj.style.top.replace("px",""))>parseInt(_s.dragObjs[_s.dragObjPos+_s.cols].style.top.replace("px",""))){
  		//dragObjs[dragObjPos] = dragObjs[dragObjPos+cols];
		for(var j=0;j<_s.cols;j++){
  			_s.dragObjs[_s.dragObjPos+j] = _s.dragObjs[_s.dragObjPos+j+1];
		}
		_s.dragObjs[_s.dragObjPos+_s.cols] = _s.dragHelper;
		_s.dragObjPos = _s.dragObjPos + _s.cols;
	}
	_s.paintDragObjs();
	_s.dragObjs[_s.dragObjPos] = _s.dragObj;
}

//重新定位
_s.paintDragObjs = function(){
	_s.initHeight = _s.ObjHelght;
	_s.initWidth = _s.ObjWidth;
	_s.iii = 0;
	_s.drag_area_height = _s.DragHeight
	for(i=0; i<_s.dragObjs.length; i++){
		if(_s.iii==0){
			_s.drag_area_height += _s.dragObjs[i].offsetHeight + 10;
		}
		_s.iii++;
		_s.dragObjs[i].style.left = _s.initWidth+"px";
		_s.dragObjs[i].style.top = _s.initHeight+"px";
		//alert(dragObjs[i].getElementsByTagName("input")['0'].value);
		if(_s.iii==_s.cols){
			_s.iii = 0;
			_s.initWidth = _s.ObjWidth;
			_s.initHeight += _s.dragObjs[i].offsetHeight + 10;
		}else{
			_s.initWidth += _s.dragObjs[i].offsetWidth + 10;
		}
	}
	document.getElementById("drag_area").style.height = _s.drag_area_height+"px";
}

//关闭
_s.openClose = function (obj){
	obj.innerHTML = obj.innerHTML=="-"?"+":"-";
	while(obj.tagName != "TBODY"){
		obj = obj.parentNode;
	}

	for(i=0; i<obj.childNodes.length; i++){
		if(obj.childNodes[i].nodeName == "#text" || obj.childNodes[i].getAttribute("bar")){
			continue;
		}
		obj.childNodes[i].style.display=obj.childNodes[i].style.display==""?"none":"";
	}

	_s.paintDragObjs();
}

//添加图片
_s.addpicurl = function (obj){
	var s = obj.elements;
    _s.setDragId();
    alert(_s.dragId);
	for(var i=0;i<s.length;i++){
		if(s[i].type=="text" && s[i].value != ""){
			_s.addphoto("",s[i].value,"1");
		}
	}
	et.closewin();
}

//删除所有字模
_s.delallfonts = function (){
	if(!confirm("您确定要删除所有字幕吗？")){
		return;
	}
    _s.dragId = 0;
	for(var i=0; i<_s.dragObjs.length; i++){
		var obj = _s.dragObjs[i].getElementsByTagName("input");
		obj['0'].value = "";
	}
	_s.setcookie("slide_tmp_images",_s.getimginfo());
	_s.Flash_Reload();
}

//删除所有图片
_s.delallphotos = function (){
	if(!confirm("您确定要删除所有图片吗？")){
		return;
	}
	for(var i=0; i<_s.dragObjs.length; i++){
		var obj = _s.dragObjs[i];
		document.body.removeChild(obj);
		obj = null;
	}
    _s.dragId = 0;
	_s.dragObjs.length = 0;
	_s.initHeight = _s.ObjHelght;
	_s.initWidth = _s.ObjWidth;
	_s.iii = 0;
	_s.drag_area_height = _s.DragHeight;
	document.getElementById("drag_area").style.height = _s.drag_area_height+"px";
	_s.setcookie("slide_tmp_images",_s.getimginfo());
	_s.Flash_Reload();
}

_s.setcaption = function(){
	_s.setcookie("slide_tmp_images",_s.getimginfo());
	_s.Flash_Reload();
}

//获取拖拽区图片信息
_s.getimginfo = function (){
	var str = "";
    var loopit = (_s.dragObjs.length > 0);
    var i = _s.dragId;
    while(loopit){
		var obj = _s.dragObjs[i].getElementsByTagName("input");
		var thisimg = _s.trans(obj['0'].value)+"{p}"+obj['1'].value+"{p}"+obj['2'].value;
		if(str != ""){
			str += "{img}";
		}
		str += thisimg;
        i++;
        if(i >= _s.dragObjs.length){i=0;}
        loopit = (i != _s.dragId);
    }
	_s._images = str;
	//alert(_s._images);
	return str;
}

//上传Flash返回请求
_s.FlashUpload = function (files,isclose){
    _s.setDragId();
	for(var i=0;i<files.length;i++){
		_s.addphoto(files[i]['1'],files[i]['0'],"1");
	}
	if(isclose=="1"){
		et.closewin();
		_s.setcookie("slide_tmp_images",_s.getimginfo());
		_s.Flash_Reload();
	}
	
}

//删除一个图片
_s.delphoto = function (ev){
	if(!confirm("您确定要删除这个图片吗？此操作不可恢复！")){
		return;
	}
    _s.dragId = 0;
	var dragArea = false;
	
	ev = ev || window.event;
	obj = ev.srcElement || ev.target;

 	while(!obj.getAttribute("isDragObj")){
		if(obj.tagName=="HTML")
			break;
  			obj = obj.parentNode;
 	}
	
	for(i=0; i<_s.dragObjs.length; i++){
		if(_s.dragObjs[i] == obj){
			var Di = i;
			break;
		}
	}
	for(i=Di;i<_s.dragObjs.length-1;i++){
		j = i + 1;
		_s.dragObjs[i] = _s.dragObjs[j];
	}
	_s.dragObjs.length -= 1;
	var img = obj.getElementsByTagName("input")['1'].value;
	var _ajax = new ajax;
	var content = _ajax.StartRequest("/get/_.asp?action=delimg&url="+img,"text",'');
	//dragObjs.remove(obj);
	document.body.removeChild(obj);
	_s.paintDragObjs();
	_s.setID();
	_s.setcookie("slide_tmp_images",_s.getimginfo());
	_s.Flash_Reload();
	
}
//start 对ajax的更改，同步形式该成异步。这几个都是新增的函数，对原来的流程不会有影响。--zyt
z_content = '';//一个全局变量在ajax.js文件下会用到
cur_photo_z = 0;
total_photo_z = 0;
_s.request_addphoto = function(title,url,type,url2) {
	if(-1 == url.indexOf(my_url)){
		var _ajax = new ajax;
        var content = _ajax.StartRequest(myurl+"/get/_.asp?action=getnet&url="+url,"text",function() {
			_s.z_addphoto(title,url,type,url2);
			
			count--;
		}); 
    }
    else
    {
		var content = url;
    }
	
}

//添加一个图片，新增的ajax基础上的addphoto
_s.z_addphoto = function (title,url,type,url2){
	if(z_content=='') {
		total_photo_z--;
		if(cur_photo_z == total_photo_z){
			et.closewin();
		}
		return;
	}
    if(url2==undefined || url2=='') url2 = z_content;
    title = title!="" ? title : "请输入字幕";
	var obj	= document.createElement('div');
	obj.className = "normal";
	//obj.setAttribute("class","normal");
	obj.setAttribute("overClass","over");
	obj.setAttribute("dragClass","normal");
	document.body.appendChild(obj);
	var str = "<div class=\"dragArea dArea\" dragArea=\"yes\">";
	str += "<span dragArea=\"yes\" class=\"float_left xiu_13\">第1张</span><span class=\"float_right\"><a href=\"javascript:sl.delphoto(this);\" class=\"xiu_12\">&nbsp;</a></span>";
	str += "</div>";
	str += "<div dragArea=\"yes\" class=\"dArea\"><img dragArea=\"yes\" align=\"center\" src=\""+url2+"\" width=\"85px\" height=\"80px\" class=\"border_01 dArea\" /></div>";
	str += "<div class=\"xiu_14\"><input type=\"text\" name=\"title\" value=\""+title+"\" onclick=\"this.focus();\" onblur=\"sl.setcaption();\" onfocus=\"sl.checkcaption(this);\"><input type=\"hidden\" name=\"url\" value=\""+z_content+"\"><input type=\"hidden\" name=\"type\" value=\""+type+"\"></div>";
	
	obj.innerHTML=str;
	_s.makeDraggable(obj);
	_s.dragObjs.push(obj);
	if(_s.iii==0){
		_s.drag_area_height += obj.offsetHeight + 10;
		document.getElementById("drag_area").style.height = _s.drag_area_height+"px";
	}
	_s.iii++;
	//start
	var MaskHeight = document.getElementsByTagName("body").item(0).scrollHeight;
	if(MaskHeight<window.screen.height)
		MaskHeight = window.screen.height;
	var MaskWidth = window.screen.width - 21;
	document.getElementById("divPageMask").style.width = MaskWidth+"px";
	document.getElementById("divPageMask").style.height = MaskHeight+"px";	
	cur_photo_z++;
	if (cur_photo_z==1) {
		document.getElementById('help_note').style.display='none';
		document.getElementById('container_photo').style.display='block';
		// et.closewin();
	}
	document.getElementById('cur_photo').innerHTML = cur_photo_z;
	document.getElementById('total_count').innerHTML = total_photo_z;
	if(cur_photo_z ==total_photo_z) {
		et.closewin();
	}
	//end
//if(total_photo)
	obj.style.left = _s.initWidth+"px";
	obj.style.top = _s.initHeight+"px";
	var j = _s.dragObjs.length;
	obj.getElementsByTagName("span")['0'].innerHTML = "第"+j+"张";
	//alert(item.style.left);
	_s.dragObjTops.push(_s.initHeight);
	if(_s.iii==_s.cols){
		_s.initHeight += obj.offsetHeight + 10;
		_s.initWidth = _s.ObjWidth;
		_s.iii = 0;
	}else{
		_s.initWidth += obj.offsetWidth + 10;
	}
	//_s.setcookie("slide_tmp_images",sl.getimginfo());//这两行是元元加的
	document.cookie = "slide_tmp_images = "+_s.getimginfo();
	_s.Flash_Reload();
}
//end

//添加一个图片
_s.addphoto = function (title,url,type,url2){
    if(-1 == url.indexOf(my_url)){
        var _ajax = new ajax;
        var content = _ajax.StartRequest(myurl+"/get/_.asp?action=getnet&url="+url,"text","");
    }
    else
    {
        var content = url;
    }
    if(url2==undefined || url2=='') url2 = content;
    title = title!="" ? title : "请输入字幕";
	var obj	= document.createElement('div');
	obj.className = "normal";
	//obj.setAttribute("class","normal");
	obj.setAttribute("overClass","over");
	obj.setAttribute("dragClass","normal");
	document.body.appendChild(obj);
    
	var str = "<div class=\"dragArea dArea\" dragArea=\"yes\">";
	str += "<span dragArea=\"yes\" class=\"float_left xiu_13\">第1张</span><span class=\"float_right\"><a href=\"javascript:sl.delphoto(this);\" class=\"xiu_12\">&nbsp;</a></span>";
	str += "</div>";
	str += "<div dragArea=\"yes\" class=\"dArea\"><img dragArea=\"yes\" align=\"center\" src=\""+url2+"\" width=\"85px\" height=\"80px\" class=\"border_01 dArea\" /></div>";
	str += "<div class=\"xiu_14\"><input type=\"text\" name=\"title\" value=\""+title+"\" onclick=\"this.focus();\" onblur=\"sl.setcaption();\" onfocus=\"sl.checkcaption(this);\"><input type=\"hidden\" name=\"url\" value=\""+content+"\"><input type=\"hidden\" name=\"type\" value=\""+type+"\"></div>";
	obj.innerHTML=str;
	_s.makeDraggable(obj);
	_s.dragObjs.push(obj);
	if(_s.iii==0){
		_s.drag_area_height += obj.offsetHeight + 10;
		document.getElementById("drag_area").style.height = _s.drag_area_height+"px";
	}
	_s.iii++;
	obj.style.left = _s.initWidth+"px";
	obj.style.top = _s.initHeight+"px";
	var j = _s.dragObjs.length;
	obj.getElementsByTagName("span")['0'].innerHTML = "第"+j+"张";
	//alert(item.style.left);
	_s.dragObjTops.push(_s.initHeight);
	if(_s.iii==_s.cols){
		_s.initHeight += obj.offsetHeight + 10;
		_s.initWidth = _s.ObjWidth;
		_s.iii = 0;
	}else{
		_s.initWidth += obj.offsetWidth + 10;
	}

}

//排序
_s.setID = function (){
	for(var i=0; i<_s.dragObjs.length; i++){
		var j = i + 1;
		_s.dragObjs[i].getElementsByTagName("span")['0'].innerHTML = "第"+j+"张";
	}
}

//转义特殊字符
_s.trans = function(str){
	str = str.replace(/&/g,"asc(38)");
	str = str.replace(/#/g,"asc(35)");
	str = str.replace(/\|/g,"asc(124)");
	str = str.replace(/\"/g,"asc(34)");
	str = str.replace(/\'/g,"asc(39)");
	str = str.replace(/%/g,"asc(37)");
	return str;
}

_s.trans_s = function(str){
	str = str.replace(/asc\(38\)/g,"&");
	str = str.replace(/asc\(35\)/g,"#");
	str = str.replace(/asc\(124\)/g,"|");
	str = str.replace(/asc\(34\)/g,"\"");
	str = str.replace(/asc\(39\)/g,"'");
	str = str.replace(/asc\(37\)/g,"%");
	return str;
}

//检测字幕
_s.checkcaption = function(obj){
	obj.value = obj.value == "请输入字幕" ? "" : obj.value;
}

_s.getvars = function(){
	var vars = "ispreview=1";
	vars += "&border="+_s._border;
	vars += "&theme="+_s._theme;
	vars += "&style="+_s._style;
	vars += "&background="+_s._background;
	vars += "&bgcolor="+_s._bgcolor;
	vars += "&playmode="+_s._play_mode;
	vars += "&plus="+_s._plus;
	vars += "&music="+_s._music;
	vars += "&caption_mode="+_s._caption_mode;
	vars += "&caption_speed="+_s._caption_speed;
	vars += "&caption_transparent="+_s._caption_transparent;
	vars += "&caption_fontsize="+_s._caption_fontsize;
	vars += "&caption_fontcolor="+_s._caption_fontcolor;
	vars += "&caption_bgcolor="+_s._caption_bgcolor;
	vars += "&"+_s.getimgvars();
	
	//alert(vars);

	return vars;
}


_s.resetDragId = function(){
    _s.dragId = 0;
    _s.getimginfo();
}
_s.setDragId = function(){
    _s.dragId = _s.dragObjs.length;
}

_s.getimgvars = function(){
	var imagelist = _s.trans_s(_s._images);
	imagelist = imagelist.replace(/\"/g,"&#34");
	var imginfo = imagelist.split("{img}");
	var imgcount = imagelist ? imginfo.length : 0;
	var vars = "imgcount="+imgcount;
	for(var i=0;i<imgcount;i++){
		vars += "&img"+i+"="+imginfo[i];
	}
	
	return vars;
}

//2008-7-23 13:33:02s
_s.layer_effect_make = function(v){
	document.getElementById('layer_effect_make').className = 'displayN';
	if(v == 'y'){if(_s._play_mode > 1){document.getElementById('layer_effect_make').className = 'layer_effect_make';}}
}
//2008-7-25 10:07:57s
_s.playmodelayer = function(v){
	_s.layer_effect_make('n');
	_s._play_mode = v;
	_s.layerseteffect(v);
	_s.setcookie("slide_tmp_play_mode",_s._play_mode);
	_s.Flash_Reload();
}