function drawer(name,label){
	var id = document.getElementById( name );
		if((label==1))

		{
			id.style.display='';
		}
		else
			id.style.display='none';
}

function draw_switch(name)
{

		var id = document.getElementById( name );

		if(id.style.display=='')
		{

			id.style.display='none';
		}
		else if(id.style.display=='none')
		{
			id.style.display='';
		}


}

 function draw_all(name1,name2,name3){
	var id1 = document.getElementById( name1 );
	var id2 = document.getElementById( name2 );
	var id3 = document.getElementById( name3 );
		if((id1.style.display=='' || id2.style.display=='' || id2.style.display==''))
		{
			id1.style.display='none';
			id2.style.display='none';
			id3.style.display='none';
		}
		else
		{
			id1.style.display='';
			id2.style.display='none';
			id3.style.display='none';
		}
}

 function isEmail(email) {
    var emailRegExp = /^(?:\w+\.?)*\w+@(?:\w+\.?)*\w+$/;
    return emailRegExp.test(email);
}

function $$(id) {
    return document.getElementById(id);
}
var toTop = 0;
window.onscroll = function () {
    toTop = document.documentElement.scrollTop;
}
function showMessage(message,url) {
    var win = getWinSize();
    if (!($$('alert'))) {
        var div = document.createElement('div');
        var msg = document.createElement('h1');
        var ok  = document.createElement('h2');
        ok.onclick = function () {
            $$('alert').style.display = 'none';
        }
        div.appendChild(msg);
        div.appendChild(ok);
        div.id = 'alert';
        document.body.appendChild(div);
    }
    var alert = $$('alert');
    alert.childNodes[0].innerHTML = message;
	if(url=='#')
		alert.childNodes[1].innerHTML = '<a href="javascript:;"><img src="/misc/img/btnmsgconfirm.gif"></a>';
	else
		alert.childNodes[1].innerHTML = '<a href="'+url+'"><img src="/misc/img/btnmsgconfirm.gif"></a>';

    var left = (win.width - 300) / 2;
    alert.style.left = left + 'px';
    var top = (win.height - 200) / 2 + toTop;
    alert.style.top = top + 'px' ;
	alert.style.display = 'block';
}
/*function showMessage(message,url) {


    var win = getWinSize();
    if (!($$('alert'))) {
        var div = document.createElement('div');
        var shade = document.createElement('div');
        var msg = document.createElement('h1');
        var ok  = document.createElement('h2');
        ok.onclick = function () {
            $$('alert').style.display = 'none';
            $$('alertShade').style.display = 'none';
        }
        div.appendChild(msg);
        div.appendChild(ok);
        div.id = 'alert';
        shade.id = 'alertShade';
        document.body.appendChild(div);
        document.body.appendChild(shade);
    }
    var alert = $$('alert');
    var shade = $$('alertShade');
    alert.childNodes[0].innerHTML = message;
	if(url=='#')
		alert.childNodes[1].innerHTML = '<a href="javascript:;">确 定</a>';
	else
		alert.childNodes[1].innerHTML = '<a href="'+url+'">确 定</a>';

    var left = (win.width - 300) / 2;
    alert.style.left = left + 'px';
    shade.style.left = left + 5 + 'px';
    var top = (win.height - 200) / 2 + toTop;
    alert.style.top = top + 'px' ;
    shade.style.top = top + 5 + 'px';
    shade.style.display = alert.style.display = 'block';
}*/

function getWinSize(_target) {
	var windowWidth, windowHeight;
	if(_target) target = _target.document;
	else	target = document;
	if (self.innerHeight) { // all except Explorer
		if(_target) target = _target.self;
		else	target = self;
		windowWidth = target.innerWidth;
		windowHeight = target.innerHeight;
	} else if (target.documentElement && target.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = target.documentElement.clientWidth;
		windowHeight = target.documentElement.clientHeight;
	} else if (target.body) { // other Explorers
		windowWidth = target.body.clientWidth;
		windowHeight = target.body.clientHeight;
	}
	return {width:parseInt(windowWidth),height:parseInt(windowHeight)};
}

function $$(divId){return document.getElementById(divId);}

function MailYaoQing(name, event)
{
	//firefox不支持disabled属性，重复点击保护暂时取消
	//form_mail.btn.disabled="";
	var win = getWinSize();
	var left = (win.width - 300) / 1.9;
    var top = (win.height - 500) / 2.2 + toTop;


	//$$('mailtitle').value = name + '发自renrengo的邀请信';
	//$$('mailcontent').value = '你的朋友' + name + '邀请你来到人人购 http://www.renrengo.com';
	$$('divMailDiag').style.left = left + 'px';
	$$('divMailDiag').style.top = top + 'px';
	$$('divMailDiag').style.display = 'block';
}

