tboks.webtboks.popup={}; 
/**
 * 显示Popup
 * @param {string} divID
 * @param {string} locationID
 * @param {string} fieldFlag  用于确定输出值赋予哪个对象
 */
tboks.webtboks.popup.showPopup=function(divID,fieldFlag)

{
	$("#"+divID).click();
	popupFlag = fieldFlag;
}

//Old Func
tboks.webtboks.popup.showPopupO=function(divID,locationID,fieldFlag)
{
	//document.getElementById(divID).style.display = "block";
	$("#"+divID).show();
	//document.getElementById(locationID).style.display = "block";
	$("#"+locationID).show();
	tboks.webtboks.popup.unsetLocationCheckBox('cityheckbox2countryTD');
	
	popupFlag = fieldFlag;
	
	//妈的，做修饰
	var isIE6 = $.browser.msie && (parseInt($.browser.version) == 6);
	switch(locationID)
	{
		case "LocationSelectionOne":
		/*
		if(!isIE6){
			checkAndDoSimSelect("locationCountrySelectDiv");
			checkAndDoSimSelect("cityTableToCountry621");//法国
		}
		*/
	}
	if(isIE6){
		$("#DomainSelectDiv").hide();
		$("#CategorySelectDiv").hide();
	}
}

/**
 * 关闭Popup
 * @param {string} divID
 * @param {string} locationID
 */
tboks.webtboks.popup.closePopup=function(divID)
{
	Boxy.get($("#"+divID)).hide();
	//$("#"+divID).hide();
}

//Old Func
tboks.webtboks.popup.closePopupO=function(divID,locationID)
{
	//document.getElementById(divID).style.display = "none";
	$("#"+divID).hide();
	//document.getElementById(locationID).style.display = "none";
	$("#"+locationID).hide();
	tboks.webtboks.popup.unsetLocationCheckBox('cityheckbox2countryTD');
	var isIE6 = $.browser.msie && (parseInt($.browser.version) == 6);
	if(isIE6){
		$("#DomainSelectDiv").show();
		$("#CategorySelectDiv").show();
	}
}

/**
 * 重置所有城市选择的Checkbox
 * @param {string} elementContainer
 */
tboks.webtboks.popup.unsetLocationCheckBox=function(elementContainer)
{
	var   chk= $("."+elementContainer);
	
	for(var i = 0; i < chk.length; i++)  
    {  
          for(var j = 0; j < chk[i].childNodes.length; j++)
		  {
		  	if (chk[i].childNodes[j].nodeType == 1) {
				chk[i].childNodes[j].checked = false;
			}
		  }
    } 
}


tboks.webtboks.popup.confirmLocationSelectionPopup=function(divID,locationID)
{
	var countryLocationID = $("#locationCountrySelect").attr("value");
	var countryLocationName = $("#locationCountrySelect option:selected").text();
	var cityID = $("#cityTableToCountrySelect"+countryLocationID).attr("value");
	var cityName = $("#cityTableToCountrySelect"+countryLocationID + " option:selected").text();
	if(!(countryLocationID&&cityID))
	{
		jAlert("Veuillez choisir un pays et une ville","Tboks");
		return;
	}
	switch (popupFlag)
	{
		case "FROM":
			tboks.webtboks.popup.valueWrite("HFromCountry",countryLocationID);
			tboks.webtboks.popup.valueWrite("HFromCity",cityID);
			
			tboks.webtboks.popup.valueWrite("locationFrom",countryLocationName + " : " + cityName);
			break;
		case "TO":
			tboks.webtboks.popup.valueWrite("HToCountry",countryLocationID);
			tboks.webtboks.popup.valueWrite("HToCity",cityID);
			
			tboks.webtboks.popup.valueWrite("locationTo",countryLocationName + " : " + cityName);
			break;
		case "SINGLE":
			tboks.webtboks.popup.valueWrite("HSingleCountry",countryLocationID);
			tboks.webtboks.popup.valueWrite("HSingleCity",cityID);
			
			tboks.webtboks.popup.valueWrite("locationSingle",countryLocationName + " : " + cityName);
			break;
	}
	
	tboks.webtboks.popup.closePopup(divID);
}

