// JavaScript Document

function checkLogin(){
	if(!uname){
		alert('请先登录！');
		$(".login a:first").addClass("thickbox").click();
		return false;
	}
	window.document.loadflash.SetVariable("my_login", 1);
}

function fileSelect() {
	document.frames[0].form1.imgUpload.value = '';
	document.frames[0].form1.imgUpload.click();
	var imgSrc = document.frames[0].form1.imgUpload.value.replace(/\\/g,"/");
	window.document.loadflash.SetVariable("myVar", imgSrc);
	//$("#setavatar").click();
}

function btnSubmit(){
	if(document.frames[0].form1.imgUpload.value==''){
		alert('请先选择上传的图片');
		return false;
	}
	document.frames[0].form1.submit.click();
}

function sendMsg(txt,pid) {
	if(uname==''){
		alert('请先登录！');
		$(".login a:first").addClass("thickbox").click();
		return false;
	}

	if(txt.empty() || txt.MaxLength()){
		alert('留言失败！内容不能为空或超过100字');
		return '';
	}
	
	if(window.location.href.indexOf('mirror')!=-1)
		type = 2;
	else
		type = 1;
	
	$.post("save.php",{'action':'message','title':txt,'type':type,'pid':pid},function(data,stat){
		if(data==1){
			alert('留言成功！');
			window.document.loadflash.SetVariable("myVar_msg", "1");	
		}else if(data==-1){
			alert('请先登录！');
			$(".login a:first").addClass("thickbox").click();
			return '';
		}else{
			alert('留言失败，写入数据库错误！请重试！');	
			return '';
		}
	});
	//end
}

function showBmi(gewicht,groesse) {

	if(uname==''){
		alert('请先登录！');
		$(".login a:first").addClass("thickbox").click();
		return false;
	}

	if(gewicht.empty() || groesse.empty()){
		alert('身高和体重都不能为空！');
		return '';
	}
	
	if(groesse<1.4 || groesse>2.0){
		alert('身高只能输入1.4M-2.0M之间的数据');
		return '';
	}
	
	$.post("save.php",{'action':'BMI','gewicht':gewicht,'groesse':groesse},function(data,stat){
		if(data==-1){
			alert('请先登录！');
			return false;
		}else if(data==1){
			window.document.bmi.SetVariable("myVar_bmi", "1");	
		}else{
			alert('出现错误！请再试');
			return '';
		}															
	});
}

//动态JS文件
$(function(){
	//统一底部
	ctime = new Date().getTime();
	$.get("./count.php",{"time":ctime},function(count){
		if(count){
			footStr = '<div class="footleft"><p class="airal">Copyrights all reserved by Brightcheese @2010.&nbsp;&nbsp;&nbsp;&nbsp;沪ICP备05002385号</p><p>本网站版权归上海光明奶酪黄油有限公司所有 上海市吴中路578号 <a href="mailto:52cheese@gmail.com">联系我们</a></p><p>目前已有<font style="font-size:14px;"><strong>'+count+'</strong></font>位用户访问</p></div>';
		document.getElementById('foot').innerHTML = footStr;
		}			  
	})
	
	$(".topnav a:last").attr('href','http://www.brightcheese.com');
	$(".topnav a:last").attr('target','_blank')
	
	$(".topnav a").eq(2).after('<a href="huodong.html"><img src="images/nav4.jpg" /></a>')

	
	
	
	if(typeof IN_MAIN == "undefined"){
		var sd = document.createElement("script");
		sd.src = './js/main.js';
		document.appendChild(sd);		
	}
	
	
})
