﻿/***************************************************
创建日期：2009-05-12
函数描述：获取制定元素
***************************************************/
function getparms(){
	var len = arguments.length;
	var obj;
	if(len > 2 || len < 1){
		alert("js(getparms):error");
		return false;	
	}
	if(arguments[1] == "id" || arguments[1] == undefined)
		obj = document.getElementById(arguments[0]);
	if(arguments[1] == "name")
		obj = document.getElementByName(arguments[0]);
	return obj;
}
/***************************************************
创建日期：2009-05-12
函数描述：判断浏览器
***************************************************/
function obIE(){
	var isIE = document.all ? 1 : 0;
	return isIE;
}
/***************************************************
创建日期：2009-05-12
函数描述：获取页面的高度
***************************************************/
function getpageheight(){
	var height = document.body.clientHeight?document.body.clientHeight:document.documentElement.clientHeight;
	return height;
}
/***************************************************
创建日期：2009-05-13
函数描述：获取页面的宽度
***************************************************/
function getpagewidth(){
	var width = document.body.clientWidth;
	return width;
}
/***************************************************
创建日期：2009-05-13
函数描述：onclick判断是否
***************************************************/
var e1;
function obonclick(){
	if(e1){
		e1=0;
	}
	else{
		e1=1;
	}
	return e1;
}
/***************************************************
创建日期：2009-05-14
函数描述：下拉菜单
***************************************************/
var proy;
function openstar(id,width,height,speed){
	clearInterval(proy);
	var obj = getparms(id);
	obj.style.display = "block";
	obj.style.height = "1px";
	proy = setInterval(function(){openy(obj,height,speed)},speed);
}
function closestar(id,speed){
	clearInterval(proy);
	var obj = getparms(id);
	if(obj.style.display == "block"){
    	proyc = setInterval(function(){closey(obj,speed)},speed);   
    }
}
function openy(obj,height,speed){
	var cy = parseInt(obj.style.height);
	 if(cy < height){
		obj.style.height = (cy + Math.ceil((height-cy)/speed)) +"px";
	}
	else{
		clearInterval(proy);  
	}
}
function closey(obj,speed){
	var cy = parseInt(obj.style.height);
	 if(cy > 0){
		obj.style.height = (cy - Math.ceil(cy/speed)) +"px";
	}
	else{
		obj.style.display = "none";
		clearInterval(proy);  
	}
}
/***************************************************
创建日期：2009-05-18
函数描述：display显示
***************************************************/
function displayID(id){
	var obj = getparms(id);
	if(obj.style.display != "none"){
		obj.style.display = "none";
	}
	else{
		obj.style.display = "inline";
	}
}
/***************************************************
创建日期：2009-08-02
函数描述：获取页面的卷动高度
***************************************************/
function getpagescrolltop(){
	var scrollTop = document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;
	//alert(scrollTop);
	return scrollTop;
}
/***************************************************
创建日期：2009-08-02
函数描述：获取元素top(position)
***************************************************/
function getpositiontop(id){
	var top = parseInt($(id).css("top"));
	return top;
}
/***************************************************
创建日期：2009-08-02
函数描述：fixed浮动
***************************************************/
function fixedfloat(id){
	var obj = $(id);
	obj.css("top",100 + getpagescrolltop());
}
/***************************************************
创建日期：2009-09-16
函数描述：form check
***************************************************/
function cf_InputNull(obj,txt,message){
	var _self = $(obj);
	if(_self.attr("value")=="" || _self.attr("value")==txt ){
		alert(message);
		_self.focus();
		return false;
	}
	else{
		return true;
	}
}

function cf_TextAreaNull(obj,txt,message){
	var _self = $(obj);
	if(_self.html()=="" || _self.html()==txt ){
		alert(_self.html());
		alert(message);
		_self.focus();
		return false;
	}
	else{
		return true;
	}
}

function cf_integer(obj,message){
	var _self = $(obj);
	if(!EW_checknumber(_self.attr("value"))){
		alert(message);
		_self.focus();
		return false;
	}
	else{
		return true;
	}
}

function EW_checknumber(object_value) {
        if (object_value.length == 0)
                return true;

        var start_format = " .+-0123456789,";
        var number_format = " .0123456789,";
        var check_char;
        var decimal = false;
        var trailing_blank = false;
        var digits = false;

        check_char = start_format.indexOf(object_value.charAt(0));
        if (check_char == 1)
                decimal = true;
        else if (check_char < 1)
                return false;

        for (var i = 1; i < object_value.length; i++)        {
                check_char = number_format.indexOf(object_value.charAt(i))
                if (check_char < 0) {
                        return false;
                } else if (check_char == 1)        {
                        if (decimal)
                                return false;
                        else
                                decimal = true;
                } else if (check_char == 0) {
                        if (decimal || digits)
                        trailing_blank = true;
                }        else if (trailing_blank) {
                        return false;
                } else {
                        digits = true;
                }
        }

        return true;
}





/***************************************************
创建日期：2009-08-16
函数描述：jQuery Effects
***************************************************/

$(document).ready(function(){
	$("img.center").each(function(){
		var _self = $(this);
		var img_width = _self.width();
		var img_height = _self.height();
		var parent = _self.parent();
		var parent_width = parent.width();
		var parent_height = parent.height();
		var left = parseInt((parent_width - img_width)/2);
		var top = parseInt((parent_height - img_height)/2);
		if(img_width != 0){
			_self.css("margin-left",left+"px");
			_self.css("margin-top",top+"px");
		}

	});
});






$(document).ready(function(){
     $('.order_sub1').click(function(){
	 if(cf_InputNull(".name","","请输入您的姓名") 
	 && cf_InputNull(".xint1","","请输入电话") 
	 && cf_InputNull(".xint2","","请输入您的信箱") 
	 && cf_email(".xint2","邮箱地址输入错误")
	 && cf_InputNull(".xint3","","请输入您的住址") 
	 && cf_InputNull(".xint4","","请输入您的邮编") 
	 ){
	 $('#f_order').submit();
	 }
         
     })
     $('.order_sub2').click(function(){
        document.f_order.reset();
    })
})








function cf_email(obj,message){
	var _self = $(obj);
	if(!EW_checkemail(_self.attr("value"))){
		alert(message);
		_self.focus();
		return false;
	}
	else{
		return true;
	}
}


function EW_checkemail(object_value) {
        if (object_value.length == 0)
                return true;

        if (!(object_value.indexOf("@") > -1 && object_value.indexOf(".") > -1))
                return false;

        return true;
}

function cf_pwd(obj1,obj2,message){
	var _self1 = $(obj1);
	var _self2 = $(obj2);
	if(_self1.attr('value') != _self2.attr('value'))
	{
		alert(message);
		_self1.attr('value','');
		_self2.attr('value','');
		_self1.focus();
		return false;
	}
	return true;
} 


