var chengcai_url = 'http://market.chengcai.net';
//var chengcai_url = 'http://www.chengcai.com';
//var chengcai_hot_prefix = chengcai_url+'/dll_hotad.php?';
if(typeof chengcai_ad_num == "undefined")
var chengcai_ad_num = 4;
if(typeof chengcai_ad_style == "undefined")
var chengcai_ad_style = 1;
if(typeof chengcai_ad_width == "undefined")
var chengcai_ad_width = 728;
if(typeof chengcai_ad_height == "undefined")
var chengcai_ad_height = 90;
if(typeof chengcai_ad_random == "undefined")
var chengcai_ad_random = 0;
if(typeof chengcai_ad_pic == "undefined")
var chengcai_ad_pic = 0;
if(typeof chengcai_ad_length == "undefined")
var chengcai_ad_length = 0;
if(typeof chengcai_ad_rule == "undefined")
var chengcai_ad_rule = 0;
if(typeof listTable == "undefined"){
	var listTable = 1;
} else {
	listTable = listTable+1;
}
if(typeof uplist == "undefined"){
	var uplist = chengcai_ad_num;
	//	document.write('style'+chengcai_ad_style+'<br>');
	//	document.write(uplist);
} else {
	uplist = uplist+chengcai_ad_num;
	//	document.write('style'+chengcai_ad_style+'<br>');
	//	document.write(uplist);
}

function geturl()
{
	url = chengcai_hot_prefix;
	url += "style=" + chengcai_ad_style;
	url += "&num=" + chengcai_ad_num;
	url += "&listtable=" + listTable;
	url += "&uplist=" + uplist;
	url += "&random=" + chengcai_ad_random;
	url += "&pic=" + chengcai_ad_pic;
	url += "&length=" + chengcai_ad_length;
	url += "&rule=" + chengcai_ad_rule;
	//		document.write(url);
	return url;
}

function showad()
{
	var chengcai_ad = '<script language="javascript" src="'+geturl()+'"></script>';
	return chengcai_ad;
}
/*document.write("<span id=\"chengcaihot"+listTable+"\"></span>");
document.write(showad());*/
chengcai_ad_random = 0;

include_js(chengcai_url+"/js/prototype.js");
setTimeout('include_js("'+chengcai_url+'/js/effects.js");',1000);

