<?php
//选择Logo样式 
if(file_exists('output/chooselogo.jpg'))
{
	list($width, $height, $type, $attr) = getimagesize("output/chooselogo.jpg");
	$pic_html = <<<pic
<div id="show_logo" style="background:#f6f6f6;padding-top:10px;padding-bottom:10px;"><img id="show_img" src="output/chooselogo.jpg"/><span>宽*高:{$width}px*{$height}px</span></div>
pic;
}
else
{
	$pic_html = <<<pic
<div style="display:none;" id="show_logo"><img id="show_img" src=""/></div>	
pic;
}

$logo_message = simplexml_load_file('SitestarMaker.xml');
if(empty($logo_message->choose_logo->logo_name))
{
	$load_pic = '<img width="100" height="100" src="http://image.sitestar.cn/logo/6.jpg"/>';
}
else
{
	$load_pic = "<img width='100' height='100' src='{$logo_message->choose_logo->logo_name}'/>";
}

$js = <<<js
<link rel="stylesheet" href="css/colorpicker.css" type="text/css" />
<script type="text/javascript" src="../../script/colorpicker.js"></script>
<script type="text/javascript" src="../../script/helper.js"></script>
<script type="text/javascript" src="../../script/thickbox.js"></script>
<script type="text/javascript">
function showColor(src)
{
	$('#'+src).ColorPicker({
		onSubmit: function(hsb, hex, rgb, el) {
			colorValue = '#'+hex;
    		$(el).val(colorValue);
    		$(el).ColorPickerHide();
		},
		onBeforeShow: function () {
    		$(this).ColorPickerSetColor(this.value);
    	}
	}).bind('keyup', function(){
    	$(this).ColorPickerSetColor(this.value);
    });
}

function ajaxSend()
{
	$.ajax({
	   type: "POST",
	   url: "server.php",
	   data: {id:"chooseLogo",logo_text:$("#logo_text").attr("value"),logo_color:$("#logo_color").attr("value"),font_family:$("#font_family").attr('value'),font_size:$("#font_size").attr('value')},
	   beforeSend:function(msg){
	   		$("#show_logo").css('display','block');
	   		$("#show_img").remove();
			$("#show_logo").append("<img id='show_img' src='images/loadingAnimation.gif'/>");
		},
	   success: function(msg){
	   		if(msg.substr(0,6) == 'notice')
	   		{
	   			msg = msg.substring(6);
	   			$('#notice').empty();
	   			$('#notice').css('display','block').append(msg);
	   			$("#show_logo").remove();
	   		}
	   		else
	   		{
				window.location.reload();
			}
   	   },
   	   error: function(msg){
   	   	 	alert(msg);
   	   }
	});
}

function validate(oNum)
{
	if(!oNum)
	{ 
		$('#font_size').attr('value','');
		return false; 
	}
  	var strP=/^\d+(\.\d+)?$/; 
  	if(!strP.test(oNum)) 
  	{
		$('#font_size').attr('value',''); 
		return false; 
	}
  	try
  	{ 
  		if(parseFloat(oNum)!=oNum)
		{
			$('#font_size').attr('value','');
  			return false;
  		}
  	} 
  	catch(ex) 
  	{ 
  	 	$('#font_size').attr('value','');
  		return false;
  	} 
  	return true; 
}
</script>
<link rel="stylesheet" type="text/css" href="../../script/thickbox.css" />
js;

$html = <<<html
<div style="text-align:left;font-size:18px;font-family:'microsoft yahei';color:#006ec6;">挑选喜欢的图片</div>
<div class="tabstyle"></div>
<div class="divsettings">	
	<table cellspacing="10" cellpadding="5" width="100%" border="0">
		<tbody>
			<tr>
				<td valign="top" nowrap><span><input type="button" value="选择Logo" onclick="show_iframe_win('LogoPopup.php?page=1', '', 732, 503);"/></span></td>
				<td>
					<div class="tdstyle">
                    	$load_pic
                    </div>
				</td>
			</tr>
			<tr>
				<td valign="top" nowrap><span>Logo文本:</span></td>
				<td>
					<div class="tdstyle">
                    	<input name="logo_text" type="text" value="cndns" id="logo_text"  style="width:125px;" maxlength="12"/>
                    </div>
				</td>
			</tr>
			<tr>
				<td valign="top" nowrap><span>文本颜色:</span></td>
				<td>
					<div class="tdstyle">
                    	<input onclick="showColor('logo_color');" onkeyup="$(this).attr('value','');" name="logo_color" type="text" value="#000000" id="logo_color"  style="width:125px;" maxlength="12"/>
                    </div>
				</td>
			</tr>
			<tr>
				<td valign="top" nowrap><span>文字大小:</span></td>
				<td>
					<div class="tdstyle">
                    	<input onkeyup="validate($(this).attr('value'));" name="font_size" type="text" value="12" id="font_size"  style="width:125px;" maxlength="12"/>像素
                    </div>
				</td>
			</tr>
			<tr>
				<td valign="top" nowrap><span>文本字体:</span></td>
				<td>
					<div class="tdstyle">
                    	<select name="font_family" id="font_family" style="width:130px;">
							<option value="simfang">仿宋</option>
							<option selected="selected" value="simsun">宋体(默认)</option>
							<option value="simkai">楷体</option>
							<option value="simhei">黑体</option>
							<option value="simli">隶书</option>
							<option value="simyou">幼圆</option>
							<option value="msyh">微软雅黑</option>
							<option value="msyhbd">微软雅黑加粗</option>
							<option value="sthupo">华文琥珀</option>
							<option value="stxihei">华文细黑</option>
							<option value="stxinwei">华文新魏</option>
							<option value="stxingka">华文行楷</option>
							<option value="fzstk">方正舒体</option>
							<option value="sursong">方正超大字体</option>
						</select>&nbsp;&nbsp;<div id="notice" style="display:none;margin-top:10px;"></div>
					</div>
				</td>
			</tr>
			<tr>
				<td></td>
				<td class="tdstyle"><input onclick="ajaxSend();" type="button" value="创建我的logo >>" style="width:244px;" /></td>
			</tr>
		</tbody>
	</table>
</div>
$pic_html
html;
?>