// JavaScript ToolBox - Copyright - Jamespot 17/09/2007
// Enable Simple check for mandotory fields
// Ajax
var ns6=document.getElementById&&!document.all

function expandDiv(idContainer,idContent)
{
	new Effect.Morph(idContainer, {
	  style: 'width:300px;',
	  duration: 0.4,
	  afterFinish: function () {$(idContent).style.display='inline';}
	});
}

function expandDiv_v2(idContainer,idContent)
{
	
	jQuery('#'+idContainer).animate(
			{width:'550px'},
			'fast',
			function(){
				jQuery('#'+idContent).show();
			}
			);
}

function reductorDiv_v2(idContainer,idContent)
{
	jQuery('#'+idContent).hide();
	jQuery('#'+idContainer).animate(
			{width:'60px'},
			'fast'
			);
}

/*function div_inline(id)
{
	$(id).style.display='inline';
}*/

function reductorDiv(idContainer,idContent)
{
	new Effect.Morph(idContainer, {
	  style: 'width:20px;',
	  duration: 0.4,
	  afterFinish: function () {$(idContent).style.display='none';}
	});
}

function see_all_properties(id)
{
	container=getElmt(id);
	var propLink;
	propLink="";
	for (prop in container)
    {
    	propLink=propLink+ prop + " ---------> " + container[prop]+"<br />";
    }
    return propLink;
}

var el_menu = new Array("Home","MySpot","Message","Community","Account");

function getIndex(elmt)
{
	for( var i = 0 ; i < el_menu.length ; i++ )
	{
		if (el_menu[i]==elmt)
			return i
	}
	return 0;
}

function display_submenu(id)
{
	/*prop=see_all_properties("link"+id);
	div_block('modal');
	div=getElmt('modal');
	div.innerHTML=prop;*/
	index_array=getIndex(id);
	div=getElmt("sub"+id);
	left=0;
	for ( var i = 0 ; i < index_array ; i++ )
	{
		div2=getElmt(el_menu[i]);
		left=left+5+div2.offsetWidth;
	}
	left=left+270+20;
	div.style.position="absolute";
	div.style.top="75px";
	div.style.left=left+"px";
	link=getElmt("link"+id);
	link.className="activate";
	div_block("sub"+id);
}

function undisplay_submenu(id)
{
	link=getElmt("link"+id);
	link.className="menu_el";
	div_none("sub"+id);
}


function restrictinput(maxlength,e,placeholder)
{
	if (window.event&&event.srcElement.value.length>=maxlength)
		return false
	else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength)
	{
		var pressedkey=/[a-zA-Z0-9\.\,\/]/ 
		if (pressedkey.test(String.fromCharCode(e.which)))
		e.stopPropagation()
	}
}

function countlimit(maxlength,e,placeholder)
{
	var theform=eval(placeholder)
	var lengthleft=maxlength-theform.value.length
	var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
	if (window.event||e.target&&e.target==eval(placeholder))
	{
		if (lengthleft<0)
			theform.value=theform.value.substring(0,maxlength)
		placeholderobj.innerHTML=lengthleft
	}
}

function displaylimit(thename, theid, thelimit)
{
	var theform=theid!=""? document.getElementById(theid) : thename
	var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> chars maximum.'
	if (document.all||ns6)
		document.write(limit_text)
	if (document.all)
	{
		eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
		eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
	}
	else if (ns6){
		document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
		document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
	}
}

function ajax_modal(fx,id,w,h,m,x,y,p)
{
  var p = (p == null) ? "global" : p;
  setModal(w,h,x,y);
  new Ajax.Updater(
      'modal',
      'inc/ajax.i.php',
      {
        method: 'post',
        parameters: {
        			  page: p,
                      fonction: fx,
                      idFather:id,  
                      width: w,
                      height: h,
                      modifiers: m,
                      x: x,
                      y: y
                    }
      }
  );
}

function setModal(w,h,x,y)
{
	div_block('modal');
	div=getElmt('modal');
	if (w!=0 || w!="")
		div.style.width=w+"px";
	if (h!=0 || h!="")
		div.style.height=h+"px";
	if (x!=0 || x!="")
	{
  		div.style.left=x+"px";
  	}
  	if (y!=0 || y!="")
  	{
  		div.style.top=y+"px";
  	}
}

