﻿//document.write("<script src='/aspx/iplimit.aspx?s=" + Math.random() + "'><\/script>"); //by meiso 2011-10-10

function ShowSubMenu(show_id,hide_ids)
{
    if(hide_ids != "")
    {
        var arrMenu=hide_ids.split(",");
        for(var i=0;i<arrMenu.length;i++)
        {
                $('#'+arrMenu[i]).hide();
        }
    }
    $('#'+show_id).show();
}

function Search_Click()
{   
    var str=$("#SearchStr").val();
    if(str == "")
    {return;}
    location.href ="/aspx/Search.aspx?Key="+encodeURIComponent(str);
}
function showBgImage(index)
{
    $("#mainnav li").eq(index).addClass("here");
}

// JScript 文件
function getCookie (sCookieName)
{
    var sName=sCookieName+"=", ichSt, ichEnd;
    var sCookie=document.cookie;

    if ( sCookie.length && ( -1 != (ichSt = sCookie.indexOf(sName)) ) )
    {
        if (-1 == ( ichEnd = sCookie.indexOf(";",ichSt+sName.length) ) )
            ichEnd = sCookie.length;
        return unescape(sCookie.substring(ichSt+sName.length,ichEnd));
    }
    
    return null;
}
   
function setCookie (sName, vValue)
{
    var argv = setCookie.arguments, argc = setCookie.arguments.length;
    var sExpDate = (argc > 2) ? "; expires="+argv[2].toGMTString() : "";
    var sPath = "; path=/";// (argc > 3) ? "; path="+argv[3] : "";
    var sDomain = (argc > 4) ? "; domain="+argv[4] : "";
    var sSecure = (argc > 5) && argv[5] ? "; secure" : "";
    document.cookie = sName + "=" + escape(vValue,0) + sExpDate + sPath + sDomain + sSecure + ";";
}
    
function deleteCookie (sName)
{
    document.cookie = sName + "=" + getCookie(sName) + "; expires=" + (new Date()).toGMTString() + ";";
}

//------------------------------------


function setProductInqurie(pid,ask)
{
if(ask == true){
    setCookie("InquireList",pid+",");
    location.href="/Products_Feedback.htm";
}else{
    var oldCookie = getCookie("InquireList")==null?"":getCookie("InquireList");
    if(pid.replace(" ","") != "" && oldCookie.indexOf(pid+",")<0)
    {
        setCookie("InquireList",oldCookie+pid+",");
    }
}
}

function selectAll()
{
    var check_ids = "";
    $("input[name='CheckBox_Prod']").each(function(i,El){
        if($(this).attr("checked"))
        {
            check_ids += $(this).val()+",";
            setProductInqurie($(this).val(),false);
        }
    });
    if(check_ids != "")
    {
      location.href="/Products_Feedback.htm";
    }
    else
    {
        alert("Pls select products");
    }
    return false;
}

function pcSearch()
{
    var _id = $("#ProdClassSearch1_drtype option:selected").val();
    var key = $("#ProdClassSearch1_KeyText1").val();
    if( key=="" && _id == "")
    {return;}
    location.href = ("/aspx/Search.aspx?TypeID="+_id+"&key="+encodeURIComponent(key));
    
}
function clickThisImg(Name)
{
    $("#Img").attr("src","/UserFiles/Image/"+Name); 
    $( "#Img" ).aeImageResize({ height: 340, width: 340 });
}

function chgH3_Style(id)
{
    $( '#'+id ).addClass('here');
}
function chgH4_Style(id)
{
    $( '#'+id ).addClass('here');
}
function showContent(obj,a_id)
{
    var ps = "p_Description,p_Specification,p_Picture,p_Case";
    var arrps=ps.split(",");
    for(var i=0;i<arrps.length;i++)
    {
            $('#'+arrps[i]).hide();
    }
    $(obj).show();
    
    //
    var as="a_show_Description,a_show_Specification,a_show_Picture,a_show_Case,";//background:#EBF1F8; color:#2E3192;
    var arras=as.split(",");
    for(var i=0;i<arras.length;i++)
    {
        $('#'+arras[i]).attr('background','#7298CB');
        $('#'+arras[i]).attr('color','#FFFFFF');
    }
    $('#'+a_id).attr('backgroundColor','#EBF1F8');
    $('#'+a_id).attr('color','#2E3192');
    try{window.event.returnValue =false;}catch(e){}
    return false;
}
function AddClick( ID , TYPE )
{
    var url="<iframe width=0 height=0 style='display:none' src='/aspx/AddClick.aspx?TYPE="+TYPE;
    url+="&IDentityID=";
    url+=ID;
    url+="'></iframe>";
    document.write(url);
}
function AjaxGetPro_Next( ControlID , ObjectID , Type )
{             
    $.post("/aspx/Ajax.aspx",{IdentityID:escape( ObjectID ),Type:escape( Type )},function(data){
        $('#'+ControlID).html(data);
    });
}
function AjaxGetRemmProd( ControlID , ObjectID )
{
    $.post("/aspx/Ajax.aspx",{GetREMMPROD:escape( ObjectID )},function(data){
        $('#'+ControlID).html(data);
    });
}

