var FilePathObj;
var IsImagePath=false;
var SourceServerID=0;
var SourceFilePath;
function OnPathChange(url){
if(window.parent.ServerIDs&&url!=""){
for(var i=0;i<window.parent.ServerIDs.length;++i){
if(window.parent.ServerIDs[i]&&url.indexOf(window.parent.ServerIDs[i][1])>-1){
SourceServerID=window.parent.ServerIDs[i][0];
SourceFilePath=url.replace(window.parent.ServerIDs[i][1],"");
$("tosource").disabled=false;
return;
}
}
}
SourceServerID=window.parent.ImageServerID;
SourceFilePath=null;
$("tosource").disabled=true;
}


function SelectImagePath(obj,defaultMaxImageWidth,defaultMaxImageHeight,defaultWatermarkMode,isToSourceFile){
FilePathObj=obj;
IsImagePath=true;
var url;
if(isToSourceFile){
url="../../../../listfile.ashx?siteid=" + window.parent.SiteID + "&serverid=" + SourceServerID + "&path=" + SourceFilePath.substring(0,SourceFilePath.lastIndexOf("/") + 1) + "&filepath=" + SourceFilePath;
}
else{
url="../../../../listfile.ashx?siteid=" + window.parent.SiteID + "&serverid=" + window.parent.ImageServerID;
}
url+="&height=265&extension=.gif,.jpg,.jpeg,.bmp,.png";
if(defaultMaxImageWidth){
url+="&maximagewidth="+defaultMaxImageWidth;
}
if(defaultMaxImageHeight){
url+="&maximageheight="+defaultMaxImageHeight;
}
if(defaultWatermarkMode){
url+="&watermarkmode="+defaultWatermarkMode;
}
else{
url+="&watermarkmode=1";
}
var content="<iframe src=\""+url+"\" frameborder=\"0\" scrolling=\"no\" width=\"100%\" height=\"100%\"></iframe>";
EasyMask.init({ width: document.documentElement.clientWidth-10 > 705 ? 705 : document.documentElement.clientWidth-10, height: 440, padding:"0", title: '选取图片文件', detail: content, padding:'0'});
}

function SelectMediaPath(obj,isToSourceFile){
FilePathObj=obj;
IsImagePath=false;
var url;
if(isToSourceFile){
url="../../../../listfile.ashx?siteid=" + window.parent.SiteID + "&serverid=" + SourceServerID + "&filepath=" + SourceFilePath;
}
else{
url="../../../../listfile.ashx?siteid=" + window.parent.SiteID + "&serverid=" + window.parent.MediaServerID;
}
url+="&height=265&extension=.swf,.flv,.asf,.wmv,.mpeg,.wma,.mp3&watermarkmode="+window.parent.DefaultWatermarkMode;
var content="<iframe src=\"" + url + "\" frameborder=\"0\" scrolling=\"no\" width=\"100%\" height=\"100%\"></iframe>";
EasyMask.init({ width: document.documentElement.clientWidth-10 > 705 ? 705 : document.documentElement.clientWidth-10, height: 440, padding:"0", title: '选取音视频文件', detail: content, padding:'0'});
}

function SelectOtherPath(obj,isToSourceFile){
FilePathObj=obj;
IsImagePath=false;
var url;
if(isToSourceFile){
url="../../../../listfile.ashx?siteid=" + window.parent.SiteID + "&serverid=" + SourceServerID + "&filepath=" + SourceFilePath;
}
else{
url="../../../../listfile.ashx?siteid=" + window.parent.SiteID + "&serverid=" + window.parent.OtherServerID;
}
url+="&height=265&watermarkmode="+window.parent.DefaultWatermarkMode;
var content="<iframe src=\"" + url + "\" frameborder=\"0\" scrolling=\"no\" width=\"100%\" height=\"100%\"></iframe>";
EasyMask.init({ width: document.documentElement.clientWidth-10 > 705 ? 705 : document.documentElement.clientWidth-10, height: 440, padding:"0", title: '选取文件', detail: content, padding:'0'});
}

function FileSelected(path,url){
EasyMask.close();
FilePathObj.value=url;
if(IsImagePath){
FilePathObj.focus();
}
FilePathObj.focus();
}