document.write("<script type='text/javascript' src='"+imgcdn+"/public/js/jquery.rc.js'></script>"); 
document.write("<script type='text/javascript' src='"+imgcdn+"/public/js/jQuery.cookie.js'></script>"); 
document.write("<script type='text/javascript' src='"+imgcdn+"/public/js/flex.js'></script>"); 
document.write("<script type='text/javascript' src='"+imgcdn+"/public/js/jquery.swipebox.js'></script>"); 
document.write("<script type='text/javascript' src='"+imgcdn+"/public/js/wow.js'></script>"); 
document.write("<script type='text/javascript' src='"+imgcdn+"/public/js/comlib.js'></script>"); 

var doones = true;

function webbasedo(){
	new WOW().init();	
	if (doones){
		base_ones();
		doones = false;
	}
	jQuery(".showtab").unbind('click').click(function(){
		jQuery("."+jQuery(this).attr("rel")).show(200);
		jQuery(this).addClass('hidetab');
		jQuery(this).removeClass('showtab');
		if (jQuery(this).attr("rtype")==='mobbig'){
			jQuery(this).find("span").addClass('icon-shanchu');
			jQuery(this).find("span").removeClass('icon-caidan1');
			//jQuery("ul.mobmenuul li.mli").hide();
			//jQuery("ul.mobmenuul li.sli").hide();
		}else if (jQuery(this).hasClass("icon-jia")){
			jQuery(this).addClass('icon-plus-minus');
			jQuery(this).removeClass('icon-jia');
		}
		webbasedo();
	});
	jQuery(".hidetab").unbind('click').click(function(){
		jQuery("."+jQuery(this).attr("rel")).hide(200);
		jQuery(this).addClass('showtab');
		jQuery(this).removeClass('hidetab');
		if (jQuery(this).attr("rtype")==='mobbig'){
			jQuery(this).find("span").addClass('icon-caidan1');
			jQuery(this).find("span").removeClass('icon-shanchu');
		}else if (jQuery(this).hasClass("icon-plus-minus")){
			jQuery(this).addClass('icon-jia');
			jQuery(this).removeClass('icon-plus-minus');
		}
		webbasedo();
	});
	jQuery(".tel").unbind('click').click(function(){
		if (!isEmpty(jQuery(this).attr("rel"))){
			window.location.href = "tel://"+jQuery(this).attr("rel");
		}
	});
	jQuery(".feedbackbtn").unbind('click').click(function(){
		do_feedback_submit(jQuery(this).attr('rel'));
	});
	jQuery(".blurcheck").unbind('blur').blur(function(){
		do_check_from_row(jQuery(this).attr('id'));
	});
}

function base_ones(){
	var clientWidth = document.body.clientWidth;
	var bgimgsize = '-';
	if (clientWidth<1300){
		bgimgsize = '_960x960';
	}
	if (clientWidth<650){
		bgimgsize = '_640x640';
	}
	jQuery(".bgimgautosize").each(function(){
		var bgimg = jQuery(this).attr('bgimg');
		if (bgimgsize!=='-'){			
			bgimg = bgimg + bgimgsize + bgimg.substr(-4);
		}
		jQuery(this).css("background-image","url('"+bgimg+"')");
		//alert(bgimg);
	});
	jQuery(".imgautosize").each(function(){
		var bgimg = jQuery(this).attr('srcb');
		if (bgimgsize!=='-'){			
			bgimg = bgimg + bgimgsize + bgimg.substr(-4);
		}
		jQuery(this).attr("src",bgimg);
		//alert(bgimg);
	});

	jQuery(window).scroll(function(){
		stickyfunc('.header');
		if (jQuery(this).scrollTop() > 150) {
			jQuery('#backtotop').fadeIn();
		} else {
			jQuery('#backtotop').fadeOut();
		}
	});
	jQuery('#backtotop a').unbind('click').click(function () {
		scrollTo();
	});
	jQuery('.gotab').unbind('click').click(function () {
		scrollTo('.'+jQuery(this).attr("rel"),300);
	});
	window.setTimeout("yaaque_up()",500);
}

