/* level 1 navigation hack for MSIE */
<!--//--><![CDATA[//><!--
sfHover = function() {
	if(!document.getElementById("nav_L1"))
		return;
	var sfEls = document.getElementById("nav_L1").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
//--><!]]>

/* BROWSER DETECT PARAMS */
var detect = navigator.userAgent.toLowerCase();
var isSafari = (detect.indexOf('safari') != -1 ? true : false);
var isMacIE = (detect.indexOf('mac') != -1 && detect.indexOf('msie') != -1 ? true : false);
var isLinux = (detect.indexOf('linux') != -1 ? true : false);
var isUnix = (detect.indexOf('x11') != -1 ? true : false);
var isWin = (detect.indexOf('win') != -1 ? true : false);
var isMac = (detect.indexOf('mac') != -1 ? true : false);

//GET OBJECT BY ID
function getMyObj(elemName) {
	var obj;
	if (document.all && !(document.getElementById)) { 
		obj = eval("document."+elemName);
	} else if (document.layers && !(document.getElementById)) {
		obj = eval( 'document.ns4' + elemName + '.document.ns4' + elemName + '2.' );
	} else if (document.getElementById) {
		obj = eval("document.getElementById('"+elemName+"')");
	} 
	return obj;
}
	


/* FUNCTIONS REQUIRED FOR DYNAMIC INFO ON SC CODE BELOW */
function setCookie( name, value, expires, path, domain, secure ) {
	var expireDate = new Date();
	expireDate.setTime(Date.parse(expires));
	var defaultDate = new Date();
	defaultDate.setYear( ( defaultDate.getYear() < 1900 ? defaultDate.getYear() + 1900 : defaultDate.getYear() ) + 1 );
	var curCookie = name + '=' + escape( value ) + '; expires=' + ( (expires) ? expireDate.toGMTString() : 
	defaultDate.toGMTString() ) +
		'; path=' + ( (path) ? path : '/') +
		'; domain=' + ( (domain)  ? domain : cookieDomain ) +
		( (secure)  ? '; secure' : '');
	document.cookie = curCookie;
}

function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + '=';
	var begin = dc.indexOf( '; ' + prefix );
	if( begin == -1 ){
		begin = dc.indexOf(prefix);
		if( begin != 0 ){
			 return null;
		}
	} else {
		begin += 2;
	}
	var end = document.cookie.indexOf(';', begin);
	if( end == -1 ){
		end = dc.length;
	}
	return unescape( dc.substring( begin + prefix.length, end ) ); 
}