function ajax_modal_jquery(fx,id,w,h,m,x,y,p)
{
  var p = (p == null) ? "mkt" : p;
  setModalJquery(w,h,x,y);
  jQuery('#modal').load(urlbase+'inc/ajax.i.php',
    { page: p,
      fonction: fx,
      idFather:id,  
      width: w,
      height: h,
      modifiers: m,
      x: x,
      y: y},
    function (responseText, textStatus, XMLHttpRequest) {
      if (textStatus == 'success') {
        closeOperationInProgressExt();
        div_block('modal');
      } else {
        closeOperationInProgress();
      }
    }
  );
}

function setModalJquery(w,h,x,y)
{
	screenSize = seeOperationInProgress();
	divforsize = getElmt('unactivate_action');
	div = getElmt('modal');
  // size width
	if (w != "") div.style.width = w+"px";
  // size height
	if (h != "") div.style.height = h+"px";
	// position left
		if (x != "") {
	  div.style.left = x+"px";
	} else {
  	posLeft = ((screenSize["W"]-w)/2);
 	  div.style.left = posLeft.toFixed(0)+"px";
  }
	// position top
	if (y != "") {
	  div.style.top = y+"px";
	} else {
    posTop = ((screenSize["H"]-h)/2);
    div.style.top = posTop.toFixed(0)+"px";
  }
}

function closeOperationInProgress()
{
	div_none('unactivate_action');
	closeOperationInProgressExt();
}

function closeOperationInProgressExt()
{
	div_none('operation_in_progress');
	div=getElmt('operation_in_progress');
	div.style.backgroundColor="transparent";
	div.innerHTML='';
}

/*
** Leo S
**
** useful functions get on : http://javascript.internet.com/forms/regexp-validation.html
*/
// returns true if the string is empty
function isEmpty(str){
  return (str == null) || (str.length == 0);
}
// returns true if the string is a valid email
function isEmail(str){
  if(isEmpty(str)) return false;
  var re = new RegExp('^[^\\s()<>@,;:\\/]+@[\\w\\.-]+\\.+[a-z]{2,}$', 'i');
  return re.test(str) ;

}
// returns true if the string is a valid pseudo else error sentence
function isValidPseudo(str){
  if(isEmpty(str)) return 'Le Pseudo ne peut pas être vide.';
  var reg = /[^a-zA-Z0-9\-\_\./éèêôàâçù]/g
  var wrong = str.match(reg);
  if (wrong != null) {
    if (wrong == " ")
      wrong = '" "';
    return 'Les caractères suivant ne sont pas autorisés: '+wrong;
  }
  return true;
}
// returns true if the string is a valid password else error sentence
function isValidPassword(str){
  if(isEmpty(str)) return 'Le Password ne peut pas être vide.';
  var reg = /[éèêôàâçù\*\\/]/
  var wrong = reg.test(str);
  if (wrong == true)
    return 'Les caractères suivant ne sont pas autorisés: é,è,ê,ô,à,â,ç,ù,*,/,\\';
  return true;
}
// returns true if the string only contains characters A-Z or a-z
function isAlpha(str){
  var re = /[^a-zA-Z]/g
  if (re.test(str)) return false;
  return true;
}
// returns true if the string only contains characters 0-9
function isNumeric(str){
  var re = /[\D]/g
  if (re.test(str)) return false;
  return true;
}
// returns true if the string only contains characters A-Z, a-z or 0-9
function isAlphaNumeric(str){
  var re = /[^a-zA-Z0-9]/g
  if (re.test(str)) return false;
  return true;
}
// returns true if the string's length equals "len"
function isLength(str, len){
  return str.length == len;
}
// returns true if the string's length is between "min" and "max"
function isLengthBetween(str, min, max){
  return (str.length >= min)&&(str.length <= max);
}
// returns true if the string is a US phone number formatted as...
// (000)000-0000, (000) 000-0000, 000-000-0000, 000.000.0000, 000 000 0000, 0000000000
function isPhoneNumber(str){
  var re = /^\(?[2-9]\d{2}[\)\.-]?\s?\d{3}[\s\.-]?\d{4}$/
  return re.test(str);
}
// returns true if the string is a valid date formatted as...
// mm dd yyyy, mm/dd/yyyy, mm.dd.yyyy, mm-dd-yyyy
function isDate(str){
  var re = /^(\d{1,2})[\s\.\/-](\d{1,2})[\s\.\/-](\d{4})$/
  if (!re.test(str)) return false;
  var result = str.match(re);
  var m = parseInt(result[1]);
  var d = parseInt(result[2]);
  var y = parseInt(result[3]);
  if(m < 1 || m > 12 || y < 1900 || y > 2100) return false;
  if(m == 2){
          var days = ((y % 4) == 0) ? 29 : 28;
  }else if(m == 4 || m == 6 || m == 9 || m == 11){
          var days = 30;
  }else{
          var days = 31;
  }
  return (d >= 1 && d <= days);
}
// returns true if "str1" is the same as the "str2"
function isMatch(str1, str2){
  return str1 == str2;
}
// returns true if the string contains only whitespace
// cannot check a password type input for whitespace
function isWhitespace(str){ // NOT USED IN FORM VALIDATION
  var re = /[\S]/g
  if (re.test(str)) return false;
  return true;
}
// removes any whitespace from the string and returns the result
// the value of "replacement" will be used to replace the whitespace (optional)
function stripWhitespace(str, replacement){// NOT USED IN FORM VALIDATION
  if (replacement == null) replacement = '';
  var result = str;
  var re = /\s/g
  if(str.search(re) != -1){
    result = str.replace(re, replacement);
  }
  return result;
}

