function CopyToClipboard(obj) {
        var inElement = document.getElementById(obj);
        if (inElement.createTextRange) {
            var range = inElement.createTextRange();
            if (range)
            range.execCommand('Copy');
        }
        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="http://www.liqucn.com/skin/liqucn.com/images/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
        document.getElementById(flashcopier).innerHTML = divinfo;
       return;
  }
}
function myselectaddr(inputurl)
{
	document.getElementById(inputurl).select();
	window.clipboardData.setData("text",document.getElementById(inputurl).value);
}
function getAppName(str_encode)
{
	return str_encode?encodeURIComponent(document.getElementById('editor_con').getElementsByTagName('h2')[0].innerHTML):document.getElementById('editor_con').getElementsByTagName('h2')[0].innerHTML;
}
function getAppComment(str_encode)
{
	return str_encode?encodeURIComponent('在历趣上看到'+getAppName()+'，装到手机上玩了下还不错，推荐推荐'):'在历趣上看到'+getAppName()+'，装到手机上玩了下还不错，推荐推荐';
}
function Postkaixin()
{
	var app_name = getAppName(0);
	var submitForm = document.createElement("FORM");
	document.body.appendChild(submitForm);
	
	submitForm.method = "POST";
	var elementName = 'rurl';var elementValue = location.href;
	
	var newElement = document.createElement("input");
	newElement.setAttribute('name',elementName);newElement.setAttribute('value',elementValue);newElement.setAttribute('type','hidden');
	submitForm.appendChild(newElement);
	var elementName = 'rtitle';var elementValue = app_name;
	var newElement = document.createElement("input");
	newElement.setAttribute('name',elementName);newElement.setAttribute('value',app_name);newElement.setAttribute('type','hidden');
	submitForm.appendChild(newElement);
	var elementName = 'rcontent';var elementValue = getAppComment(0);
	var newElement = document.createElement("input");
	newElement.setAttribute('name',elementName);newElement.setAttribute('value',elementValue);newElement.setAttribute('type','hidden');
	submitForm.appendChild(newElement);
	submitForm.action= "http://www.kaixin001.com/repaste/share.php";
	submitForm.target= "_blank";
    submitForm.submit();
}
function get_bookmark()
{
	var bookmark='\
&nbsp;&nbsp;<a href="javascript:Postkaixin()"><img style="vertical-align: middle;" src="http://www.liqucn.com/skin/liqucn.com/images/ico_kai.gif"> 开心网</a>\
&nbsp;&nbsp;<a target="_blank" href="http://share.renren.com/share/buttonshare.do?link='+location.href+'&title='+getAppName(1)+'"><img style="vertical-align: middle;" src="http://www.liqucn.com/skin/liqucn.com/images/ico_rr.gif"> 人人网</a>\
&nbsp;&nbsp;<a target="_blank" href="http://www.douban.com/recommend/?url='+location.href+'&title='+getAppName(1)+'&comment='+getAppComment()+'"><img style="vertical-align: middle;" src="http://www.liqucn.com/skin/liqucn.com/images/ico_dou.gif"> 豆瓣</a>\
</p>\
<p>通过QQ/MSN推荐：<input onclick="myselectaddr(\'inputurl1\')" id="inputurl1" name="inputurl1" type="text" size="32" value="'+location.href+'" class="keywordinput" />  <input onclick="myselectaddr(\'inputurl1\')" id="copyurl" name="copyurl" type="image" src="http://www.liqucn.com/skin/liqucn.com/images/copyurl.gif" alt="复制地址" onclick=\'CopyToClipboard("inputurl1")\'/></p>\
';
	return bookmark;
}
function AddToFavorite()
{   
    if (document.all){   
       window.external.addFavorite('http://www.liqucn.com/','手机软件、游戏、主题、壁纸免费下载-历趣');   
    }else if (window.sidebar){   
       window.sidebar.addPanel('手机软件、游戏、主题、壁纸免费下载-历趣', 'http://www.liqucn.com/', "");   
    }   
}
function DrawImage(ImgD){ var image=new Image(); var proportion =1; image.src=ImgD.src; if(image.width>0 && image.height>0){ if(image.width>200 || image.height>200){ if(image.width>image.height){ proportion = image.width/image.height; ImgD.width = 200; ImgD.height = Math.floor(200/proportion); }else{ proportion = image.height/image.width; ImgD.height = 200; ImgD.width = Math.floor(200/proportion); } }else{ ImgD.width=image.width; ImgD.height=image.height; } }}
function setCookie(name, value) 
{ 
  var argv=setCookie.arguments; 
  var argc=setCookie.arguments.length; 
  var expires=(argc>2)?argv[2]: null; 
  var path=(argc>3)? argv[3]: null; 
  var domain=(argc>4)? argv[4]: null; 
  var secure=(argc>5)? argv[5]: false; 
  document.Cookie=name+"="+escape 
	(value)+ 
  ((expires==null)?"":("; expires=" 
	+expires.toGMTString()))+ 
  ((path==null)?"":("; path="+path))+ 
  ((domain==null)?"":("; domain="+ 
	domain))+ 
  ((secure==true)?"; secure":""); 
}
function getCookie(name)//取cookies函数        
{
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	 //if(arr != null) return unescape(arr[2]); return null;
	if(arr != null) return decodeURI(arr[2]); return null; 
}
function delCookie(name)//删除cookie
{
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval=getCookie(name);
	if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

function AJAX_GET_CROSS_DOMAIN(url,parameters){
	var obj_if_cross = document.getElementById('iframe_cross_domain');
	if(obj_if_cross)
	{
		document.domain = 'liqucn.com';
		var cross_proxy = obj_if_cross.contentWindow;
		if(cross_proxy)	
		{
			var ajax_rnt = cross_proxy.AJAX_GET( url,parameters );
			return ajax_rnt?ajax_rnt:false;
		}
		else
			return false;
	}
	else
		return false;
}
function AJAX_POST_CROSS_DOMAIN(url,parameters){
	var obj_if_cross = document.getElementById('iframe_cross_domain');
	if(obj_if_cross)
	{
		document.domain = 'liqucn.com';
		var cross_proxy = obj_if_cross.contentWindow;
		if(cross_proxy)	
		{
			var ajax_rnt = cross_proxy.AJAX_POST( url,parameters );
			return ajax_rnt?ajax_rnt:false;
		}
		else
			return false;
	}
	else
		return false;
}
function checkCrossDomain()
{
	var obj_if_cross = document.getElementById('iframe_cross_domain');
	if(obj_if_cross)
	{
		document.domain = 'liqucn.com';
		return obj_if_cross.contentWindow?true:false;
	}
	else
		return false;
}

function AJAX_GET( link,parameters ) {
	var http_request = false; 
	if(window.XMLHttpRequest) http_request=new XMLHttpRequest();
	else if (window.ActiveXObject) http_request = new ActiveXObject("Microsoft.XMLHTTP");	
	if( !http_request ) return false; 
	window.status = "Please wait...";
	if(parameters=='nocache')	link += '&' + Math.floor( Math.random() * 100000000 ); /* IE caching AJAX */
	http_request.open('GET', link, false); 
	http_request.send(null); 
	window.status = ""; 
	if (http_request.readyState == 4 && http_request.status == 200 ) return http_request.responseText; 
	else return false;
}

function AJAX_POST( url, parameters ) {
	var http_request = false; 
	if(window.XMLHttpRequest) http_request=new XMLHttpRequest();
	else if (window.ActiveXObject) http_request = new ActiveXObject("Microsoft.XMLHTTP");	
	if( !http_request ) return false;
	http_request.open('POST', url, false);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
	if (http_request.readyState == 4 && http_request.status == 200 ) return http_request.responseText; 
	else return false;	
}

function browserIsIE6() {
	var version = parseFloat(navigator.appVersion.split('MSIE')[1])
	return version <= 6;
}
function browserIsFF() {
	return navigator.userAgent.indexOf("Firefox") > -1;
}

function getScroll(){
	if( self.pageYOffset ) return posY = self.pageYOffset;
	if( document.documentElement && document.documentElement.scrollTop ) return posY = document.documentElement.scrollTop;
	if( document.body ) return posY = document.body.scrollTop;
}

function setScrollTo( x, y ) {
	window.scrollTo( x, y ); 
}

function setSearchResult( result ) {
	document.getElementById( 'searchPhoneResultsContainer' ).innerHTML = result;
	var searchResultsDiv = document.getElementById( 'searchPhoneResults' );
	if( searchResultsDiv !== null ) searchResultsDiv.scrollTop = divScroll;
}
function trySetFirstDevice()
{
	var obj_result = document.getElementById('searchPhoneResults');
	if(obj_result)
	{
		var arr_a = obj_result.getElementsByTagName('a');
		if(arr_a.length==1)
		{
			if(document.all)
				arr_a[0].click();
			else
				eval( arr_a[0].href );
		}
	}
}
var lasttimeout = 0;
var gDlgParams = new Array();
var divScroll = 0;
function enterPhoneModel( keyword, event ) {
	divScroll = 0;
	keyword = trimString( keyword );
	//if( !keyword || keyword.length < 2 || event.keyCode == 32 ) return setSearchResult( '' );
	if( !keyword || keyword.length < 2 ) return setSearchResult( '' );
	if( event.keyCode == 13 )	{trySetFirstDevice();}	//回车直达唯一的一款机型
	if( lasttimeout ) clearTimeout(lasttimeout);
	lasttimeout = setTimeout('displayMatchedPhonesDialog(\"'+keyword+'\", "15")', 300 );
}

/* STEP 1 - Show callout to select a type of phone */
function displayPhoneCallout() {
	gDlgParams['file_download'] = false;
	var orderurl = "/api/ajax.php?action=dialog&type=phoneCallout";
	$.fn.colorbox({transition:"elastic", innerWidth:670, innerHeight:256, scrolling:false, preloading:false, overlayClose:false, iframe:false, opacity:0.5, href:orderurl, onClosed:function(){fixUrlWhenReChooseClose();}});
	cancel_select_phone();//取消以选机型的显示
	return true;
}
function displayPhoneCalloutWithDownload() {
	gDlgParams['file_download'] = true;
	var orderurl = "/api/ajax.php?action=dialog&type=phoneCallout";
	$.fn.colorbox({transition:"elastic", innerWidth:670, innerHeight:256, scrolling:false, preloading:false, overlayClose:false, iframe:false, opacity:0.5, href:orderurl});
	cancel_select_phone();//取消以选机型的显示
	return true;
}
function writeComment(IndexID) {
	gDlgParams['IndexID'] = IndexID;
	var orderurl = "/api/ajax.php?action=dialog&type=reviewDialog";
	$.fn.colorbox({transition:"elastic", innerWidth:670, innerHeight:256, scrolling:false, preloading:false, overlayClose:false, iframe:false, opacity:0.5, href:orderurl});
	return true;
}
function saveScrollPos(){
    divScroll = document.getElementById("searchPhoneResults").scrollTop;
}
/* STEP 2 - Show window with search phone results */
function displayMatchedPhonesDialog( keyword, displayItemsCount ) {
	//var result = AJAX_GET( '/api/ajax.php?action=dialog&type=searchPhones&keyword='+encodeURI(keyword)+'&itemsCount='+displayItemsCount,'' );
	//var result = AJAX_GET_CROSS_DOMAIN( 'http://www.liqucn.com/api/ajax.php?action=dialog&type=searchPhones&keyword='+encodeURI(keyword)+'&itemsCount='+displayItemsCount,'' );
	//if( result ) setSearchResult( result );
	$.ajax({
	  url: '/api/ajax.php?action=dialog&type=searchPhones&keyword='+encodeURI(keyword)+'&itemsCount='+displayItemsCount,
	  cache: true,
	  async: true,
	  success: function(html){
		if( html ) setSearchResult( html );
	  }
	}); 
}
function writeIntro(IndexID,div_id)
{
	$.ajax({
	  url: '/api/ajax.php?action=get&type=intro&IndexID='+IndexID,
	  cache: true,
	  async: true,
	  success: function(html){
		$("#"+div_id).append(html);
	  }
	});
}
function urlJump(url)
{
	document.location.href = url;
	//$.fn.colorbox({transition:'elastic', innerWidth:670, innerHeight:256, scrolling:false, preloading:false, overlayClose:false, iframe:false, opacity:0.5, html:''});
}
/* STEP 4 - Set phone */
function setUserDevice( deviceID ) {
	//var url = '/api/ajax.php?action=dialog&type=setUserDevice&deviceID='+deviceID+'&url='+encodeURIComponent(window.location.href);
	//var result = AJAX_GET( url,'nocache' );
	//var result = AJAX_GET_CROSS_DOMAIN( url,'nocache' );
	//if( result ) onPhoneFlowCompleted( result );
	$.ajax({
	  url: '/api/ajax.php?action=dialog&type=setUserDevice&deviceID='+deviceID+'&url='+encodeURIComponent(window.location.href),
	  cache: false,
	  async: true,
	  success: function(html){
		if( html ) onPhoneFlowCompleted( html );
	  }
	}); 
}

function onPhoneFlowCompleted( redirectURL ) {
	if(redirectURL)	redirectURL = redirectURL.replace('#auto_download','');
	if( gDlgParams['file_download'] == true ) //下载时弹出的窗口
	{
		var arr_t = redirectURL.split('|');
		showDownloadInfo('',arr_t[1]);
	}
	else
	{
		//window.location.href = redirectURL;
		urlJump(redirectURL);
	}
}
function fixUrlWhenDownloadClose()
{
	var user_model_id = getCookie('user_model_id'),user_brand_url = getCookie('user_brand_url'),user_brand_title = getCookie('user_brand_title'),user_model = getCookie('user_model');
	if(user_model_id)	//有机型信息，选了机型了
	{
		//确保内容页机型和cookie机型对应
		var model_page_url = window.location.href;
		model_page_url = model_page_url.replace('#auto_download','');
		if(model_page_url.search(/http:\/\/[^\/]+\/phone\/[^\/]+\/[^\/]+\//)>-1)	{model_page_url = model_page_url.replace(/phone\/[^\/]+\/[^\/]+\//,"");}
		if(model_page_url.search(/http:\/\/[^\/]+\/os\/[^\/]+\//)>-1)	{model_page_url = model_page_url.replace(/os\/[^\/]+\//,"");}
		model_page_url = model_page_url.indexOf('/phone/')>-1?model_page_url:model_page_url.replace('.com/','.com/phone/'+user_brand_url.toLowerCase()+'/'+user_model.toLowerCase()+'/');
		if(model_page_url)
		{
			if(gDlgParams['no_match'])
			{
				if(model_page_url.search(/http:\/\/[^\/]+\/phone\/[^\/]+\/[^\/]+\//)>-1)	{window.location.href = model_page_url.match(/http:\/\/[^\/]+\/phone\/[^\/]+\/[^\/]+\//);}
			}
			else
			{
				if(model_page_url.indexOf('/phone/')>-1 && window.location.href.indexOf('/phone/')==-1)	{window.location.href = model_page_url;}
			}
			return;
		}
	}
	else	//没选机型
	{
		
	}
}
function goToModelPage()
{
	var user_model_id = getCookie('user_model_id'),user_brand_url = getCookie('user_brand_url'),user_brand_title = getCookie('user_brand_title'),user_model = getCookie('user_model');
	if(user_model_id)	//有机型信息，选了机型了
	{
		//确保内容页机型和cookie机型对应
		var model_page_url = window.location.href.match(/http:\/\/[^\/]+\//);
		model_page_url += 'phone/'+user_brand_url.toLowerCase()+'/'+user_model.toLowerCase()+'/';
		urlJump(model_page_url);
	}
}
function fixUrlWhenReChooseClose()
{
	if(window.location.href.search(/http:\/\/[^\/]+\/phone\/[^\/]+\/[^\/]+\//)>-1)	{window.location.href = window.location.href.replace(/phone\/[^\/]+\/[^\/]+\//,"");}
	return;
}
function showDownloadInfo(IndexID,redirectURL)
{
	if(!IndexID && gDlgParams['IndexID'])	IndexID = gDlgParams['IndexID'];
	if(!gDlgParams['IndexID'] && IndexID)	gDlgParams['IndexID'] = IndexID;
	var user_model_id = getCookie('user_model_id'),user_brand_url = getCookie('user_brand_url'),user_brand_title = getCookie('user_brand_title'),user_model = getCookie('user_model');
	
	if(user_model_id)	//有机型信息
	{
		//确保内容页机型和cookie机型对应
		var model_page_url = window.location.href;
		model_page_url = model_page_url.replace('#auto_download','');
		if(model_page_url.search(/http:\/\/[^\/]+\/phone\/[^\/]+\/[^\/]+\//)>-1)	{model_page_url = model_page_url.replace(/phone\/[^\/]+\/[^\/]+\//,"");}
		if(model_page_url.search(/http:\/\/[^\/]+\/os\/[^\/]+\//)>-1)	{model_page_url = model_page_url.replace(/os\/[^\/]+\//,"");}
		model_page_url = model_page_url.indexOf('/phone/')>-1?model_page_url:model_page_url.replace('.com/','.com/phone/'+user_brand_url.toLowerCase()+'/'+user_model.toLowerCase()+'/');
		if( window.location.href.indexOf(model_page_url)==-1 && (window.location.href.search(/http:\/\/[^\/]+\/phone\/[^\/]+\/[^\/]+\//)>-1 || window.location.href.search(/http:\/\/[^\/]+\/os\/[^\/]+\//)>-1) )	//用户在os或model内容页选了个无关的机型，直接跳到选择的机型内容页，加上自动下载后缀。
		{
			window.location.href = model_page_url.replace(/phone\/[^\/]+\/[^\/]+\//,"")+'#auto_download';	//跳到不带os,model的内容页，利用hash触发，直接根据cookie跳带model的内容页可能会访问不存在的页
			return;
		}
		else	//不带model,os的内容页，或者与cookie吻合的model内容页
		{
			gDlgParams['IndexID'] = IndexID;
			var orderurl = "/api/ajax.php?action=dialog&type=downloadDialog";
			$.fn.colorbox({transition:"elastic", innerWidth:670, innerHeight:256, scrolling:false, preloading:false, overlayClose:false, iframe:false, opacity:0.5, href:orderurl, onComplete:function(){write_download_info(IndexID);}, onClosed:function(){fixUrlWhenDownloadClose();}});
		}
	}
	else	//没有机型信息，先选机型
	{
		displayPhoneCalloutWithDownload();
	}
}
function fix_url_by_cookie()
{
	var str_model_homepage_href = document.getElementById('model_homepage_href')?document.getElementById('model_homepage_href').href:'';
	var str_user_model = getCookie('user_model');
	var str_brand_url = getCookie('user_brand_url');
	var str_current_page_url = window.location.href;
	if( str_model_homepage_href && str_user_model && str_brand_url && str_model_homepage_href.indexOf(str_user_model.toLowerCase())==-1 )	//查看的页面带有model筛选，用户有机型cookie信息，并且页面model和机型cookie不一致
	{
		if(str_current_page_url.search(/http:\/\/[^\/]+\/phone\/[^\/]+\/[^\/]+\//)>-1)	{str_current_page_url = str_current_page_url.replace(/phone\/[^\/]+\/[^\/]+\//,"");}
		str_current_page_url = str_current_page_url.indexOf('/phone/')>-1?str_current_page_url:str_current_page_url.replace('.com/','.com/phone/'+str_brand_url.toLowerCase()+'/'+str_user_model.toLowerCase()+'/');
		window.location.href = str_current_page_url;
	}
}
function write_download_info(IndexID)
{
	if(!IndexID && gDlgParams['IndexID'])	IndexID = gDlgParams['IndexID'];
	if(!gDlgParams['IndexID'] && IndexID)	gDlgParams['IndexID'] = IndexID;
	var user_model_id = getCookie('user_model_id'),user_brand_url = getCookie('user_brand_url'),user_brand_title = getCookie('user_brand_title'),user_model = getCookie('user_model'),market_place_id = getCookie('market_place_id');
	//填充下载信息
	
	document.getElementById('downloadDialog_title').innerHTML = '下载'+getAppName();
	document.getElementById('ModalDownloadDialog_title').innerHTML = getAppName();
	
	if(user_brand_title && user_model)
	{
		document.getElementById('ModalUserModel').innerHTML = document.getElementById('ModalUserModel1').innerHTML = user_brand_title+' '+user_model;
	}
	document.getElementById('downloadDialog_number').innerHTML = IndexID+'.'+user_model_id;
	if(market_place_id)	document.getElementById('downloadDialog_number').innerHTML += '.'+market_place_id;	//market place exists
	document.getElementById('sms_downurl').href += document.getElementById('downloadDialog_number').innerHTML;

	var flag_have_match = false;
	gDlgParams['no_match'] = true;
	
	if( document.getElementById('content_mobile_href') && document.getElementById('content_mobile_href').getAttribute('mid')==user_model_id )	//机型内容页
	{
		document.getElementById('downloadDialog_fileurl').href = document.getElementById('content_mobile_href').href;
		if(market_place_id)
			document.getElementById('qr_code_img').src += escape(document.getElementById('downloadDialog_fileurl').href);
		else
			document.getElementById('qr_code_img').src += escape(document.getElementById('downloadDialog_fileurl').href.replace('&down_url','&market_place_id=5&down_url'));
		flag_have_match = true;
		gDlgParams['no_match'] = false;
	}
	else if( document.getElementById('download') )	//普通内容页
	{
		var arr_a = document.getElementById('download').getElementsByTagName('a');
		for(var i=arr_a.length-1;i>=0;i--)
		{
			if( arr_a[i].getAttribute('mid')==user_model_id )
			{
				document.getElementById('downloadDialog_fileurl').href = arr_a[i].href;
				if(market_place_id)
					document.getElementById('qr_code_img').src += escape(document.getElementById('downloadDialog_fileurl').href);
				else
					document.getElementById('qr_code_img').src += escape(document.getElementById('downloadDialog_fileurl').href.replace('&down_url','&market_place_id=5&down_url'));
				flag_have_match = true;
				gDlgParams['no_match'] = false;
				break;
			}
		}
	}
	if(!flag_have_match)	//页面内不存在该机型下载地址
	{
		noMatchAction();
	}
}

function noMatchAction()
{
	//document.getElementById('modalDlgTop_Green').innerHTML = document.getElementById('modalDlgTop_GreenError').innerHTML;
	document.getElementById('ModalContentAlign').innerHTML = document.getElementById('ModalContentAlignError').innerHTML;
}

function cleanPhoneBox( obj ) {
	if( obj.value == obj.defaultValue ) {
		obj.value = '';
		obj.className = '';
	}
}
function fillPhoneBox( obj ) {
	if( obj.value == '' ) {
		obj.value = obj.defaultValue;
		obj.className = 'phoneTypeDefaultValue';
	}
}
function trimString( str ) {
	return str.replace( /^\s+|\s+$/g, '' );
}

function setFocus( elemId ) {
	var elem = document.getElementById( elemId );
	if( elem ) elem.focus();
}
function auto_select_phone()
{
	var user_brand_title = getCookie('user_brand_title'),user_brand_url = getCookie('user_brand_url'),user_model = getCookie('user_model'),user_phone_info = getCookie('user_phone_info'),have_selected = getCookie('have_selected');
	if(user_phone_info)	//有机型cookie的
	{
		var span_select_phone = document.getElementById('span_select_phone');
		var info_select_phone = span_select_phone.getElementsByTagName('span');
		var a_select_phone = span_select_phone.getElementsByTagName('a');
		if(!info_select_phone[0])	//页面没有显示所选机型
		{
			a_select_phone[0].innerHTML = '重选机型';
			span_select_phone.innerHTML = "<span>"+user_phone_info+"</span> （"+span_select_phone.innerHTML+"）";
		}
		var h = document.location.host,p = document.location.pathname;
		if( (p=='/' || p=='/index.shtml') && (h=='www.liqucn.com'||h=='rj.liqucn.com'||h=='yx.liqucn.com'||h=='zt.liqucn.com'||h=='bz.liqucn.com') )//只在频道首页跳转
		{
			if(user_brand_url && user_model)	window.location.href = "http://"+h+"/phone/"+user_brand_url.toLowerCase()+"/"+user_model.toLowerCase()+"/";
		}
	}
	else		//无机型cookie
	{
		var h = document.location.host,p = document.location.pathname;
		if( (p=='/' || p=='/index.shtml') && (h=='www.liqucn.com'||h=='rj.liqucn.com'||h=='yx.liqucn.com'||h=='zt.liqucn.com'||h=='bz.liqucn.com') )//只在频道首页弹出
		{
			//if(!have_selected)	{ if( checkCrossDomain() ){displayPhoneCallout(true);}else{setTimeout(auto_select_phone(), 3000);} }	//一定时间内没弹过，才弹
			if(!have_selected)	{ $(document).ready(function(){displayPhoneCallout(true);}) }	//一定时间内没弹过，才弹
		}
	}
}
function cancel_select_phone()
{
	//AJAX_GET( '/api/ajax.php?action=dialog&type=cleanPhonesCookie'+'&' + Math.random(),'' );
	$.ajax({
	  url: '/api/ajax.php?action=dialog&type=cleanPhonesCookie',
	  cache: false,
	  async: false
	}); 
	var span_select_phone = document.getElementById('span_select_phone');
	var info_select_phone = span_select_phone.getElementsByTagName('span');
	var a_select_phone = span_select_phone.getElementsByTagName('a');
	if(info_select_phone[0])
	{
		a_select_phone[0].innerHTML = '选择机型';
		span_select_phone.removeChild(info_select_phone[0]);
		span_select_phone.innerHTML = span_select_phone.innerHTML.replace(' （','');
		span_select_phone.innerHTML = span_select_phone.innerHTML.replace('）','');
	}
}
var isRated = false;
function onrate( idx, field ) {
	if( !isRated) 
	{
		isRated = true;
		document.getElementById('ratingStatus').innerHTML = '感谢您的评价!';
	}
	else //if( isRated && idx==document.getElementById(field).value )
	{
		isRated = false;
		document.getElementById('ratingStatus').innerHTML = '';
	}
}
function ratingMove( idx, dirImg, field ) {
	if( !isRated ) 
	{
		for(i=1;i<=5;i++) 
		{
			if( i <= idx ) imgSrc = dirImg + 'ratingOn.png';	
			else imgSrc = dirImg + 'ratingOff.png';
			if( idx == 0 && i <= int(document.getElementById(field).value) ) imgSrc = dirImg + 'ratingOn.png';
			document.getElementById( 'ratingStar'+i ).src = imgSrc;
		}
		document.getElementById(field).value=(idx);
	}
	//alert(idx+' '+document.getElementById(field).value);
}
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}
function submitReview( url )
{
	//url = '/dialog/submit-feedback/' + url + '/';
	//if( document.getElementById( 'nameField' ).value=='' ) { document.getElementById( 'errorField' ).innerHTML='Please specify your name'; return false; }
	//if( document.getElementById( 'ratingField' ).value=='' ) { document.getElementById( 'errorField' ).innerHTML='Please specify your rating'; return false; }
	if(document.getElementById( 'textField' ).value || document.getElementById( 'ratingField' ).value)
	{
		var t_flag = submitUserFeedback(url, new Array('ratingField','textField') );
		var orderurl = "/api/ajax.php?action=dialog&type=confirmation";
		$.fn.colorbox({transition:"elastic", innerWidth:670, innerHeight:256, scrolling:false, preloading:false, overlayClose:false, iframe:false, opacity:0.5, href:orderurl});
	}
}
function submitUserFeedback( url, fields )
{
	var params='';
	for( key in fields )
	{
		var el = document.getElementById( fields[key] );
		if( params != '' ) params += "&";
		params += el.name + "=" + el.value;
	}
	if( params != '' ) params += "&";
	params += 'IndexID' + "=" + gDlgParams['IndexID'];
	if( params != '' ) params += "&";
	if( getCookie('user_brand_title') && getCookie('user_model') )	params += 'UserPhone' + "=" + getCookie('user_brand_title') + ' ' + getCookie('user_model');
	return AJAX_POST( url, params );
}