function include_js(path)
{
	var sobj = document.createElement('script');
	sobj.type = "text/javascript";
	sobj.src = path;
	var headobj = document.getElementsByTagName('head')[0];
	headobj.appendChild(sobj);
}
function create()
{
	document.write('<div id="detailedSummaryBG" style="display:none;width:430px;height:91px;position:absolute;z-index:10" onMouseOver="javascript:inBoxFlag=true;" onMouseOut="javascript:inBoxFlag=false;" ></div>');
	document.write('<div id="detailedSummaryBox" style="display:none;z-index:11;position:absolute;"><table cellpadding="0" cellspacing="0" border="0" width="400" id="popInnerBox" onMouseOver="javascript:inBoxFlag=true;" onMouseOut="javascript:inBoxFlag=false;" ><tr><td><div id="detailedSummaryContent" onMouseOver="javascript:inBoxFlag=true;" onMouseOut="javascript:inBoxFlag=false;">稍后……</div></td></tr></table>');
	document.write('</div>');
}
create();
function getAbsolutePos(e){
	var l=e.offsetLeft;
	var t=e.offsetTop;
	while(e=e.offsetParent){
		l+=e.offsetLeft;
		t+=e.offsetTop;
	}
	var pos=new Object();
	pos.x=l;
	pos.y=t;
	return pos;
}
function getWindowSize(){
	var _13=0,_14=0;
	if(typeof (window.innerWidth)=="number"){
		_13=window.innerWidth;
		_14=window.innerHeight;
	}else{
		if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){
			_13=document.documentElement.clientWidth;
			_14=document.documentElement.clientHeight;
		}else{
			if(document.body&&(document.body.clientWidth||document.body.clientHeight)){
				_13=document.body.clientWidth;
				_14=document.body.clientHeight;
			}
		}
	}
	var _15=new Object();
	_15.width=_13;
	_15.height=_14;
	return _15;
}
function getScrollXY(){
	var _16=0,_17=0;
	if(typeof (window.pageYOffset)=="number"){
		_17=window.pageYOffset;
		_16=window.pageXOffset;
	}else{
		if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){
			_17=document.body.scrollTop;
			_16=document.body.scrollLeft;
		}else{
			if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){
				_17=document.documentElement.scrollTop;
				_16=document.documentElement.scrollLeft;
			}
		}
	}
	var _18=new Object();
	_18.x=_16;
	_18.y=_17;
	return _18;
}
function addEvent(elm,_1a,fn,_1c){
	if(elm.addEventListener){
		elm.addEventListener(_1a,fn,_1c);
		return true;
	}else{
		if(elm.attachEvent){
			var r=elm.attachEvent("on"+_1a,fn);
			return r;
		}else{
			elm["on"+_1a]=fn;
		}
	}
}
function changeImageToNormalState(_1e){
	var img=document.getElementById("detailedSummaryImage"+_1e);
	/*if(typeof changeimg == "undefined") changeimg = "http://www.chengcai.net/huodong/200707dm/images/renmin-phone2.gif";
	img.src = changeimg;*/
	//closeBubble('onmouseout');
}
function changeImageToClickState(_20){
}
function changeImageToHoverState(_21){
	var img=document.getElementById("detailedSummaryImage"+_21);
	/*if(typeof changeimg == "undefined") changeimg = "http://www.chengcai.net/huodong/200707dm/images/renmin-phone2.gif";
	img.src = changeimg;*/
}
var popTimer;
var gotoTitleTimer;
var canCloseTimer;
var canClose=false;
var inBoxFlag=false;
var detailedSummaryHidden=true;
var lastDocId;
var sumPoped=false;
function clearPopsTimer(_23,_24){
	changeImageToNormalState(_23);
	if(_24=="1"){
		clearTimeout(popTimer);
	}

}
function timeOutShowDetailedSummary(_25,_29,_2a,mid,title,url,shortad,ppcnumber,changepic){
	if(typeof changepic == "undefined"){
		changeImageToHoverState(_25);
	}else{
		changeImageToHoverState(_25,changepic);
	}
	if(_2a=="1"){
		popTimer=setTimeout("_showDetailedSummary('"+_25+"','"+mid+"','"+title+"','"+url+"','"+shortad+"','"+ppcnumber+"')",_29);
	}
}
function hideDetailedSummary(){
	if(!canClose){
		return;
	}
	clearTimeout(gotoTitleTimer);
	//alert("a")
	var box=document.getElementById("detailedSummaryBox");
	box.style.display="none";
	var _2c=document.getElementById("detailedSummaryBG");
	_2c.style.display="none";
	//var _2d=document.getElementById("detailedSummaryContent");
	//if(_2d.scrollTop){
	//_2d.scrollTop=0;
	//}
	detailedSummaryHidden=true;
	sumPoped=false;
	//resetInex();
}
function showDetailedSummary(_2e,_2f,_30,_31,_32){
	changeImageToClickState(_2e);
	if(_32=="0"){
		_showDetailedSummary(_2e,_2f,_30,_31);
	}
}
downpng=new Image();
downpng.src=chengcai_url+"/htm/images/ppcbj3.gif";
uppng=new Image();
uppng.src=chengcai_url+"/htm/images/ppcbj4.gif";
var cache=new Object();
var currentHitPos=0;
function _showDetailedSummary(_33,mid,title,url,shortad,ppcnumber){
	var phonenumber = ppcnumber.substr(0,3)+"-"+ppcnumber.substr(3,3)+"-"+ppcnumber.substr(6,4)
	var disnumber = ppcnumber.substr(10,6);
	sumPoped=true;
	clearTimeout(gotoTitleTimer);
	var _37=document.getElementById("detailedSummary"+_33);
	var pos=getAbsolutePos(_37);
	var box=document.getElementById("detailedSummaryBox");
	var _3c=document.getElementById("detailedSummaryBG");
	var _3d=getWindowSize();
	var _3e=getScrollXY();
	box.style.left=(pos.x+20)+"px";
	//var _3f=document.getElementById("popupSummaryURL");
	var _40=document.getElementById("detailedSummaryContent");
	var _41=document.getElementById("popInnerBox");
	var _42=navigator.appVersion.split("MSIE");

	var _43=parseFloat(_42[1]);
	if(pos.y-_3e.y<300){
		if(pos.x-_3e.x<500)
		{
			box.className="popdown";
			box.style.top=pos.y+"px";
			_41.style.margin="18px 0 0 15px";/*down层里面文字的位置*/
			if(_43&&_43<7){
				_3c.style.background="0 none no-repeat";
				_3c.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=scale,src='"+chengcai_url+"/htm/images/ppcbj3.gif')";
			}else{
				_3c.style.background="0 url('"+chengcai_url+"/htm/images/ppcbj3.gif') no-repeat";
			}

		}
		else
		{
			box.className="popdown";
			box.style.top=pos.y+"px";
			box.style.left=(pos.x-400)+"px"
			_41.style.margin="18px 0 0 15px";/*down层里面文字的位置*/
			if(_43&&_43<7){
				_3c.style.background="0 none no-repeat";
				_3c.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=scale,src='"+chengcai_url+"/htm/images/ppcbj2.gif')";
			}else{
				_3c.style.background="0 url('"+chengcai_url+"/htm/images/ppcbj2.gif') no-repeat";
			}
		}
	}else{
		if(pos.x-_3e.x<400)
		{
			box.className="popup";
			box.style.top=(pos.y-80)+"px";
			_41.style.margin="12px 0 0 15px";/*up层里面文字的位置*/
			if(_43&&_43<7){
				_3c.style.background="0 none no-repeat";
				_3c.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=scale,src='"+chengcai_url+"/htm/images/ppcbj4.gif')";
			}else{
				_3c.style.background="0 url('"+chengcai_url+"/htm/images/ppcbj4.gif') no-repeat";
			}
		}
		else
		{
			box.className="popup";
			box.style.top=(pos.y-80)+"px";
			box.style.left=(pos.x-400)+"px"
			_41.style.margin="12px 0 0 15px";/*up层里面文字的位置*/
			if(_43&&_43<7){
				_3c.style.background="0 none no-repeat";
				_3c.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=scale,src='"+chengcai_url+"/htm/images/ppcbj.gif')";
			}else{
				_3c.style.background="0 url('"+chengcai_url+"/htm/images/ppcbj.gif') no-repeat";
			}

		}
	}
	_3c.style.top=box.style.top;
	_3c.style.left=box.style.left;
	currentHitPos=_33;

	canClose=false;
	clearTimeout(canCloseTimer);
	canCloseTimer=setTimeout("allowClose()",200);
	if(detailedSummaryHidden){
		_3c.style.display="block";
		box.style.display="block";
	}
	detailedSummaryHidden=false;
	ppcnumber = parseInt(ppcnumber);
