// JavaScript Document
/*dreamweaver js function*/

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var basehref="http://www.2973.com/";

function CreateHeadScript(file){
	head=document.getElementsByTagName('head').item(0); 
    var new_element;
    new_element=document.createElement("script");
    new_element.setAttribute("type","text/javascript");
    new_element.setAttribute("src",file);
    void(head.appendChild(new_element));
}

function changeLange(loc){
   	  ajaxLang(loc);

   	  var loc1;
   	  if(loc=='LANG_TS'){
   	  	loc1="tc";
   	  }else if(loc=='LANG_EN'){
   	  	loc1="en";
   	  }else{
   	  	loc1="sc";
   	  }
   	  var currentPath=location.href.toString();
			var switchTc='/tc/';
			var switchSc='/sc/';
			var switchEn='/en/';
			if (currentPath.indexOf(switchTc)>0){
					currentPath=currentPath.replace(switchTc, '/'+loc1+'/');
			}else if (currentPath.indexOf(switchSc)>0){
					currentPath=currentPath.replace(switchSc, '/'+loc1+'/');
			}else if (currentPath.indexOf(switchEn)>0){
				currentPath=currentPath.replace(switchEn, '/'+loc1+'/');
			}
			setTimeout("document.location.href ='"+ currentPath +"';",500);
   }

/**
 * ========================================
 *
 * chLang
 * ----------------------------------------
 *
 */
 
function chLang(lang) {
	
	var currentPath=location.href.toString();
	var switchTc='/tc/';
	var switchSc='/sc/';
	var switchEn='/en/';
	if (currentPath.indexOf(switchTc)>0){
			currentPath=currentPath.replace(switchTc, '/'+lang+'/');
	}else if (currentPath.indexOf(switchSc)>0){
			currentPath=currentPath.replace(switchSc, '/'+lang+'/');
	}else if (currentPath.indexOf(switchEn)>0){
			currentPath=currentPath.replace(switchEn, '/'+lang+'/');
	}
	document.location=currentPath;
}

 function hasClass(ele,cls) {

	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));

} 

function addClass(ele,cls) {

	if (!this.hasClass(ele,cls)) ele.className += " "+cls;

}

function removeClass(ele,cls) {
	if (hasClass(ele,cls)) {
		var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
		ele.className=ele.className.replace(reg,' ');
	}
}
function hlLearning() {
	var currentPath = location.href.toString();

	var pageArray = new Array();	
	pageArray.push(new Array("product_index.asp","header_product",""));
	pageArray.push(new Array("function_index.asp","header_function",""));

	pageArray.push(new Array("news-and-events.asp","header_news",""));
	pageArray.push(new Array("advertising-sharing.asp","header_sharing",""));
	pageArray.push(new Array("advertising-sharing.html","header_sharing",""));
	pageArray.push(new Array("contact.asp","header_contact",""));
	pageArray.push(new Array("enquiry.html","header_enquiry",""));
	
	pageArray.push(new Array("corporate-company.html","profile1",""));
	pageArray.push(new Array("corporate-vision.html","vision",""));
	pageArray.push(new Array("corporate-brand.html","brand",""));
	pageArray.push(new Array("corporate-award.html","award",""));
	pageArray.push(new Array("corporate-product.html","product_overview",""));
	
	pageArray.push(new Array("oral-care-tips-basic-index.html","header_oralcare",""));
	pageArray.push(new Array("oral-care-tips-white-index.html","header_oralcare",""));
	pageArray.push(new Array("oral-care-tips-tooth-sensitivity-index.html","header_oralcare",""));
	pageArray.push(new Array("oral-care-tips-tooth-whitening.html","header_oralcare",""));
	pageArray.push(new Array("oral-care-tips-tooth-sensitivity.html","header_oralcare",""));
	pageArray.push(new Array("hygiene.html","header_oralcare",""));
	pageArray.push(new Array("gum-disease.html","header_oralcare",""));
	pageArray.push(new Array("firstaid.html","header_oralcare",""));
	pageArray.push(new Array("oral-care-tips-cavities.html","header_oralcare",""));
	pageArray.push(new Array("calculus.html","header_oralcare",""));
	pageArray.push(new Array("oral-care-tips-brush.html","header_oralcare",""));
	pageArray.push(new Array("oral-care-tips-basic-halitosis.html","header_oralcare",""));
	pageArray.push(new Array("halitosis.html","header_oralcare",""));
	  

	for(var i=0;i<pageArray.length;i++){

		if (currentPath.indexOf(pageArray[i][0]) > 0){
			
			addClass(document.getElementById(pageArray[i][1]), "present_cat2");

			if(pageArray[i][2].length > 1){
				document.getElementById(pageArray[i][1]).style.fontWeight = pageArray[i][2];
			}
			break;
		}
	}
}
function centerpopwin(url,winname,winwidth,winheight){
  var screenW = 1024, screenH = 768;
  if (document.all || document.layers) {
    screenW = screen.availWidth;
    screenH = screen.availHeight;
  }
  var pw = winwidth>0?winwidth:screenW, ph = winheight>0?winheight:screenH;
  var lpos = (screenW-pw)/2-5, tpos = (screenH-ph)/2;
  if (tpos+ph>screenH-20){
    tpos = 0;
    ph = screenH-20;
  }
  if (lpos+pw>screenW-2){
    lpos = 1;
    pw = screenW-2;
  }
  window.open(url, winname, 'width='+pw+',height='+ph+',resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,left='+lpos+',top='+tpos); 
}
function noticepopup(){
  centerpopwin('http://images.2973.com/pdf/bidder.pdf','bidder_deposit',800,600);
}