function AjaxPageClass( control,pars ){
    var arrpars=[];
    arrpars = pars.split("&");
    $.post("/aspx/AjaxGetPages.aspx",{ID:arrpars[0].split("=")[1],Type:arrpars[1].split("=")[1]},function(data){
        $('#'+control).html(data);
    });
}

String.prototype.trim = function()
{
    return this.replace(/(^[\\s]*)|([\\s]*$)/g, "");
}
//产品内容品的产品评论脚本
function Ajax_getLeave( ControlID , productID ,currentPage )
{

    $.post("/aspx/MsgAjax.aspx",{productID:escape( productID ),currentPage:escape(currentPage)},function(data){
        $('#'+ControlID).html(data);
    });
}

function Ajax_setLeave(productID,name,email,content,country,subject,inquireType)
{
    var i=0;
    var errorMsg="";
    var xmlhttp;
    var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;  
　　　　　　flag = pattern.test(email);  
　　　　　　if(subject.trim().length<=0){errorMsg+=(++i)+".Subject should not be blank!\n";}
　　　　　　if(name.trim().length<=0){errorMsg+=(++i)+".Name cannot be blank!\n";}
　　　　　　if(!flag){errorMsg+=(++i)+".Your email address is not correct!\n";}
　　　　　　if(country.trim().length<=0){errorMsg+=(++i)+".Country cannot be blank!\n";}
　　　　　　if(content.trim().length<=0){errorMsg+=(++i)+".Message should not be blank!\n";}
　　　　　　if(errorMsg!=""){alert(errorMsg);$("#mybg").hide(); return false;}
    $.post(
        "/aspx/MsgAjax.aspx",
        {
            insert:"true",
            productID:escape( productID ),
            name:name,
            email:email,
            content:content,
            country:country,
            subject:subject,
            inquireType:inquireType
        },
        function(data){
          alert(data);
          $("#mybg").hide();
        }
    );
}


$(function(){
    $.get("/aspx/FloatBox.aspx",function(data){
				$("body").append(data).append("<script type='text/javascript' src='/js/ControlfloatBox.js'></script>");
                if($.browser.msie && $.browser.version=="6.0") 
                {			
				    $("body").append("<script type='text/javascript' src='/js/floatBox.js?t="+(new Date()).getTime()+"'></script>");
				    $("#floatBox").css('position','absolute');
				}
//				$("body").append("<script type='text/javascript' src='/js/AlertDivFloat.js'></script>");
    });
    $( "#Img" ).aeImageResize({ height: 340, width: 340 });
    $( "#pro_list a img" ).aeImageResize({ height: 124, width: 168 });
    $( "#i_show a img" ).aeImageResize({ height: 124, width: 168 });
});




//-----以下控制flash播发,但要设置object的id和embed的name为同一个值-----
function getFlashMovieObject(movieName)  
 {  
   if (window.document[movieName])  
   {return window.document[movieName];}  

   if (navigator.appName.indexOf("Microsoft Internet")==-1)
   {
     if (document.embeds && document.embeds[movieName])  
       return document.embeds[movieName];
   }  

   else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)  
   {return document.getElementById(movieName);}  

 } 
//暂停播放flash
function StopFlashMovie(flashObj)
{
var flashMovie=getFlashMovieObject(flashObj);
flashMovie.StopPlay();
}
//开始播放flash
function PlayFlashMovie(flashObj)
{
	var flashMovie=getFlashMovieObject(flashObj);
	flashMovie.Play();
	//embed.nativeProperty.anotherNativeMethod();
}
//停止播放flash
function RewindFlashMovie(flashObj)
{
	var flashMovie=getFlashMovieObject(flashObj);
	flashMovie.Rewind();
}
//放大
function ZoominFlashMovie(flashObj)
{
	var flashMovie=getFlashMovieObject(flashObj);
	flashMovie.Zoom(90);
}
//缩小
function ZoomoutFlashMovie(flashObj)
{
	var flashMovie=getFlashMovieObject(flashObj);
	flashMovie.Zoom(110);
}
//-----以上控制flash播发-----

