var addExtMedia = {
noImg : '',
yesImg : '',
wpspinImg : '',
tag:'',
setImgIcon : function(noImg,yesImg,wpspinImg){
	var t = addExtMedia;
	t.noImg=noImg;
	t.yesImg=yesImg;
	t.wpspinImg=wpspinImg;
},
themeSelectMediaFromUrl : function (){
	var t = this;
	var f = document.forms[0];
	if ( '' == f.href.value || ''==t.type)
		return false;
	if ( '' == f.title.value)
		return false;
	src =  f.href.value;
	title = f.title.value;
	type = t.type;
	var win = window.dialogArguments || opener || parent || top;
	win.themeSetMediaData(src,title,type,'url');
	win.tb_remove();
	return false;
},
themeResetMediaData : function (){
	var t = addExtMedia;
	t.type = '';
	document.getElementById('go_button').style.color = '#bbb';
		if ( ! document.forms[0].href.value )
			document.getElementById('status_img').innerHTML = '*';
		else document.getElementById('status_img').innerHTML = '<img src="'+t.noImg+'" alt="" />';
},
themeUploadMediaData :function (){
	var t = addExtMedia;
	t.type = 'image';
	document.getElementById('go_button').style.color = '#333';
	document.getElementById('status_img').innerHTML = '<img src="'+t.yesImg+'" alt="" />';
},
themeResetImageData :function (){
	var t = addExtMedia;
	src = document.forms[0].href.value;
	var res=src.split('.');
	if(res[res.length-1]=='swf'){
		t.type = 'video';
		document.getElementById('go_button').style.color = '#333';
		document.getElementById('status_img').innerHTML = '<img src="'+t.yesImg+'" alt="" />';
	}
	else{
		
		t.themeResetMediaData();
	}
},
themeGetMediaData :function (noImg,yesImg,wpspinImg){
	var t=addExtMedia;
	t.noImg=noImg;
	t.yesImg=yesImg;
	t.wpspinImg=wpspinImg;
	src = document.forms[0].href.value;
	if ( ! src ) {
		t.themeResetMediaData();
		return false;
	}
	document.getElementById('status_img').innerHTML = '<img src="'+t.wpspinImg+'" alt="" />';
	t.preloadImg = new Image();
	t.preloadImg.onload = t.themeUploadMediaData;
	t.preloadImg.onerror = t.themeResetImageData;
	t.preloadImg.src = src;

}
};
function themeSendMediaData(media,title,type){
	var win = window.dialogArguments || opener || parent || top;
	win.themeSetMediaData(media,title,type,'form');
	win.tb_remove();
	return false;
}
