/*
 *
 * Version       : WeekPix 1.0 (PHP5/MySQL5)
 * Author        : Stucki Gael
 * Last Modified : 14.09.2006 
 *
 *
*/


/*
 *
 * Function   : mouseMO
 * Return     : /
 *
*/

	function mouseMO(imgID, imgSRC){
	
		var img = document.getElementById(imgID);
		img.src = imgSRC;
	
	}


/*
 *
 * Function   : isEmpty
 * Return     : /
 *
*/
	function isEmpty(str){ 
		strRE = new RegExp( ); 
	  strRE.compile( '^[s ]*$', 'gi' ); 
	  return strRE.test(str); 
	} 


/*
 *
 * Function   : notValidEmail
 * Return     : /
 *
*/
	function notValidEmail( str ){ 
		mailRE = new RegExp( ); 
    mailRE.compile( '^[._a-z0-9-]+@[.a-z0-9-]+[.]{1}[a-z]{2,4}$', 'gi' ); 
    return !(mailRE.test(str)); 
	}
	


/*
 *
 * Function   : isValidRegularExpression
 * Return     : /
 *
*/
	function isValidRegularExpression( str, regularExpression ){ 
		
		spcRE = new RegExp( ); 
    spcRE.compile(regularExpression, 'gi' ); 
    return spcRE.test(str);
    
	}
	
	
/*
 *
 * Function   : isNotValidRegularExpression
 * Return     : /
 *
*/
	function isNotValidRegularExpression( str, regularExpression ){ 
			
    return !isValidRegularExpression(str , regularExpression);
    
	}
	
	
/*
 *
 * Function   : goToPage
 * Return     : /
 *
*/
	function goToPage( url ){ 
		
		window.location = url;
		
	}
	
/*
 *
 * Function   : goToPage_Iframe
 * Return     : /
 *
*/
	function goToPage_Iframe( idIframe, urlIframe, paramsIframe){ 
		
		//document.getElementById(idIframe).src = treePhoto_root_linkPath + urlIframe;
		document.getElementById(idIframe).src = urlIframe + paramsIframe;
		
	}
  
 
 
 /*
 *
 * Function   : listRedirectToPage
 * Return     : /
 *
*/
  
  function listRedirectToPage(list){
  
	var cList = document.getElementById(list);
	var cValue = cList.options[cList.selectedIndex].value;
	
  //if (cValue != -1){
	  
	  location.href = cValue;
	  
	//}
	
}
	


/*
 *
 * Function   : checkAll
 * Return     : /
 *
*/
	function checkAll(formName, ctrlName, ctrlsName){ 
		
		with(eval("document."+formName)){
			
			try{
				var ctrl = eval(ctrlName); 
				var ctrls = eval(ctrlsName); 
				
				if (ctrls.length == undefined){
					
					ctrls.checked = ctrl.checked;
					
				}else{
					
					for (var i = 0; i<ctrls.length; i++){
					
						ctrls[i].checked = ctrl.checked;
					
					}	
					
				}
				
			}catch(exc){
				
				// nothing
				
			}
		}
		
	}
	
	
	
	/*
 *
 * Function   : showFreezeWindow
 * Return     : /
 *
*/
	function showFreezeWindow(pWFreeze, toShow){ 
		
		resizeFreezeWindow(pWFreeze);
		var wFreeze = document.getElementById(pWFreeze);
		wFreeze.style.visibility = (toShow) ? "visible" : "hidden";
		
	}
	

/*
 *
 * Function   : resizeFreezeWindow
 * Return     : /
 *
*/
	function resizeFreezeWindow(pWFreeze){ 
		
		var w = (document.body.clientWidth);
		var h = (document.body.clientHeight);
		var wFreeze = document.getElementById(pWFreeze);
		
		wFreeze.style.width = w;
		wFreeze.style.height = h;
		
	}
  
  
  /*
 *
 * Function   : openCloseCatNavigation
 * Return     : /
 *
*/
	function openCloseCatNavigation(idDiv){ 
		
		var divCatNav = document.getElementById(idDiv);
    
    divCatNav.className = (divCatNav.className == "catNavClose") ? "catNavOpen" : "catNavClose";
		
	}
  
  
  
   /*
 *
 * Function   : sendSearch()
 * Return     : /
 *
*/
	function sendSearch(){ 
	
    document.frmHiddenSearch.idfCAT.value = document.frmSearch.cbCategories.value;
    document.frmHiddenSearch.idfCOU.value = document.frmSearch.cbCountries.value;
    document.frmHiddenSearch.idfCNT.value = document.frmSearch.cbCantons.value;
    document.frmHiddenSearch.words.value = document.frmSearch.words.value;
		document.frmHiddenSearch.submit();
		
	}
  
  
