
var userAgent = " " + navigator.userAgent.toLowerCase();
nn = userAgent.indexOf( "mozilla" ) > 0;
if( userAgent.indexOf( "compatible" ) > 0 )
    nn = false;
ie = userAgent.indexOf( "msie" ) > 0;
mac = userAgent.indexOf( "mac" ) > 0;
if(ie && !mac)
	{
	var vb= "";	
      	vb += '<SCR' + 'IPT LANGUAGE=VBScript\> \n';
		vb += 'Function VBFlash() \n';
        vb += 'on error resume next \n';
        vb += 'Dim C \n';
        vb += 'set C = vbNull \n';
        vb += 'Dim tver \n';
        vb += 'set tver = 0 \n';
		vb += 'Dim svr \n';
        vb += 'svr = "ShockwaveFlash.ShockwaveFlash" \n';
        vb += 'set C = CreateObject(svr) \n';
        vb += 'if (IsObject(C)) then \n';
		vb += 'Dim mVer \n';
        vb += 'Dim sVer \n';
        vb += 'Dim cVer \n';
        vb += 'cVer = C.FlashVersion() \n';
        vb += 'mVer = int(cVer / 65536) \n';
        vb += 'sVer = cVer mod 65536 \n';
        vb += 'if (sVer < 100) then sVer = "0" + CStr(sVer) \n';
        vb += 'if (sVer < 10)  then sVer = "0" + CStr(sVer) \n';
        vb += 'tver = CStr(mVer) + ".0" + CStr(sVer) \n';
        vb += 'end if \n';
        vb += 'VBFlash = tver \n';
        vb += 'End Function \n';
      	vb += 'Function VBGetFlashTE \n';
        vb += 'on error resume next \n';
        vb += 'Dim C \n';
        vb += 'set C = vbNull \n';
        vb += 'Dim svVer \n';
        vb += 'set svVer = 0 \n';
        vb += 'For i = 10 To 1 Step -1 \n';
        vb += 'Dim svr \n';
        vb += 'svr = "ShockwaveFlash.ShockwaveFlash." + CStr(i) \n';
        vb += 'set C = CreateObject(svr) \n';
        vb += 'if (IsObject(C)) then \n';
        vb += 'svVer = i \n';
        vb += 'Exit For \n';
        vb += 'end if \n';
        vb += 'Next \n';
        vb += 'VBGetFlashTE = svVer \n';
        vb += 'End Function \n';
	vb += '</SCR' + 'IPT\> \n';
	document.write(vb);
	}
    if(ie && !mac)
		{
	      	var fVer = VBFlash() || 0;
		if (fVer == 3.0008){var svVer = VBGetFlashTE();
        	if (svVer > fVer){fVer = 4.0000;}}
		else if (!fVer){fVer = VBGetFlashTE() || 0;}
		else if (fVer == 4){fVer = 4.0015;}}
    else{var fVer=0;}
      function setF()
      {arr = navigator.plugins;arrl = arr.length;
        for (var i=0; i < arrl; i++){plug = arr[i];desc   = plug.description;
          if (desc.indexOf("Shockwave Flash ") != -1){var vLoc = desc.indexOf("Shockwave Flash ");
            var vStr = desc.substring(vLoc + 16,desc.length);var sVer;var mVer;vLoc = vStr.indexOf(" r");
            if (vLoc != -1){mVer = vStr.substring(0,vLoc);sVer = vStr.substring(vLoc + 2,vStr.length);
            fnVer = parseFloat(mVer + (sVer < 100 ? "0" : "") + (sVer < 10 ? "0" : "") + sVer);}
            else{fnVer = parseFloat(vStr);}}}}