//		alert(ppcnumber);
	_40.innerHTML = '<div id="youcall" style="color:#000000"><table width="100%" height="91" border="0" cellpadding="0" cellspacing="0"><form name="ppcformf" method="post" action="http://market.chengcai.net/htm/dialback.php?type=layer" target="ppciframe"><tr><td valign="middle"><span style="color: #000000">现在输入您的电话号码，即可立即接到学校打给您的免费服务咨询电话</span></td><td width="14" align="right" valign="middle"><img src="http://ccapi.chengcai.net/market/images/close.gif" alt="关闭" name="Image2" width="14" height="14" border="0" id="Image2" onClick="javascript:hideDetailedSummary();" /></td></tr><tr><td colspan="2" align="center" valign="top"><input name="gqhf" id="gqhf" style="width:30px;" type="text" value="区号" size="4" maxlength="4" onClick="clearValue(this)" onKeyUp="value=value.replace(/[^\\d]/g,\'\')" onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\\d]/g,\'\'))" />－<input name="gthf" id="gthf" type="text" value="手机/固话或小灵通" size="10" maxlength="11" onClick="clearValue(this)" onKeyUp="value=value.replace(/[^\\d]/g,\'\')" onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\\d]/g,\'\'))" title="手机/固话或小灵通" /><span style="color: #000000">验证码：</span><input name="ycodef" type="text" id="ycodef" style="width:34px" size="4" maxlength="4"  /><img name="safepic" id="safepic" src="http://market.chengcai.net/seccode.php" border="0" onClick="changePic()" style="cursor:pointer" align="absmiddle" > <img src="http://ccapi.chengcai.net/market/images/gif-0167.gif" width="65" height="18" onClick="checkTel();"  style="cursor:pointer"><input name="ppc_numberf" type="hidden" id="ppc_numberf" value="'+ppcnumber+'"></td></tr><tr><td height="15" colspan="2"></td></tr></form></table></div><div id="callyou" style="display:none"><ul><li>您的通话请求已经发出，您的电话铃声即将响起，准备接听吧！ </li><li><a href="javascript:void(0);" onMouseDown="javascript:hideDetailedSummary();"><img src="images/close.gif" alt="关闭" name="Image2" width="14" height="14" border="0" id="Image2" /></a></li></ul><ul><li><a href="#"><img src="http://ccapi.chengcai.net/market/images/fh.gif" width="123" height="20" border="0" /></a>&nbsp;</li><li><a href="#"><img src="http://ccapi.chengcai.net/market/images/wjt.gif" width="123" height="20" border="0"></a></li></ul><ul><li></li></ul></div>';
}
function allowClose(){
	canClose=true;
}
function closeBubble(event) {
	if(inBoxFlag===false){
		hideDetailedSummary();
	}
}
function checkTel()
{
	var gqh = $("gqhf").value;
	var gth = $("gthf").value;
	var ppcnumber = $("ppc_numberf").value;
	var ycode = $("ycodef").value;
	if(gqh=='' || gqh=='区号' || gqh == '您的区号'){
		var x =  /^13[\d]{9}|15[\d]{9}|013[\d]{9}|015[\d]{9}|18[\d]{9}|018[\d]{9}$/;
		if (x.test(gth) == false)
		{
			alert("请正确填写手机号码!");
			return false;
		}
		gqh = '';
	} else {
		var x = /^0[1-9]{1}[\d]{1,2}$/;
		if (x.test(gqh) == false)
		{
			alert("请正确填写固话/小灵通电话区号!");
			return false;
		}
		var x = /^[2-8]{1}[\d]{6,7}$/;
		if (x.test(gth) == false)
		{
			alert("请正确填写固话/小灵通电话号码!");
			return false;
		}
		gth = '';
	}
//	createCall(ppcnumber,ycode,gqh,gth)
	//ajaxCall(ppcnumber,ycode,gqh,gth);
//	var url = chengcai_url+'/dialback.php?';
//	var pars = 'type=frame&ppcnumber=' + ppcnumber + '&ycode=' + ycode + '&gqh=' + gqh + '&gth=' + gth;
//	var tUrl = url+pars;
//	var pi = document.getElementById("ppciframef");
//	pi.src = tUrl;
	/*if(typeof layergrade != "undefined" && $("layergrade").value=="layergrade"){
		hidedialog('floatcall');showdialog('getgrade');
	}else{
		document.ppcformf.submit();
	}*/
	if(typeof(document.all.layergrade) == "undefined"){
		document.ppcformf.submit();
	}else{
		hidedialog('floatcall');showdialog('getgrade');
	}
	//document.getElementById("callyou").style.display = "none";
	//document.getElementById("youcall").style.display = "block";
	
}

