/**
 * 显示Popup
 * @param {string} divID
 * @param {string} locationID
 * @param {string} fieldFlag  用于确定输出值赋予哪个对象
 */
function showPopup(divID,fieldFlag)
{
	$("#"+divID).click();
	popupFlag = fieldFlag;
}

//Old Func
function showPopupO(divID,locationID,fieldFlag)
{
	//document.getElementById(divID).style.display = "block";
	$("#"+divID).show();
	//document.getElementById(locationID).style.display = "block";
	$("#"+locationID).show();
	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
 */
function closePopup(divID)
{
	Boxy.get($("#"+divID)).hide();
	//$("#"+divID).hide();
}

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

/**
 * 重置所有城市选择的Checkbox
 * @param {string} elementContainer
 */
function unsetLocationCheckBox(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;
			}
		  }
    } 
}


function confirmLocationSelectionPopup(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":
			valueWrite("HFromCountry",countryLocationID);
			valueWrite("HFromCity",cityID);
			
			valueWrite("locationFrom",countryLocationName + " : " + cityName);
			break;
		case "TO":
			valueWrite("HToCountry",countryLocationID);
			valueWrite("HToCity",cityID);
			
			valueWrite("locationTo",countryLocationName + " : " + cityName);
			break;
		case "SINGLE":
			valueWrite("HSingleCountry",countryLocationID);
			valueWrite("HSingleCity",cityID);
			
			valueWrite("locationSingle",countryLocationName + " : " + cityName);
			break;
	}
	
	closePopup(divID);
}

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


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

/**
 * 转到注册界面
 */
function showSignInPart()
{
	/*
	closePopup('DIVPOPUP','DIVLOGIN');
	showPopup('DIVPOPUP','DIVREGISTER');
	*/
	closePopup("DivRegister");
	showPopup("boxySignIn");
	
}
/**
 * 转到登录界面
 */
function showSinscrirePart()
{
	closePopup("DivLogin");
	showPopup("boxyRegister");
	tboksCaptcha();
	$(".sinscriretips").each(function(){
		$(this).cluetip({
		splitTitle: '|',
		showTitle:false,
		activation:'focus'
	  	});
	});
	/*
	closePopup('DIVPOPUP','DIVREGISTER');
	showPopup('DIVPOPUP','DIVLOGIN');
	*/
}

/**
 * loading popup
 */
function loadingShowPopup()
{
	/*
	$("#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...'
	}); 
}
function loadingClosePopup()
{
	/*
	$("#DIVPROCESSPOPUP").hide();
	$("#LOADINGPOPUP").hide();
	*/
	$.unblockUI();
}