function scrollTo(ele, speed){
	if(!speed) speed = 300;
	if(!ele){
		jQuery("html,body").animate({scrollTop:0},speed);
	}else{
		if(ele.length>0) jQuery("html,body").animate({scrollTop:jQuery(ele).offset().top},speed);
	}
	return false;
}

function do_check_from_row(txtrowid){	
	var bodyrap = (window.opera) ? (document.compatMode == "CSS1Compat" ? jQuery('html') : jQuery('body')) : jQuery('html,body');
	var ischeck = true; 	
	var regemail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var txtrowid = jQuery("#"+txtrowid).attr('id');
	var txtval = jQuery("#"+txtrowid).val();
	var rel = jQuery("#"+txtrowid).attr('rel');
	if (!isEmpty(rel) && ischeck){
		var arrcheck = rel.split('|');
		if (arrcheck[0]=='email' && !regemail.test(txtval)){
			ischeck = false;
		}
		if (arrcheck[0]=='txt' && txtval.length<parseInt(arrcheck[1])){
			ischeck = false;
		}
		if (ischeck){
			jQuery(".err"+txtrowid).html('');
		}else{
			var offtop = jQuery('#'+txtrowid).offset().top - 70;
			jQuery(".err"+txtrowid).html(jQuery("#"+txtrowid).attr('placeholder'));
			bodyrap.animate({scrollTop:offtop}, 300);
			jQuery("#"+txtrowid).focus();
		}
	}
	return ischeck;
}

function do_feedback_submit(formid){
	var ischeck = true; 
	var arrpost = {};
	arrpost['data'] = {};
	jQuery("#"+formid+" input").each(function(){
		var txtrowid = jQuery(this).attr('id');
		var txtval = jQuery(this).val();
		ischeck = do_check_from_row(txtrowid);
		if (!ischeck){
			return false;
		}
		arrpost['data'][txtrowid] = txtval;
	});
	if (ischeck){
		jQuery("#"+formid+" textarea").each(function(){
			var txtrowid = jQuery(this).attr('id');
			var txtval = jQuery(this).val();
			ischeck = do_check_from_row(txtrowid);
			if (!ischeck){
				return false;
			}
			arrpost['data'][txtrowid] = txtval;
		});
	}
	if (ischeck){
		jQuery("#"+formid+" select").each(function(){
			var txtrowid = jQuery(this).attr('id');
			var txtval = jQuery(this).val();
			ischeck = do_check_from_row(txtrowid);
			if (!ischeck){
				return false;
			}
			arrpost['data'][txtrowid] = txtval;
		});
	}
	//alert(jQuery.cookie('confirm'));
	if (ischeck){		
		jQuery(".ing"+formid).removeClass('hide');
		jQuery.ajax({
			type: "POST",
			url: jQuery.cookie('feedbackurl'),
			data:JSON.stringify(arrpost),
			contentType: "application/json;charset=utf-8",
			dataType: "json",
			success:function (data) {
				//MaskUtil.unmask();
				jQuery(".ing"+formid).addClass('hide');
				//alert(JSON.stringify(data));
				rc.msg.alert(data['msg'],'Msg',jQuery.cookie('confirm'),jQuery.cookie('cancel'));
			},
			error:function (data) {
				//MaskUtil.unmask();
				//alert(JSON.stringify(data));
				jQuery(".ing"+formid).addClass('hide');
				rc.msg.alert('error submit','Msg',jQuery.cookie('confirm'),jQuery.cookie('cancel'));
			}
		});
	}
}

function isEmpty(obj){
    if(typeof obj == "undefined" || obj == null || obj == ""){
        return true;
    }else{
        return false;
    }
}


function stickyfunc(v){
	var strickyScrollPos = 25;
	var strickyScrollPos2 = 100;
	if(jQuery('body').width()>800) {
		var strickyScrollPos = 50;
		var strickyScrollPos2 = 300;
	}
	if(jQuery(window).scrollTop()>1) {
		jQuery(v).addClass('header-small');
		jQuery(v).removeClass('header-transparent');
	}else{
		jQuery(v).addClass('header-transparent');
		jQuery(v).removeClass('header-small');
	}
 }