function return_error(error) {
  alert(error);
  return false;
}
// verif if form in mkt-user.i.tpl is valid
function verifyForm(formname) {
  if (!isEmail(document[formname]['mail'].value)) {
    return return_error('Email incorrect.');
  }
  if (isEmpty(document[formname]['nom'].value)) {
    return return_error('Le nom ne peut pas être vide.');
  }
  if (isEmpty(document[formname]['prenom'].value)) {
    return return_error('Le prenom ne peut pas être vide.');
  }
  var test_pseudo = isValidPseudo(document[formname]['pseudo'].value);
  if (test_pseudo != true) {
    return return_error('Pseudo incorrect.\n'+test_pseudo);
  }
  var test_password = isValidPassword(document[formname]['pwd'].value);
  if (test_password != true) {
    return return_error('Password incorrect.\n'+test_password);
  }
  return true;
}

function verifyFieldValue(formname, field) {
  if (field == 'Mail'){
    if (!isEmail(document[formname][field].value)) {
      return return_error('Email incorrect.');
    }
  } else if (field == 'Pseudo') {
    var test_pseudo = isValidPseudo(document[formname][field].value);
    if (test_pseudo != true) {
      return return_error('Pseudo incorrect.\n'+test_pseudo);
    }
  } else if (field == 'Pwd') {
    var test_password = isValidPassword(document[formname][field].value);
    if (test_password != true) {
      return return_error('Password incorrect.\n'+test_password);
    }
  }
  return true;
}

function delete_image(type,id)
{
  new Ajax.Updater(
      'current_image',
      'inc/ajax.i.php',
      {
        method: 'post',
        parameters: {
                      fonction: 'delete-image',
                      page: 'spot',
                      type: type,
                      id: id  
                    }
      }
  );
  div_none('current_image');
}

function ajax_change_photo(idSpot,new_img)
{
  div_none('changeLS');
  new Ajax.Updater(
      'logo_spot_editable',
      'inc/ajax.i.php',
      {
        method: 'post',
        parameters: {
                      fonction: 'change-spot-photo', 
                      page: 'spot', 
                      IdSpot: idSpot,
                      new_img: new_img 
                    }
      }
  );
}

function MakeFormPermission (div,nickname,iduser,level,idSpot,levelViewer)
{
  div_block(div);
  new Ajax.Updater(
      div,
      'inc/ajax.i.php',
      {
        method: 'post',
        parameters: {
                      fonction: 'form-change-permission', 
                      page: 'spot', 
                      IdSpot: idSpot,
                      IdUser: iduser,
                      level: level,
                      levelViewer: levelViewer,
                      nickname: nickname
                    }
      }
  );
}

