<?php
//明信片风格
if(file_exists('output/techsir.jpg'))
{
	list($width, $height, $type, $attr) = getimagesize("output/techsir.jpg");
	$pic_html = <<<pic
<div id="show_logo"><img id="show_img" src="output/techsir.jpg"/><span>宽*高:{$width}px*{$height}px</span></div>
pic;
}
else
{
	$pic_html = <<<pic
<div id="show_logo"><img id="show_img" src="images/default.jpg"/></div>
pic;
}

$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">
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);
    });
}
</script>
<script type="text/javascript">
function ajaxSend()
{
	$.ajax({
	   type: "POST",
	   url: "server.php",
	   data: {id:"techsir",left_padding:$("#left_padding").attr("value"),logo_text:$("#logo_text").attr("value"),logo_font:$(":radio:checked").attr("value"),logo_color:$("#logo_color").attr("value"),logo_size:$("select option:selected").attr('value')},
	   beforeSend:function(msg){
	   		$("#show_img").remove();
			$("#show_logo").append("<img id='show_img' src='images/loadingAnimation.gif'/>");
		},
	   success: function(msg){
			window.location.reload();
   	   },
   	   error: function(msg){
   	   	 alert(msg);
   	   }
	});
}

function validate(oNum)
{
	if(!oNum)
	{ 
		$('#left_padding').attr('value','');
		return false; 
	}
  	var strP=/^\d+(\.\d+)?$/; 
  	if(!strP.test(oNum)) 
  	{
		$('#left_padding').attr('value',''); 
		return false; 
	}
  	try
  	{ 
  		if(parseFloat(oNum)!=oNum)
		{
			$('#left_padding').attr('value','');
  			return false;
  		}
  	} 
  	catch(ex) 
  	{ 
  	 	$('#left_padding').attr('value','');
  		return false;
  	} 
  	return true; 
}
</script>
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="0" cellpadding="5" width="100%" border="0">
		<tbody>
			<tr>
				<td valign="top" nowrap><span>Logo文本:</span></td>
				<td>
					<div class="tdstyle">
                    	<input name="logo_text" type="text" value="cndns" id="logo_text" maxlength="12" style="width:125px;" />
                    </div>
				</td>
			</tr>
			<tr>
				<td valign="top" nowrap><span>文本左边距:</span></td>
				<td>
					<div class="tdstyle">
                    	<input name="left_padding" onkeyup="validate($(this).attr('value'));" type="text" value="0" id="left_padding" maxlength="3" style="width:125px;" />像素
                    </div>
				</td>
			</tr>
			<tr>
				<td valign="top" nowrap><span>Logo字型:</span></td>
				<td>
					<div class="tdstyle">
                    	<input type="radio" checked="checked" value="regular" name="logo_font" id="regular">
                    	<label for="regular">标准</label>
                    	<input type="radio" value="bold" name="logo_font" id="bold">
                    	<label for="bold">粗体</label>
                    	<input type="radio" value="italic" name="logo_font" id="italic">
                    	<label for="italic">斜体</label>
					</div>
				</td>
			</tr>
			<tr>
				<td valign="top" nowrap><span>字体颜色:</span></td>
				<td>
					<div class="tdstyle">
                    	<input onkeydown="$(this).attr('value','');" name="logo_color" type="text" value="#000000" id="logo_color" maxlength="8" style="width:125px;" onclick="showColor('logo_color');"/>
                    </div>
				</td>
			</tr>
			<tr>
				<td valign="top" nowrap><span>图片大小:</span></td>
				<td class="tdstyle">
					<div>
                    	<select name="logo_size" id="logo_size" style="width:130px;">
							<option value="large">大</option>
							<option value="medium">中</option>
							<option selected="selected" value="small">小</option>
						</select>
					</div>
				</td>
			</tr>
			<tr>
				<td></td>
				<td class="tdstyle"><input onclick="ajaxSend();" type="button" id="techsir_button" value="创建我的logo >>"  style="width:244px;" /></td>
			</tr>
		</tbody>
	</table>
</div>
$pic_html
html;
?>