var fnVer = 0;
setF();
var myFlash;
if(!fVer || fVer==0){myFlash=fnVer;}
else{myFlash=fVer;}
function hasFlash(bVer){if(myFlash<bVer){return false;}else{return true;}}
flashEnabled = hasFlash(7);

	function cookiesEnabled () {
	cookieSet('test', 'sitehelptest', 180, '/' );
	var cookieTest = cookieGet('test');
     	if (cookieTest == "") { 
     		return false; 
     	} else {
     		cookieDelete('test', '/');
     		return true;
     	}
     }
	function cookieDelete(name, path, domain) {
		var value = cookieGet(name);
		if( !path ) { path = '/'; }
		if( !domain ) { domain = ''; }
		if (value != null) {
			document.cookie = name + '=' + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + '; expires=Thu, 01-Jan-70 00:00:01 GMT';
		}
		return value;
	}
	function cookieGet(name) {
		var docCookie = document.cookie;
		var prefix = name + "=";
		var start = docCookie.indexOf("; " + prefix);
		if (start == -1) {
			start = docCookie.indexOf(prefix);
			if (start != 0) return null;
		}	else {
			start += 2;
		}	
		var end = docCookie.indexOf(";", start);
		if (end == -1) {
			end = docCookie.length;
		}
		return unescape(docCookie.substring(start + prefix.length, end));
	}
	function cookieSet(name, value, daysToKeep, path, domain, secure) {
		var today = new Date();
		var expires = new Date();
		if( !daysToKeep ) { daysToKeep = 1; }
		expires.setTime(today.getTime() + 3600000*24*daysToKeep);
		if( !path ) { path = '/'; }
		if( !domain ) { domain = ''; }
		if( !secure ) { secure = ''; }
		var tmpCookie = name + '=' + escape(value) + ((expires) ? '; expires=' + expires.toGMTString() : '') + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + ((secure) ? '; secure' : '');
		document.cookie = tmpCookie;
	}
	function setZipCookie( zipCode ) {
		if((IsNumeric( zipCode )) && (IsZipCode( zipCode ))) {
			cookieDelete('zip', '/', '');
			cookieSet("zip", zipCode, 180, '/');
		}
	}
	function CheckDealerLocator() {
		var frmLocator = document.forms["find_dealer"];
		
		if(frmLocator.txtSearchBy.value == "") {
			alert("Ban phai nhap tu khoa tim kiem!");
			return false;
		}
		if(frmLocator.txtSearchBy.value == "Tu khoa") {
			alert("Ban phai nhap tu khoa tim kiem!");
			return false;
		}
		cookieDelete('dlr_search', '/', '');
		cookieSet('dlr_search', frmLocator.txtSearchBy.value, 180, '/');
		setZipCookie( frmLocator.txtSearchBy.value );
		return true;
	}
	function ChangeStoredZip() {
		var frmZip = document.forms["frmChangeZip"];
		if((IsNumeric(frmZip.txtZip.value)) && (IsZipCode(frmZip.txtZip.value))) {
			setZipCookie( frmZip.txtZip.value );
			cookieSet("dlr_search", frmZip.txtZip.value, 180, '/');
			document.location.reload();
		}
	}
	function ClearDealerBox() {
		var sValue = cookieGet("dlr_search");
		if(!sValue) { 
			sValue = cookieGet( 'zip' );
			if(!sValue) {
				sValue = ""; 
			}
		}
		if (document.forms["find_dealer"].txtSearchBy.value == "Tu khoa") {
			if(sValue == "") {
				document.forms["find_dealer"].txtSearchBy.value = "";
			} else {
				document.forms["find_dealer"].txtSearchBy.value = sValue;
			}
		} else {
			if(sValue == "") {
				document.forms["find_dealer"].txtSearchBy.value = "";
			} else {
				document.forms["find_dealer"].txtSearchBy.value = sValue;
			}
		}
	}
	function findObj(n, d) { //v4.01
		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
		if(!x && d.getElementById) x=d.getElementById(n); return x;
	}	
	function navBrowserDetectLite() {
		var ua = navigator.userAgent.toLowerCase(); 
		this.ua = ua;
		this.isGecko     = (ua.indexOf('gecko') != -1);
		this.isMozilla   = (this.isGecko && ua.indexOf("gecko/") + 14 == ua.length);
		this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
		this.isIE        = ( (ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1) ); 
		this.isOpera     = (ua.indexOf("opera") != -1); 
		this.isKonqueror = (ua.indexOf("konqueror") != -1); 
		this.isIcab      = (ua.indexOf("icab") != -1); 
		this.isAol       = (ua.indexOf("aol") != -1); 
		this.isWebtv     = (ua.indexOf("webtv") != -1); 
		this.isOmniweb   = (ua.indexOf("omniweb") != -1);
		this.isDreamcast = (ua.indexOf("dreamcast") != -1);
		this.isSafari	 = (ua.indexOf("safari") != -1);
		this.isIECompatible = ( (ua.indexOf("msie") != -1) && !this.isIE);
		this.isNSCompatible = ( (ua.indexOf("mozilla") != -1) && !this.isNS && !this.isMozilla);
		this.versionMinor = parseFloat(navigator.appVersion); 
			if (this.isNS && this.isGecko) {
			this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
		}
		else if (this.isIE && this.versionMinor >= 4) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
		}
		else if (this.isOpera) {
			if (ua.indexOf('opera/') != -1) {
				this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
			}
			else {
				this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
			}
		}
		else if (this.isKonqueror) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
		}
		else if (this.isIcab) {
			if (ua.indexOf('icab/') != -1) {
				this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
			}
			else {
				this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
			}
		}
		else if (this.isWebtv) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('webtv/') + 6 ) );
		}
		this.versionMajor = parseInt(this.versionMinor); 
		this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
		this.isWin   = (ua.indexOf('win') != -1);
		this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1) );
		this.isMac   = (ua.indexOf('mac') != -1);
		this.isUnix  = (ua.indexOf('unix') != -1 || ua.indexOf('linux') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
		this.isNS4x = (this.isNS && this.versionMajor == 4);
		this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
		this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
		this.isNS4up = (this.isNS && this.versionMinor >= 4);
		this.isNS6x = (this.isNS && this.versionMajor == 6);
		this.isNS6up = (this.isNS && this.versionMajor >= 6);
		this.isIE4x = (this.isIE && this.versionMajor == 4);
		this.isIE4up = (this.isIE && this.versionMajor >= 4);
		this.isIE5x = (this.isIE && this.versionMajor == 5);
		this.isIE55 = (this.isIE && this.versionMinor == 5.5);
		this.isIE5up = (this.isIE && this.versionMajor >= 5);
		this.isIE6x = (this.isIE && this.versionMajor == 6);
		this.isIE6up = (this.isIE && this.versionMajor >= 6);
		this.isIE4xMac = (this.isIE4x && this.isMac);
	}
	var browser = new navBrowserDetectLite();
	function swapImage() {
	  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	function swapImage2() {
	  var i,j=0,x,a=swapImage2.arguments; document.sr2=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=findObj(a[i]))!=null){document.sr2[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	function swapImage3() {
	  var i,j=0,x,a=swapImage3.arguments; document.sr3=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=findObj(a[i]))!=null){document.sr3[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	function swapImage4() {
	  var i,j=0,x,a=swapImage4.arguments; document.sr4=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=findObj(a[i]))!=null){document.sr4[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	function swapImgRestore() {
		var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	function swapImgRestore2() {
		var i,x,a=document.sr2; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	function swapImgRestore3() {
		var i,x,a=document.sr3; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	function swapImgRestore4() {
		var i,x,a=document.sr4; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
function flashmain( swfPath, imgPath, width, height, url, wmode, bgcol) {
	if (bgcol == undefined) bgcol= "#ffffff";
	if (flashEnabled) {
			document.write('	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" height="' + height + '" width="' + width + '">' );
			document.write('		<param name="allowScriptAccess" value="sameDomain" />' );
			document.write('		<param name="movie" value="' + swfPath + '">' );
			document.write('		<param name="quality" value="high">' );
			document.write('		<param name="play" value="true">' );
			document.write('		<param name="wmode" value="' + wmode + '">' );
			document.write('		<param name="bgcolor" value="' + bgcol + '" />' );
			document.write('		<embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="' + swfPath + 
						   			'" type="application/x-shockwave-flash" height="' + height + '" width="' + width + 
									'" play="true" quality="high" bgcolor="' + bgcol + '" allowscriptaccess="sameDomain"' );
			document.write(' wmode="' + wmode + '" ');
			document.write('>' );
			document.write('	</object>' );
		} else { // no Flash
		if (!url) {
			if(imgPath == "../img/ttd.jpg"){
				document.write('<img src="' + imgPath + '" width="' + width + '" height="200" border="0" usemap="#ibanner" />' );
			} else {
				document.write('<a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"><img src="' + imgPath + '" width="' + width + '" height="' + height + '" border="0" /></a>' );
			}
		} else if (url=="NOURL") { // * note special case
			document.write('<img src="' + imgPath + '" width="' + width + '" height="' + height + '" border="0" />' );
		} else {
			if(imgPath == "../img/ttd.jpg"){
				document.write('<img src="' + imgPath + '" width="' + width + '" height="200" border="0" usemap="#ibanner" />' );
			} else {
				document.write('<a href="' + url + '"><img src="' + imgPath + '" width="' + width + '" height="' + height + '" border="0" /></a>' );
			}
		}
	}
}
function flashcompany( swfPath, imgPath, width, height, url, wmode, bgcol) {
	if (bgcol == undefined) bgcol= "#ffffff";
	if (flashEnabled) {
			document.write('	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" height="' + height + '" width="' + width + '">' );
			document.write('		<param name="allowScriptAccess" value="sameDomain" />' );
			document.write('		<param name="movie" value="' + swfPath + '">' );
			document.write('		<param name="quality" value="high">' );
			document.write('		<param name="play" value="true">' );
			document.write('		<param name="wmode" value="' + wmode + '">' );
			document.write('		<param name="bgcolor" value="' + bgcol + '" />' );
			document.write('		<embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="' + swfPath + 
						   			'" type="application/x-shockwave-flash" height="' + height + '" width="' + width + 
									'" play="true" quality="high" bgcolor="' + bgcol + '" allowscriptaccess="sameDomain"' );
			document.write(' wmode="' + wmode + '" ');
			document.write('>' );
			document.write('	</object>' );
		} else { // no Flash
		if (!url) {
			if(imgPath == "../img/congty_banner.jpg"){
				document.write('<img src="' + imgPath + '" width="' + width + '" height="200" border="0" usemap="#ibanner" />' );
			} else {
				document.write('<a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"><img src="' + imgPath + '" width="' + width + '" height="' + height + '" border="0" /></a>' );
			}
		} else if (url=="NOURL") { // * note special case
			document.write('<img src="' + imgPath + '" width="' + width + '" height="' + height + '" border="0" />' );
		} else {
			if(imgPath == "../img/congty_banner.jpg"){
				document.write('<img src="' + imgPath + '" width="' + width + '" height="200" border="0" usemap="#ibanner" />' );
			} else {
				document.write('<a href="' + url + '"><img src="' + imgPath + '" width="' + width + '" height="' + height + '" border="0" /></a>' );
			}
		}
	}
}
function flashcatalogues( swfPath, imgPath, width, height, url, wmode, bgcol) {
	if (bgcol == undefined) bgcol= "#ffffff";
	if (flashEnabled) {
			document.write('	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" height="' + height + '" width="' + width + '">' );
			document.write('		<param name="allowScriptAccess" value="sameDomain" />' );
			document.write('		<param name="movie" value="' + swfPath + '">' );
			document.write('		<param name="quality" value="high">' );
			document.write('		<param name="play" value="true">' );
			document.write('		<param name="wmode" value="' + wmode + '">' );
			document.write('		<param name="bgcolor" value="' + bgcol + '" />' );
			document.write('		<embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="' + swfPath + 
						   			'" type="application/x-shockwave-flash" height="' + height + '" width="' + width + 
									'" play="true" quality="high" bgcolor="' + bgcol + '" allowscriptaccess="sameDomain"' );
			document.write(' wmode="' + wmode + '" ');
			document.write('>' );
			document.write('	</object>' );
		} else { // no Flash
		if (!url) {
			if(imgPath == "../img/ecatalogues_banner.jpg"){
				document.write('<img src="' + imgPath + '" width="' + width + '" height="200" border="0" usemap="#ibanner" />' );
			} else {
				document.write('<a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"><img src="' + imgPath + '" width="' + width + '" height="' + height + '" border="0" /></a>' );
			}
		} else if (url=="NOURL") { // * note special case
			document.write('<img src="' + imgPath + '" width="' + width + '" height="' + height + '" border="0" />' );
		} else {
			if(imgPath == "../img/ecatalogues_banner.jpg"){
				document.write('<img src="' + imgPath + '" width="' + width + '" height="200" border="0" usemap="#ibanner" />' );
			} else {
				document.write('<a href="' + url + '"><img src="' + imgPath + '" width="' + width + '" height="' + height + '" border="0" /></a>' );
			}
		}
	}
}
function flashproduct( swfPath, imgPath, width, height, url, wmode, bgcol) {
	if (bgcol == undefined) bgcol= "#ffffff";
	if (flashEnabled) {
			document.write('	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" height="' + height + '" width="' + width + '">' );
			document.write('		<param name="allowScriptAccess" value="sameDomain" />' );
			document.write('		<param name="movie" value="' + swfPath + '">' );
			document.write('		<param name="quality" value="high">' );
			document.write('		<param name="play" value="true">' );
			document.write('		<param name="wmode" value="' + wmode + '">' );
			document.write('		<param name="bgcolor" value="' + bgcol + '" />' );
			document.write('		<embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="' + swfPath + 
						   			'" type="application/x-shockwave-flash" height="' + height + '" width="' + width + 
									'" play="true" quality="high" bgcolor="' + bgcol + '" allowscriptaccess="sameDomain"' );
			document.write(' wmode="' + wmode + '" ');
			document.write('>' );
			document.write('	</object>' );
		} else { // no Flash
		if (!url) {
			if(imgPath == "../img/sanpham_banner.jpg"){
				document.write('<img src="' + imgPath + '" width="' + width + '" height="200" border="0" usemap="#ibanner" />' );
			} else {
				document.write('<a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"><img src="' + imgPath + '" width="' + width + '" height="' + height + '" border="0" /></a>' );
			}
		} else if (url=="NOURL") { // * note special case
			document.write('<img src="' + imgPath + '" width="' + width + '" height="' + height + '" border="0" />' );
		} else {
			if(imgPath == "../img/sanpham_banner.jpg"){
				document.write('<img src="' + imgPath + '" width="' + width + '" height="200" border="0" usemap="#ibanner" />' );
			} else {
				document.write('<a href="' + url + '"><img src="' + imgPath + '" width="' + width + '" height="' + height + '" border="0" /></a>' );
			}
		}
	}
}
function findPosition( oLink ) {
	if( oLink.offsetParent ) {
		for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) {
			posX += oLink.offsetLeft;
			posY += oLink.offsetTop;
		}
		document.getElementById("feature_flash").style.visibility = "visible";
		document.getElementById("feature_flash").style.top = posY-120 + "px";
		return [ posX, posY ];
		} else {
		return [ oLink.x, oLink.y ];
	}
}
function removeFlash() 
{
	document.getElementById("feature_flash").innerHTML = "";
	document.getElementById("feature_flash").style.visibility = "hidden";
}
function trim(str) {
	str = this != window? this : str;
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
function lookupSwfFromFeature( featureID ) {
	featureID = trim(featureID);
	var tmpSwf = "";
	tmpSwf = featureID;
	drawSpecsFlash( tmpSwf );
}

function limitedBrowser() {
	var browserDetect = new navBrowserDetectLite();
	if( browserDetect.isSafari) {
		return true;
	} else {
		return false;
	}
}