function ChangePermissions (new_Perm,IdUser,IdSpot)
{
  div_none('form_permissions');
  div="levelName_"+IdUser;
  new Ajax.Updater(
      div,
      'inc/ajax.i.php',
      {
        method: 'post',
        parameters: {
                      fonction: 'change-permission', 
                      page: 'spot', 
                      IdSpot: IdSpot,
                      IdUser: IdUser,
                      newPerm: new_Perm
                    }
      }
  );
}

//////////////
function MakeFormRole (div,nickname,iduser,level,idSpot)
{
  div_block(div);
  new Ajax.Updater(
      div,
      'inc/ajax.i.php',
      {
        method: 'post',
        parameters: {
                      fonction: 'form-change-role', 
                      page: 'spot', 
                      IdSpot: idSpot,
                      IdUser: iduser,
                      level: level,
                      nickname: nickname
                    }
      }
  );
}

function ChangeRole (new_Perm,IdUser,IdSpot)
{
  div_none('form_change_role');
  div="levelName_"+IdUser;
  new Ajax.Updater(
      div,
      'inc/ajax.i.php',
      {
        method: 'post',
        parameters: {
                      fonction: 'change-role', 
                      page: 'spot', 
                      IdSpot: IdSpot,
                      IdUser: IdUser,
                      newPerm: new_Perm
                    }
      }
  );
}
//////////////

function view_more_lastest(iddiv,updatediv,typestory,index)
{
  new Ajax.Updater(
      updatediv,
      'inc/ajax.i.php',
      {
        method: 'post',
        parameters: {
                      fonction: 'view-more-lastest-news', 
                      page: 'search', 
                      TypeStory: typestory,
                      Index: index
                    }
      }
  );

}

function get_mouse(evt)
{
	if(!evt) evt = window.event;
	var de = document.documentElement;
    var b = document.body;
    if (de)
    {
		x = evt.clientX+ de.scrollLeft;
		y = evt.clientY+ de.scrollTop;
	}
	else if (b)
	{
		x = evt.clientX+ b.scrollLeft;
		y = evt.clientY+ b.scrollTop;
	}
}

function copyHeightDiv(idReferer,idTarget, idSubtarget, modifier)
{
	div_r=getElmt(idReferer);
	div_t=getElmt(idTarget);
	div_t.style.height=div_r.offsetHeight+"px";
	if (idSubtarget!="")
	{
		div_st=getElmt(idSubtarget);
		subHeight=div_r.offsetHeight-modifier;
		div_st.style.height=subHeight+"px";
	}
}

function div_position(idDiv,width)
{
	div_block(idDiv);
	hint_div=getElmt(idDiv);
	hint_div.style.top=y+"px";	
  left=x-width;
  hint_div.style.left=left+"px";
}

function GetRadioValue(radioGroupName)
{
	var group = document.getElementsByName(radioGroupName);
	
	for( var i = 0 ; i < group.length ; i++ )
	{
		if( group[i].checked ) return group[i].value;
	}
}

function unCheckAll(group)
{
  if (group=='contact')
    nb=document.getElementById('NbContacts').value;
  else
    nb=document.getElementById('NbUmails').value;
	for( var i = 0 ; i < nb ; i++ )
	{
	 document.getElementById(group+"_"+i).checked=false;
	}
}

function CheckAll(group)
{
  	nb=document.getElementById('nbInvitation').value;
	for( var i = 0 ; i < nb ; i++ )
	{
	 document.getElementById(group+"_"+i).checked=true;
	}
}


function view_createspot(value)
{
  if (value==-1)
  {
    div_block("create_spot_it");
  }
  else
  {
    div_none("create_spot_it");
  }
}

function play_video()
{
  div=getElmt('video1');
  div.innerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="290" height="218"><param name="movie" value="flash/jamespot_video_1.swf"><param name="quality" value="high"><embed src="flash/jamespot_video_1.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="290" height="218"></embed></object>';
}

