﻿//选择按钮
$(function(){
	
	}); 

$(function(){
  $('.navbar2').mousemove(function(){
  $(this).find('ul').slideDown(200);
  $(this).find('>a').css({"background":"url("+ImageFolder+"btbg.gif) no-repeat","font-weight":"bold"});
  });
  $('.navbar2').mouseleave(function(){  
  $(this).find('ul').slideUp(0);
  $(this).find('>a').css({"background":"url()","font-weight":"normal"});
  });
});

$(function(){
setInterval("$('.topbar_2').html(new Date().toLocaleDateString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay()));",200);
}); 


//车型介绍
var cache=new Array();
function intro(url,pid){
	var id='intro';rediv();
	if(typeof(cache[url+pid])=="undefined")
	{
		$.post(url, {pid:pid},
		function (data, textStatus) {
			cache[url+pid]=data.data;
			$("body").prepend(cache[url+pid]);
			divcenter(id);$(window).resize(function(){divcenter(id);});$(window).scroll( function() {divcenter(id);});
		}, "json");
	}
	else
	{
		$("body").prepend(cache[url+pid]);
		divcenter(id);$(window).resize(function(){divcenter(id);});$(window).scroll( function() {divcenter(id);});
   }
}

//全景观车
function view(url,pid){
	var id='view';rediv();
	if(typeof(cache[url+pid])=="undefined")
	{
		$.post(url, {pid:pid},
		function (data, textStatus) {
			cache[url+pid]=data.data;
			$("body").prepend(cache[url+pid]);
			divcenter(id);$(window).resize(function(){divcenter(id);});$(window).scroll( function() {divcenter(id);});
			$(".pl").eq(0).trigger("click");
		}, "json");
	}
	else
	{
		$("body").prepend(cache[url+pid]);
		divcenter(id);$(window).resize(function(){divcenter(id);});$(window).scroll( function() {divcenter(id);});
		$(".pl").eq(0).trigger("click");
   }
}


//立即订购
function buy(url,pid){
	var id='buy';rediv();
	if(typeof(cache[url+pid])=="undefined")
	{
		$.post(url, {pid:pid},
		function (data, textStatus) {
			cache[url+pid]=data.data;
			$("body").prepend(cache[url+pid]);
			divcenter(id);$(window).resize(function(){divcenter(id);});$(window).scroll( function() {divcenter(id);});
		}, "json");
	}
	else
	{
		$("body").prepend(cache[url+pid]);
		divcenter(id);$(window).resize(function(){divcenter(id);});$(window).scroll( function() {divcenter(id);});
   }
}


function divcenter(id){
	  $('#'+id).css({ 
	  position:'absolute', 
	  left: ($(window).width() - $('#'+id).outerWidth())/2, 
	  top: ($(window).height() - $('#'+id).outerHeight())/2 + $(document).scrollTop() 
	  }); 
	}

function rediv(){
$("#intro").remove();
$("#view").remove();
$("#buy").remove();
}


function showPreview(url){
	$("#bigpic").html("<img src=\""+url+"\" width=\"440\" height=\"295\" />");
}

$(function(){
    xy.defshow($("#msgarea")[0],'文明上网，理性发言')
})


/**
 * 检查输入的邮箱格式是否正确
 * 输入:str  字符串
 * 返回:true 或 flase; true表示格式正确
 */
function checkEmail(str){
    if (str.match(/[A-Za-z0-9_-]+[@](\S*)(net|com|cn|org|cc|tv|[0-9]{1,3})(\S*)/g) == null) {
        return false;
    }
    else {
        return true;
    }
}







