//for iframe 自由调整高度，在IE/FIREFOX等测试过没有问题
function changeHight(iframename){
  var iFrm = parent.document.getElementById(iframename);
  var subWeb = iFrm.contentDocument;
  if(subWeb){
      if (subWeb.body.scrollHeight>30)
          iFrm.height = subWeb.body.scrollHeight+20;
      else
          iFrm.height=50;
      } 
      if(parent.document.frames[iframename].document && window.document.body.scrollHeight!="0"){
          parent.document.getElementById(iframename).style.height=window.document.body.scrollHeight;
      }
      if(parent.document.frames[iframename].document && window.document.body.scrollHeight=="0"){
          parent.document.getElementById(iframename).style.height=50;
     }
}

//for roll text
function rollText(rooltext,a,rollText_k,rollText_i){
	setInterval("rollText('rooltext',1,3,1)",3000);
	rollText_i+=a;
	if (rollText_i>rollText_k){rollText_i=1;}
	if (rollText_i==0){rollText_i=rollText_k;}
	//alert(i)
	for (var j=1; j<=rollText_k; j++){
		document.getElementById(rooltext+j).style.display="none";
	}
	document.getElementById(rooltext+rollText_i).style.display="block";
} 

//for roll text
function checkstatus(id){
	if(document.getElementById(id).style.display=='block')
	   document.getElementById(id).style.display='none'; 
	else
	   document.getElementById(id).style.display='block'; 
} 

function checkstoreregister(id){
	if(id=='directory'){
		document.getElementById('retail').style.display='none'; 
	    if(document.getElementById(id).style.display=='none')
	        document.getElementById(id).style.display='block'; 
	}
	else if(id=='retail'){
		document.getElementById('directory').style.display='none'; 
	    if(document.getElementById(id).style.display=='none')
	        document.getElementById(id).style.display='block'; 
	}
	else{
		document.getElementById('directory').style.display='none'; 
        document.getElementById('retail').style.display='none'; 
	}
} 



function checkregionstatus(region){
	regions = new Array('Northland','Auckland','Waikato','Bay Of Plenty','Gisborne','Hawkes Bay','Taranaki','Manawatu/Wanganui','Wellington','Nelson/Tasman','Marlborough','West Coast','Canterbury','Otago','Southland');
	tabregions = new Array('tabNorthland','tabAuckland','tabWaikato','tabBay Of Plenty','tabGisborne','tabHawkes Bay','tabTaranaki','tabManawatu/Wanganui','tabWellington','tabNelson/Tasman','tabMarlborough','tabWest Coast','tabCanterbury','tabOtago','tabSouthland');
	for(i=0;i<regions.length;i++){
         if(regions[i] == region){
			 if(document.getElementById(region).style.display=='block'){
	             document.getElementById(region).style.display='none'; 
				 document.getElementById("tab"+region).style.fontWeight='normal'; 
			 }
	         else{
	             document.getElementById(region).style.display='block'; 
				 document.getElementById("tab"+region).style.fontWeight='bold'; 
			 }
         }
         else{
              document.getElementById(regions[i]).style.display='none'; 
			  document.getElementById("tab"+regions[i]).style.fontWeight='normal'; 
         }
    }
} 


//for flash slash show in user page
function userflashads(pics, links, texts){
	
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cabversion=6,0,0,0" width="'+ pic_width +'" height="'+ swf_height +'">');
    document.write('<param name="movie" value="http://www.chinesetown.co.nz/images/flash/user/focus.swf">');
    document.write('<param name="quality" value="high"><param name="wmode" value="opaque">');
    document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&pic_width='+pic_width+'&pic_height='+pic_height+'&show_text='+show_text+'&txtcolor='+txtcolor+'&bgcolor='+bgcolor+'&button_pos='+button_pos+'&stop_time='+stop_time+'">');
    document.write('<embed src="fhttp://www.chinesetown.co.nz/images/flash/user/focus.swf" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&pic_width='+pic_width+'&pic_height='+pic_height+'&show_text='+show_text+'&txtcolor='+txtcolor+'&bgcolor='+bgcolor+'&button_pos='+button_pos+'&stop_time='+stop_time+'" quality="high" width="'+ pic_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
}




//显示缩略图
function DrawImage(ImgD,width_s,height_s){
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
        flag=true;
        if(image.width/image.height>=width_s/height_s){
            if(image.width>width_s){
                ImgD.width=width_s;
                ImgD.height=(image.height*width_s)/image.width;
            }else{
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
        }
        else{
            if(image.height>height_s){
                ImgD.height=height_s;
                ImgD.width=(image.width*height_s)/image.height;
            }else{
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
        }
    }
}

function switchsearchtype(id){
   tabarr = new Array(document.getElementById('tab1'),document.getElementById('tab2'),document.getElementById('tab3'),document.getElementById('tab4'),document.getElementById('tab5'));
   tabvalue = new Array('news','business','item','shop','shopper');
   for(i=0;i<tabarr.length;i++){
      if(i==id){
	     tabarr[id].className='home_search_active';
		 document.homesearch.searchtype.value=tabvalue[id];
	  }
      else
	     tabarr[i].className='home_search_nonactive';
   }
}

function switchsiteinfo(id){
   classarr = new Array('catebg_fir','catebg_sec','catebg_thi');
   tabvalue = new Array(document.getElementById('siteinfocontent1'),document.getElementById('siteinfocontent2'),document.getElementById('siteinfocontent3'));
   
   for(i=0;i<classarr.length;i++){
      if(i==id){
	     document.getElementById('siteinfo_tab').className = classarr[i];
		 tabvalue[id].className='content_active';
	  }
      else{
		 tabvalue[i].className='content_gray';
		 
	  }
   }
}

function switchpromotion(id){
   classarr = new Array('catebg_fir','catebg_sec','catebg_thi');
   tabvalue = new Array(document.getElementById('promotioncontent1'),document.getElementById('promotioncontent2'),document.getElementById('promotioncontent3'));
   
   for(i=0;i<classarr.length;i++){
      if(i==id){
	     document.getElementById('promotion_tab').className = classarr[i];
		 tabvalue[id].className='content_active';
	  }
      else{
		 tabvalue[i].className='content_gray';
		 
	  }
   }
}

function switchzhaoshang(id){
   classarr = new Array('catebg_fir','catebg_sec','catebg_thi');
   tabvalue = new Array(document.getElementById('zhaoshangcontent1'),document.getElementById('zhaoshangcontent2'),document.getElementById('zhaoshangcontent3'));
   
   for(i=0;i<classarr.length;i++){
      if(i==id){
	     document.getElementById('zhaoshang_tab').className = classarr[i];
		 tabvalue[id].className='content_active';
	  }
      else{
		 tabvalue[i].className='content_gray';
		 
	  }
   }
}


function copyContent(value) { 
	
	if (window.clipboardData) {  
        window.clipboardData.setData("Text",value); 
	}else{
		var flashcopier = 'flashcopier';  
        if(!document.getElementById(flashcopier)) {  
          var divholder = document.createElement('div');  
          divholder.id = flashcopier;  
          document.body.appendChild(divholder);  
        }  
        document.getElementById(flashcopier).innerHTML = '';  
        var divinfo = '<embed src="clipboard.swf" FlashVars="clipboard='+encodeURIComponent(value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';  
        document.getElementById(flashcopier).innerHTML = divinfo;  
	}
    alert("复制成功，请粘贴到你的QQ/MSN上推荐给你的好友!"); 
}