function makeFormEditMail(idSpot,NameSpot)
{
  jQuery('#edit_mail_spot .title_center').text(NameSpot);
  content='content_edit_mail';
  div_block('edit_mail_spot');
  div_block('background_modal');
  new Ajax.Updater(
      content,
      'inc/ajax.i.php',
      {
        method: 'post',
        parameters: {
                      fonction: 'edit-mail', 
                      page: 'spot', 
                      IdSpot: idSpot 
                    }
      }
  );
}

function changeInput(blank_div,div)
{
  div_none(blank_div);
  input=getElmt(div);
  input.style.display="block";
  setTimeout('input.focus();', 10);
}

function onFocusElement(idElement)
{
   input=getElmt(idElement);
   setTimeout('input.focus();', 10);
}

function getElmt(id)
{
  var div
	if (document.layers)
	{
		div= document.layers[id];
	}
	else if (document.all)
	{
		div= document.all[id];
	}
	else if (document.getElementById)
	{
		div= document.getElementById(id);
	}
  return div;
}

function div_none(id)
{
	var div
	if (document.layers)
	{
		div= document.layers[id];
	}
	else if (document.all)
	{
		div= document.all[id];
	}
	else if (document.getElementById)
	{
		div= document.getElementById(id);
	}
		div.style.display="none";
}

function div_block(id)
{
	var div
	if (document.layers)
	{
		div= document.layers[id];
	}
	else if (document.all)
	{
		div= document.all[id];
	}
	else if (document.getElementById)
	{
		div= document.getElementById(id);
	}
		div.style.display="block";
}

function fieldVerification(field)
{
	if (field == "")
	{ 
		alert("Mail Field is not filled");
		return false;
	}
	return true;
}

function erreur(ErreurImage, size)
{
	if (size == '64' || size == '128')
	  ErreurImage.src="img/default_" + size + ".jpg";
	else
	   ErreurImage.src="img/default.jpg";
}

last_video_see="";
function SetMainVideo (div,feedTitle,MajDate,html,title,description)
{
  if (last_video_see!="")
  {
    last_video=getElmt(last_video_see);
    last_video.style.background="#FFFFFF";
  }
  div_list=getElmt(div);
  last_video_see=div;
  div_player=getElmt('main_video');
  feedTitle=Url.decode(feedTitle);
  MajDate=Url.decode(MajDate);
  html=Url.decode(html);
  title=Url.decode(title);
  description=Url.decode(description);
  ret='<div id="header_main_video">'+feedTitle+'&nbsp;-&nbsp;'+MajDate+'<br /><h4><a href="#" class="medium_title_story">'+title+'</a></h4></div>';
  ret=ret+'<div id="player_video">'+html+'</div>';
  ret=ret+'<div id="content_player_video">'+description;
  ret=ret+'</div>';
  div_list.style.background="#d2b2eb";
  div_player.innerHTML=ret;
}

function playthisvideo(index,title,url,width,height)
{
	last_div=getElmt("video_div_"+activeVid);
	new_div=getElmt("video_div_"+index);
	title_div=getElmt("header_video_player");
	flash_div=getElmt("content_video_player");
	last_div.className="inactive_video";
	new_div.className="active_video";
	title_div.innerHTML=title;
	content='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">';
	content=content+'<param name="movie" value="'+url+'">';
	content=content+'<param name="quality" value="high">';
	content=content+'<embed src="'+url+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed></object>';
	flash_div.innerHTML=content;
	activeVid=index;
}