function deleteCookie( name, path, domain ) {
	if( getCookie( name ) ){
		document.cookie = name + '=' +
			'; path=' + ( (path) ? path : '/' ) +
			'; domain=' + ( (domain) ? domain : cookieDomain ) +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function getURLParams( aURL ) 
{ 
	var responseObj; 
    var responseObjText = 'responseObj = {'; 
    if( aURL.indexOf( '?' ) > -1 ){ 
        var argArray = aURL.substr( aURL.indexOf( '?' ) + 1 ).split( '&' ); 
        var key, val; 
        var safeRe = /^([0-9]{1,}|true|false)$/i; 
        var quoteRe = /'/g; 
        for( var i = 0; i < argArray.length; i++ ){ 
            key = ''; 
            val = ''; 
            if( argArray[i].indexOf( '=' ) > -1 ){ 
                key = argArray[i].substr( 0, argArray[i].indexOf( '=' ) ); 
                val = argArray[i].substr( argArray[i].indexOf( '=' ) + 1 ); 
                val = unescape( val ); 
            } else { 
                key = argArray[i]; 
            } 
            responseObjText+= ( i > 0 ? ',' : '' ) + "\n '" + key.replace( quoteRe, "\\'" ) + "': "; 
            if( val == '' ){ 
                val = true; 
            } 
            if( !safeRe.test( val ) ){ 
                responseObjText+= "'" + val.replace( quoteRe, "\\'" ) + "'"; 
            } else { 
                responseObjText+= val; 
            } 
        } 
    } 
    responseObjText+= "\n}"; 
    eval( responseObjText ); 
    return responseObj; 
}

function styleSheetChanger(cssClassName,toChange,changeTo) {
	for(i = 0; document.styleSheets.length > i; i++) { //Mozilla
  		if(document.styleSheets[i].rules != undefined) {
   			for(j = 0; document.styleSheets[i].rules.length > j; j++) {
	   			if(document.styleSheets[i].rules[j].selectorText.toLowerCase() == cssClassName.toLowerCase()) {
     				document.styleSheets[i].rules[j].style[toChange] = changeTo;
				}
   			}
  		} else if(document.styleSheets[i].cssRules != undefined) { //IE
			for(j = 0; document.styleSheets[i].cssRules.length > j; j++) {
    			if(document.styleSheets[i].cssRules[j].selectorText.toLowerCase() == cssClassName.toLowerCase()) {
     				document.styleSheets[i].cssRules[j].style[toChange] = changeTo;
    			}
   			}
  		} else {
   			alert("Your browser won't support the changing of a style sheet by javascript!");
  		}
	}
}

function switchStatus(magicDiv) {
	if (document.getElementById(magicDiv).style.display!='block') {
		document.getElementById(magicDiv).style.display='block';
	} else {
		document.getElementById(magicDiv).style.display='none';
	}
}

function openPop(url,name,width,height) {
	window.open(url,name,'height='+height+',width='+width+', scrollbars=yes, resizeable=yes, status=no, menubar=no, toolbar=no,location=no');
}

function loadXMLDoc(url) {
	var req;
	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	if(req) {
		req.open("GET", url, true);
		req.send("");
	}
}

function staticOpen(staticPage) {
	staticPage = parseInt(staticPage);
	if (staticPage>0)
		window.open('/static/'+staticPage,'_blank');
	
}

var whoMe;
var theUrl = getURLParams(window.location.href);
(getCookie('mc_company') ? whoMe='customer' : whoMe='non-customer');

//获取来路函数开始
function request(key) 
{ 
if(typeof(this)=="undefined")return false; 
if(this.length>0) 
{ 
var s = this.split("&"); 
for(var i in s) 
{ 
var sp=s[i].split("=");
if(sp[0]==key)return(sp[1]); 
} 
return false; 
} 
else
  return false;
} 

function getAllKey() 
{ 
if(typeof(this)=="undefined")return false; 
var arr=new Array; 
if(this.length>0) 
{ 
var s = this.split("&"); 
for(var i in s) 
{ 
var sp=s[i].split("="); 
arr.push(sp[0]); 
} 
return arr; 
} 
else
  return false;
}
//获取来路函数结束

//获取来路分析开始
String.prototype.request=request;
String.prototype.getAllKey=getAllKey;

var url=location.search.substr(1);
var arg=url.getAllKey();
//var showPhoto="0755-82807056";
//alert(arg) 
//document.write("提交参数:"+arg) 
for(var cou in arg ) 
{
  if(arg[cou]=="se")
  {
	  if(readCookie('searchfrontier')=="undefined" || !readCookie('searchfrontier'))
       writeCookie('searchfrontier',url.request(arg[cou]),30);
  }
}
//获取来路分析结束

//cookie
//写入cookie
function writeCookie(name, value, hours)
{
var expire = "";
if(hours != null)
{
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire+";path=/";
}
//读取cookie
function readCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
{
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    {
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
}
return cookieValue;
}
//main--old
//var showPhoto="no data";
//check();
/*function check(){
  if (document.referrer){
    var chkUrl="";
    var str=document.referrer;
    var myReg = /\?se=(\w+)&/;
    if(myReg.test(str))
    {
       var r=str.match(myReg);
      chkUrl=r[1];
	  alert(chkUrl);
    }

	if(readCookie('searchfrontier')=="undefined" || !readCookie('searchfrontier') || readCookie('searchfrontier')!=chkUrl)
       writeCookie('searchfrontier',chkUrl,365);
	
  }

}*/

//读取cookie
function readCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
{
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    {
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
}
return cookieValue;
}

var showPhoto="0755-82807056";
check();
function check(){
    var chkUrl="";
    chkUrl=readCookie('searchfrontier');
	if(chkUrl!="")
	{
	switch(chkUrl)
	{
	   case "google":
	     showPhoto="0755-82724086";
		  break;
	   case "baidu":
	      showPhoto="0755-82709790";
		  break;
	   case "yahoo":
	      showPhoto="0755-82724509";
		  break;
	   default:
	      showPhoto="0755-82807056";
		  break;
	}
	}
	else
	  showPhoto="0755-82807056";
}