function changePicfloat(){
	document.images["safepicfloat"].src='http://market.chengcai.net/seccode1.php?t='+(new Date().getTime());
}
function clearValue(obj)
{
	if (obj.value.indexOf('区号') != -1 || obj.value.indexOf('手机/固话或小灵通') != -1){
		obj.value = '';
	}
}
function wBack(){
	parent.$("callyou").style.display="none";
	new Effect.BlindDown(parent.$("youcall"));
	$("ycode").value="";
	$("successcall").style.display="none";
	$("lostcall").style.display="none";
	changePic();
}
function ajaxCall(ppcnumber,ycode,gqh,gth)
{
	var url = chengcai_url+'/dialback.php';
	var pars = 'type=layerajax&ppcnumber=' + ppcnumber + '&ycode=' + ycode + '&gqh=' + gqh + '&gth=' + gth;
	var myAjax = new Ajax.Request(
	url,
	{
		method: 'get', parameters: pars, onComplete: ajaxCallResponse}
		);
}
function ajaxCallResponse(originalRequest)
{
	var backValue = originalRequest.responseText;
	checkBackValue(backValue)
}
function createCall(ppcnumber,ycode,gqh,gth)
{
	var backValue = '';
	var url = chengcai_url+'/dialback.php?';
	var pars = 'type=createlayer&ppcnumber=' + ppcnumber + '&ycode=' + ycode + '&gqh=' + gqh + '&gth=' + gth;
	var tUrl = url+pars;
//	alert(tUrl);
	include_js(tUrl);

}
function checkBackValue(backValue)
{
	if(backValue=='error0'){
		alert('参数错误!');
	} else if(backValue=='error1'){
		alert('请正确填写固话/小灵通电话区号!');
	} else if(backValue=='error2'){
		alert('请正确填写固话/小灵通电话号码!');
	} else if(backValue=='error3'){
		alert('请正确填写手机号码!');
	} else if(backValue=='error4'){
		alert('验证码错误!');
	} else if(backValue=='error5'){
		$("youcall").style.display="none";
		new Effect.BlindDown($("callyou"));
		$("lostcall").style.display="block";
	} else if(backValue=='success1'){
		$("youcall").style.display="none";
		new Effect.BlindDown($("callyou"));
		$("successcall").style.display="block";
	}
}
chengcai_ad_length = 0;
chengcai_ad_rule = 0;
addEvent(document, "click", closeBubble);