/* LS : Spot edit confirm update before show the spot */
function confirm_view(str, idSpot)
{
  if (confirm(str)) {
    document.form_all.submit();
  } else {
    window.location.href='?action=spot&IdSpot='+idSpot;
  }
}
function seeOperationInProgress()
{
	div_block('unactivate_action');
	div_block('operation_in_progress');
	divforsize=getElmt('unactivate_action');
	if (window.innerWidth)
    {
      var screenW=window.innerWidth;
      var screenH=window.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) 
    { 
		var screenW = document.documentElement.clientWidth;
		var screenH = document.documentElement.clientHeight;
		divforsize.style.width=screenW;
		divforsize.style.height=screenH;
	}
    else
    {
    	var screenW=divforsize.offsetWidth;
    	var screenH=divforsize.offsetHeight;
    }
    div=getElmt('operation_in_progress');
    w=260;
    h=50;
	div.style.width=w+"px";
	div.style.height=h+"px";
	posLeft=((screenW-w)/2);
	div.style.left=posLeft.toFixed(0)+"px";
  	posTop=((screenH-h)/2);
  	div.style.top=posTop.toFixed(0)+"px";
  	div.innerHTML='<img src="img/ajax-loader.gif" style="display:block;margin:auto;margin-top:10px;" />';
  	var ret=new Array();
  	ret["W"]=screenW;
  	ret["H"]=screenH;
  	return ret;
  }

currentCategory = '';
function showCategory(idCategory)
{
	if(currentCategory == idCategory)
	{
		jQuery('#spots_category_'+currentCategory).hide();
		currentCategory = ''
	}else{
		if(currentCategory != '')
		{
			jQuery('#spots_category_'+currentCategory).hide();
		}
		jQuery('#spots_category_'+idCategory).show();
		currentCategory = idCategory;
	}
}

function close_alert(id)
{
	jQuery.ajax({
		   type: "POST",
		   url: "inc/ajax.i.php",
		   data: "page=global&fonction=close-alert&id="+id
	});
	jQuery('#alert-'+id).hide();
}

function userSpot(idUser)
{
	jQuery('#modify_user_spot_'+idUser).load(
		urlbase+'inc/ajax.i.php',
		{ 
			page: 'mkt',
			fonction: 'user-spot',
			idUser:idUser
		},
		function (responseText, textStatus, XMLHttpRequest) {
			if (textStatus == 'success') 
			{
				div_none('modify_user_info_'+idUser);
				div_none('modify_user_pwd_'+idUser);
				div_none('manage_user_contact_'+idUser);
				div_block('manage_user_spot_'+idUser);
			} else {
				alert('Please refresh the current page.')
			}
		}
	);		
}

function userContact(idUser)
{
	jQuery('#modify_user_contact_'+idUser).load(
		urlbase+'inc/ajax.i.php',
		{ 
			page: 'mkt',
			fonction: 'user-contact',
			idUser:idUser
		},
		function (responseText, textStatus, XMLHttpRequest) {
			if (textStatus == 'success') 
			{
				div_none('modify_user_info_'+idUser);
				div_none('modify_user_pwd_'+idUser);
				div_none('manage_user_spot_'+idUser);
				div_block('manage_user_contact_'+idUser);
			} else {
				alert('Please refresh the current page.')
			}
		}
	);		
}

function selectSpot(id)
{
	if(jQuery('#user_spot_'+id).attr('checked'))
	{
		jQuery('#spot_user_level_'+id).show();
	}else{
		jQuery('#spot_user_level_'+id).hide();
	}
}

function selectUser(id)
{
	if(jQuery('#spot_user_'+id).attr('checked'))
	{
		jQuery('#spot_user_level_'+id).show();
	}else{
		jQuery('#spot_user_level_'+id).hide();
	}
}

function spotUser(idSpot)
{
	jQuery('#modify_user_spot_'+idSpot).load(
		urlbase+'inc/ajax.i.php',
		{ 
			page: 'mkt',
			fonction: 'spot-user',
			idSpot:idSpot
		},
		function (responseText, textStatus, XMLHttpRequest) {
			if (textStatus == 'success') 
			{
				div_none('modify_spot_info_'+idSpot);
				div_block('manage_spot_user_'+idSpot);
			} else {
				alert('Please refresh the current page.')
			}
		}
	);	
}

function allCheckbox(id, c)
{
	var val = jQuery("#"+id).attr("checked");
	jQuery("."+c).attr("checked", val);	
}

function allLevel(val, c)
{
	if(val != -1)
	{
		jQuery("."+c).val(val);
	}	
}

function selectLevel(c, id)
{
	var val = jQuery("#"+id).attr("checked");
	if(val)
	{
		jQuery("."+c).show();
	}else{
		jQuery("."+c).hide();
	}
	
}