function SendMail()
{

	/*form_mail.btn.disabled=true;
	var emailRegExp = /^(?:\w+\.?)*\w+@(?:\w+\.?)*\w+$/;
   if(!emailRegExp.test($$('mailaddress').value))
	{
		showMessage('email地址输错拉','#');
		return;
	}*/

	var j = $$('ajax_mail');
	var url = window.location.toString();

	url = url.replace( /\?.{0,}/, '' );
	url = url.replace( /\/\w{0,}\.php/, '' );

	url = url + '/action/sendMail.php';
	$.post(url,
	{ email: $$('mailaddress').value, friend_name: $$('friend_name').value,recom:$$('recom').value},
		function(data){
		eval(data);
		form_mail.btn.disabled="";
		}
	)
}

function fetchcookies(isblog){

var mycookie = document.cookie;
var posturl=isblog;

t = mycookie.split(';');
var name = null;
var pass = null;

for(i=0;i<t.length;i++)
{
	if(t[i].indexOf("name=") !=-1)
		name = t[i].split('=')[1];
	if(t[i].indexOf("pass=") !=-1)
		pass = t[i].split('=')[1];

}

var url = window.location.toString();
if (name != null && pass != null)
{

	if(posturl='blog')
		posturl='../action/checkLogin.php';
	else
		posturl='./action/checkLogin.php';
	$.post(posturl,
	{
		form_email: name, form_password:pass,type:'cookiestyle',url:url },
	function(data){
		eval(data);
	});
}
}

/*************以下为原header部分的js*******************/

var tmp;
function forget_pwd()
{
	tmp = $('#headerLoginbox').html();
	$('#headerLoginbox h1').html('<a href="javascript:;" onClick="close_get_pwd()">×</a>');
	$('#headerLoginbox h2').html('输入您的注册Email：<input id="nameText" type="text" name="name" class="inT2" />');
	$('#headerLoginbox h3').html('');
	$('#headerLoginbox h4').html('<input id="loginButton" type="button" tabindex="3" class="inB" onclick="javascript:get_pwd()" value=" 获取密码 " />');
	$('#headerLoginbox h5').html('');

}

function get_pwd()
{
	$.post("./action/checkLogin.php",
		{
			form_email: $$('nameText').value,action: 'reset'
		},function(data){
		eval(data);
	});
}

function close_get_pwd()
{

	$('#headerLoginbox').html(tmp);
	document.getElementById('headerLoginbox').style.display = 'none';

}


function login()
{
	var name=$$('nameText').value;
	var pass=$$('passText').value;
	expireDate = new Date ;
　　expireDate.setTime(expireDate.getTime() + 3 * 30 * 24 * 60 * 60 * 1000) ;
	document.cookie = "name="+escape($$('nameText').value)+";expires=" + expireDate.toGMTString();
	document.cookie = "pass="+escape($$('passText').value)+";expires=" + expireDate.toGMTString();

	$.post("./action/checkLogin.php",
	{
		form_email: $$('nameText').value, form_password: $$('passText').value },
	function(data){
		eval(data);
	});
}

function logout()
{
	expireDate = new Date ;
　　expireDate.setTime(expireDate.getTime() -1) ;
	document.cookie = "name="+escape('name')+";expires=" + expireDate.toGMTString();
	document.cookie = "pass="+escape('pass')+";expires=" + expireDate.toGMTString();

	$.post("./action/checkLogin.php",
	{
		action:'quit'
	},
		function(data){
		eval(data);
	});
}

function showLoginbox() {
	$$('headerLoginbox').style.display = '';
	$('#headerLoginbox').slideDown('slow');
}


/*************原header部分的js结束*******************/


function createFlash(DivID, flashobjectUrl, width, height, flashVars)
{
    var d = document.getElementById(DivID);
    if (d.innerHTML==""){
    	d.innerHTML = '<embed ' +
                 	 '    src="' + flashobjectUrl + '" ' + 
                 	 '    width="' + width + '" ' +
                 	 '    height="' + height + '"  ' +
                 	 '    bgcolor="#FFFFFF" ' +
                 	 '    type="application/x-shockwave-flash" ' +
                 	 '    pluginspage="http://www.macromedia.com/go/getflashplayer" ' +
                 	 '    flashvars="' + flashVars + '" ' +
                 	 '    allowScriptAccess="sameDomain" ' +
                 	 '/>';
	}
}