/*
 *
 * Function   : resizeFreezeWindow
 * Return     : /
 *
*/
	function doDelete(){ 
		
		if(confirm('Voulez-vous vraiment supprimer la demande de renseignements?')){
		
			document.frmMain.submit();
		
		}

	}
	
/*
 *
 * Function   : resizeFreezeWindow
 * Return     : /
 *
*/
	function doDeletePartner(id){ 
		
		if(confirm('Voulez-vous vraiment supprimer le partenaire?')){
		
			location.href = "listPartners.php?idf="+id;
		
		}

	}
	
	
	/*
 *
 * Function   : resizeFreezeWindow
 * Return     : /
 *
*/
	function doDeleteAnnonceAdmin(id){ 
		
		if(confirm('Voulez-vous vraiment supprimer l\'annonce?')){
		
			location.href = "listANN.php?idf="+id;
		
		}

	}

/*
 * Function   : delete PTL par admin
 * Return     : /
 *
*/
	function doDeletePTLAdmin(id){ 
		
		if(confirm('Voulez-vous vraiment supprimer ce message?')){
		
			location.href = "listFreePTL.php?idd="+id;
		
		}

	}

	
	/*
 *
 * Function   : resizeFreezeWindow
 * Return     : /
 *
*/
	function doDeleteUserAdmin(id){ 
		
		if(confirm('Voulez-vous vraiment supprimer l\'utilisateur?')){
		
			location.href = "listUsers.php?idf="+id;
		
		}

	}
	
/*
 *
 * Function   : previewPhoto
 * Return     : /
 *
*/
	function previewPhoto(srcFile){ 
		
		if (document.getElementById){
			document.getElementById("photo200").src = srcFile;
			//document.getElementById("containerPhoto").height = document.getElementById("photo200").height;
		}else{
			document.all["photo200"].src = srcFile;
		}
		
	}

	
/*
 *
 * Function   : resizeThumbnail
 * Return     : /
 *
*/
	function resizeThumbnail(){ 
		
		document.getElementById("containerPhoto").style.height = document.getElementById("photo200").height;
		
	}
	
/*
 *
 * Function   : resizeThumbnail
 * Return     : /
 *
*/
	function resizeIMG(pIsPublic){
		
		var loadedImg = document.getElementById("photo200");
		var oImg = new Image();
		var maxHeight = 500;
		
		oImg.src = document.getElementById("photo200").src;
		
		if (!pIsPublic){
			maxHeight = 280;
		}
		
		if (oImg.height > maxHeight){
			loadedImg.height = maxHeight;
		}else{
			loadedImg.height = oImg.height;	
		}
		
		if (!pIsPublic){
			loadedImg.style
		}
		
	}
	
	/*
 *
 * Function   : previewPhoto
 * Return     : /
 *
*/
	function getPreviewPhoto(){ 
		
		if (document.getElementById){
			return document.getElementById("photo200").src;
		}else{
			return document.all["photo200"].src;
		}
		
	}
	
/*
 *
 * Function   : PopupWin
 * Return     : /
 *
*/
	
	function popupWin(){
		var a = popupWin.arguments;
		var scrW = window.screen.width;
		var scrH = window.screen.height;
		var leftPos = (scrW-a[2])/2;
		var topPos = 	(scrH-a[3])/2;
		
		if (a[4] != ''){
		
				var settings = a[4]+',width='+a[2]+',height='+a[3]+',left='+leftPos+',top='+topPos+'';
		
		}else{
		
				var settings = 'menubar=no,status=yes,toolbar=no,directories=no,location=no,resizable=yes,scrollbars=yes,width='+a[2]+',height='+a[3]+',left='+leftPos+',top='+topPos+'';
		
		}
		
		var cmt_P;
		
		if ((!cmt_P)|| (cmt_P.closed)){
				
				cmt_P = window.open(a[0],a[1],settings); 
				
		}
		
		
		cmt_P.focus();
		
		return cmt_P;
		
	}
	