tboks.webtboks.popup.valueWrite=function(hiddenID,hiddenValue)
{
	document.getElementById(hiddenID).value = hiddenValue;
}


tboks.webtboks.popup.smartPopupClose=function()
{
	var type = $("#HRequestType").attr("value");
	switch (type)
	{
		case "1":
			tboks.webtboks.popup.closePopup('DIVPOPUP','DIVLOGIN');
			break;
		case "11":
			tboks.webtboks.popup.closePopup('DIVPOPUP','DIVLOGIN');
			break;
	}
}

/**
 * 转到注册界面
 */
tboks.webtboks.popup.showSignInPart=function()
{
	/*
	tboks.webtboks.popup.closePopup('DIVPOPUP','DIVLOGIN');
	tboks.webtboks.popup.showPopup('DIVPOPUP','DIVREGISTER');
	*/
	tboks.webtboks.popup.closePopup("DivRegister");
	tboks.webtboks.popup.showPopup("boxySignIn");
	
}


//this function only use for home page to switch the two div
tboks.webtboks.popup.showSignInPart_newpopup=function()
{
	
	$('#DivRegister').hide();
	$('#DivLogin').show();
	$('#msgDiv').height($('#DivLogin').height());
	$('#DIVPOPUP').height($('#DivLogin').height());
	$('#msgDiv').width($('#DivLogin').width());
	$('#DIVPOPUP').width($('#DivLogin').width());
}
/**
 * 转到登录界面
 */
tboks.webtboks.popup.showSinscrirePart=function()
{
	tboks.webtboks.popup.closePopup("DivLogin");
	tboks.webtboks.popup.showPopup("boxyRegister");
	tboks.webtboks.reg_login.tboksCaptcha();
	$(".sinscriretips").each(function(){
		$(this).cluetip({
		splitTitle: '|',
		showTitle:false,
		activation:'focus'
	  	});
	});
	/*
	tboks.webtboks.popup.closePopup('DIVPOPUP','DIVREGISTER');
	tboks.webtboks.popup.showPopup('DIVPOPUP','DIVLOGIN');
	*/
}

//this function only use for home page to switch the two div
tboks.webtboks.popup.showSinscrirePart_newpopup=function()
{
	
	$('#DivLogin').hide();
	$('#DivRegister').show();
	$('#msgDiv').height($('#DivRegister').height());
	$('#DIVPOPUP').height($('#DivRegister').height());
	$('#msgDiv').width($('#DivRegister').width());
	$('#DIVPOPUP').width($('#DivRegister').width());
}



/**
 * 直接打开注册界面
 */
tboks.webtboks.popup.showSinscrirePartDirect=function()
{
	
	tboks.webtboks.popup.showPopup("boxyRegister");
	tboks.webtboks.reg_login.tboksCaptcha();
	
	$(".sinscriretips").each(function(){
		$(this).cluetip({
		splitTitle: '|',
		showTitle:false,
		activation:'focus'
	  	});
	});

}
tboks.webtboks.popup.showSinscrirePartDirect_newpopup=function()
{
	
	tboks.webtboks.popup.showPopup("boxyRegister");
	//tboks.webtboks.reg_login.tboksCaptcha();     //call tbokscaptcha function in popup_webtboks.htm
	
	$(".sinscriretips").each(function(){
		$(this).cluetip({
		splitTitle: '|',
		showTitle:false,
		activation:'focus'
	  	});
	});

} 
/**
 * loading popup
 */
tboks.webtboks.popup.loadingShowPopup=function()
{
	/*
	$("#DIVPROCESSPOPUP").show();
	$("#LOADINGPOPUP").show();
	*/
	$.blockUI({
		css: { 
			border: 'none',
			padding: '15px', 
			backgroundColor: '#000', 
			'-webkit-border-radius': '10px', 
			'-moz-border-radius': '10px', 
			opacity: .5, 
			color: '#fff' 
			},
		message: '<img src="plugins/blockui/images/busy.gif" /> Merci de patienter...'
	}); 
}
tboks.webtboks.popup.loadingClosePopup=function()
{
	/*
	$("#DIVPROCESSPOPUP").hide();
	$("#LOADINGPOPUP").hide();
	*/
	$.unblockUI();
}

