function CounrySelectionInit(objList) {
  if (!document.getElementById) return;

	objList = document.getElementById(objList)
  objList.onchange = function(){CountrySelectionOnClick(this.options[this.selectedIndex]);}
  objList.onkeypress = function(){CountrySelectionOnClick(this.options[this.selectedIndex]);}

  for (var i = 0; i < objList.options.length; i++) {
    if (objList.options[i].selected) {
      objList.options[i].parentNode.style.backgroundImage = objList.options[i].style.backgroundImage;
    }
  }
}

function CountrySelectionOnClick(e){
  //e.parentNode.setAttribute('style', e.parentNode.getAttribute('style') + e.getAttribute('style')); fahne wurde beim ersten klick nicht angezeigt. erst beim zweiten
  e.parentNode.setAttribute('style', e.getAttribute('style'));
  e.parentNode.style.backgroundRepeat = 'no-repeat';
  e.parentNode.style.backgroundPosition = '2px 50%';
  e.parentNode.style.padding = '0 0 0 22px';
  //if (e.text == '') e.parentNode.style.backgroundImage = 'none'; ist nicht mehr nötig als das erste oben entfernt wurde
}


function LanguageSelectionInit(objList) {
  if (!document.getElementById) return;

  objList = document.getElementById(objList)
  objList.onchange = function(){LanguageSelectionOnClick(this.options[this.selectedIndex]);}
  objList.onkeypress = function(){LanguageSelectionOnClick(this.options[this.selectedIndex]);}

  for (var i = 0; i < objList.options.length; i++) {
    if (objList.options[i].selected) {
      objList.options[i].parentNode.style.backgroundImage = objList.options[i].style.backgroundImage;
    }
  }
}

function LanguageSelectionOnClick(e){
  e.parentNode.setAttribute('style', e.parentNode.getAttribute('style') + e.getAttribute('style'));
  e.parentNode.style.backgroundRepeat = 'no-repeat';
  e.parentNode.style.backgroundPosition = '4px 60%';
  e.parentNode.style.padding = '0 0 0 20px';
  if (e.text == '') e.parentNode.style.backgroundImage = 'none';
}




function htmlspecialchars(text){
  if(typeof(text)=='undefined'||!text.toString){
    return'';
  }
  if(text===false){
    return'0';
  }else if(text===true){
    return'1';
  }
  return text.toString().replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/'/g,'&#039;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
}

/*erstmal rausgenommen da bei manchen browsern der cursor verschwindet wärend man tippt*/
function TextareaAutoLength(obj) {
  var padding=15;
  var shadow_div_id='shadow_'+obj.id;
  var shadow_div;

  obj.style.overflow = "hidden";

  if(!(shadow_div=document.getElementById(shadow_div_id))){
    shadow_div=document.createElement('div');
    shadow_div.id=shadow_div_id;
    shadow_div.className = "textareautosize";
    shadow_div.style.position="absolute";
    shadow_div.style.left="-10000px";
    shadow_div.style.top="-10000px";
    shadow_div.style.width=parseInt(obj.clientWidth-8)+'px';
    obj.setAttribute('startHeight', obj.clientHeight);
    obj.parentNode.appendChild(shadow_div);
  }

  var clientHeight=obj.clientHeight;
  shadow_div.innerHTML=htmlspecialchars(obj.value).replace(/[\n]/g,'<br />&nbsp;');
  var shadowHeight=shadow_div.clientHeight;
  var to_height;
  var startHeight=obj.getAttribute('startHeight');

  if(shadowHeight<startHeight) {
    to_height=startHeight;
  } else {
    to_height=shadowHeight+padding;
  }

  if(to_height&&to_height!=clientHeight) {
    obj.style.height=to_height+'px';
  }
}

function GetCount(theDate, theCountbox) {
  if (!document.getElementById(theCountbox)) return;
  
	var dateNow = new Date(); //grab current date
	var dateFuture = new Date(theDate); //"Month Day, Year Hour:Minute:Second"
	var amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates
	delete dateNow;

	// time is already past
	if(amount < 0){
		document.getElementById(theCountbox).innerHTML="Finish";
	}
	// date is still good
	else{
		days=0;hours=0;mins=0;secs=0;out="";

		amount = Math.floor(amount/1000); //kill the "milliseconds" so just secs

		days=Math.floor(amount/86400);
		amount=amount%86400;

		hours=Math.floor(amount/3600);
		amount=amount%3600;

		mins=Math.floor(amount/60);
		amount=amount%60;

		secs=Math.floor(amount);

//		if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}
//		if(days != 0 || hours != 0){out += hours +" hour"+((hours!=1)?"s":"")+", ";}
//		if(days != 0 || hours != 0 || mins != 0){out += mins +" minute"+((mins!=1)?"s":"")+", ";}
//		out += secs +" seconds";
    
    days = days.toString();
		if (days.length == 1) days = '0' + days
    
		hours = hours.toString();
		if (hours.length == 1) hours = '0' + hours

		mins = mins.toString();
		if (mins.length == 1) mins = '0' + mins

		secs = secs.toString();
		if (secs.length == 1) secs = '0' + secs

		out = days + ":" + hours + ":" + mins + ":" + secs

		document.getElementById(theCountbox).innerHTML = out;

		setTimeout("GetCount('" + theDate + "', '" + theCountbox + "')", 1000);
	}
}

function ShowSimilarPhotos() {
  var theForm = document.FormSearchByKeywordselection;

  for (i=0,n=theForm.elements.length;i<n;i++) {
    if (theForm.elements[i].name.indexOf('Keyword_') == 0) theForm.elements[i].checked = true;
  }

  theForm.ShowAllSimilar.value = 'True';
  theForm.submit();
}


function randomPassword(length)
{
  chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  pass = "";
  for(x=0;x<length;x++)
  {
    i = Math.floor(Math.random() * 62);
    pass += chars.charAt(i);
  }
  return pass;
}

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
}


function ColorSearch(color) {
  ReplaceInputfieldValue(opener.document.FormSearch.SearchPhotoColor, color);
  opener.document.getElementById('SearchPhotoColorBox').style.backgroundColor = color;
  //if(parseInt(getQueryVariable('submit')) != 0) opener.document.forms['FormSearch'].submit();  
  opener.focus();
  opener.document.FormSearch.SearchPhotoColor.focus();
  opener.document.forms['FormSearch'].submit();
}

function autoCompOff(id) {
    document.getElementById('SearchInput').setAttribute("autocomplete","off");
}


//returns a random 8 digit alphanumeric string
function GetRandomString() {
  var intLength = 8;
  var strCharList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"
  var strRandom = "";


  for (i=1; i<=intLength; i++) {
    strRandom = strRandom + strCharList.substr(Math.round(Math.random() * strCharList.length +1), 1);
  }

  return strRandom;
}


//submit form and disable submit button
function FormSubmit(target) {
  var objButton = document.getElementsByName('Submit');
  objButton.disabled = true;
  return true;
}


function ChatStartTimer() {
  setTimeout("ChatCheckRefresh()",5000)
}

function ChatCheckRefresh() {
  if(document.ChatForm.Message.value == '') {
   document.location.href = document.location.href;
  }
  setTimeout("ChatCheckRefresh()",5000)
}

function KeywordLoadAssignKeywords() {
  parent.opener.document.Form.Keywords.value = document.Form.Keywords.value;
  parent.opener.document.Form.ConceptKeywords.value = document.Form.ConceptKeywords.value;
  parent.opener.document.Form.TechnicalKeywords.value = document.Form.TechnicalKeywords.value;

  parent.opener.focus();
}



function KeywordassistentAddMoreKeywords(strFormAction) {
	document.Form.action = strFormAction;
	document.Form.submit();

	return true;
}

function KeywordassistentPassOverKeywords() {
  objKeywordfield = parent.opener.document.Form.Keywords

  strCurrentKeywords = trim(objKeywordfield.value);
  strNewKeywords = trim(document.Form.Keywords.value);

  if (isEmpty(strCurrentKeywords)) {
  	strCurrentKeywords = strNewKeywords;
  } else {
  	strCurrentKeywords = strCurrentKeywords + ', ' + strNewKeywords;
  }

	objKeywordfield.value = strCurrentKeywords;
	parent.opener.focus();
}

function PassOver(objFormField, strValue, bolSetFocus) {
  objFormField.value = strValue
	if (bolSetFocus) parent.opener.focus();
}



function ShowUploadStatus(intUploadID) {
  window.open('progressbar.asp?ID=' + intUploadID, 'win' + intUploadID, 'width=500,height=140');
  return true;
}

function PreviewImg(el) {
	var filename = el.value;
	var Img = new Image();

	Img.src = filename;
	Img.onload = function() {
	  if(this.width >= this.height) {
  	  this.height *= 164 / this.width;
  	  this.width = 164;
  	}else{
  	  this.width *= 164 / this.height;
  	  this.height = 164;
    }

  	document.PhotoPreview.src = this.src;
  	document.PhotoPreview.height = this.height;
  	document.PhotoPreview.width = this.width;
	}

  Img = null;
}


function myFileUpload(strImagePath) {
	if (!(document.createElement && document.getElementsByTagName)) return;

	//inspired by http://www.quirksmode.org/dom/inputfile.html

	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.className = 'inputFileFake';

	var fakeFileUploadInput = fakeFileUpload.appendChild(document.createElement('input'));
	fakeFileUploadInput.className = 'inputFile';

	var image = document.createElement('img');
	image.src= strImagePath + 'btn_selectphoto.gif';
	fakeFileUpload.appendChild(image);

	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].type != 'file') continue;
		if (x[i].getAttribute('noscript')) continue;
		if (x[i].parentNode.className != 'myFileinput') continue;
		x[i].className = 'inputFileHidden';
		var clone = fakeFileUpload.cloneNode(true);
		x[i].parentNode.appendChild(clone);
		x[i].relatedElement = clone.getElementsByTagName('input')[0];
	}
}


function ShowUploadPreview() {
  var ie = (navigator.userAgent.indexOf('MSIE') > -1) ? 1 : 0;

  if(ie) {
    var myElem = document.getElementById("UploadPreview");
    myElem.style.display = 'block'

    var myElem = document.getElementById("UploadPreviewForm");
    myElem.className = 'boxSubcolumnRight'
  }
}

///* Ajax Thumbnail Update Stuff - BEGIN */
//var bAjaxUpdateImageThumbRunning = false;
//
//function AjaxUpdateImageThumbResponseHandler(transport, strThumbPath, strImageElementID)
//{
//	//	process the response of the ajax call
//	var responseTxt = transport.responseText;
//	if (responseTxt.length > 0)
//	{
//		if (responseTxt == "ok")
//		{
//			//	set the thumbnail
//			var e = document.getElementById(strImageElementID);
//			e.src = strThumbPath;
//			return true;
//		}
//		else
//		{
//			return false;
//		}
//	}
//}
//
//function AjaxUpdateImageThumb(strThumbPath, strImageElementID)
//{
//	if (bAjaxUpdateImageThumbRunning)
//	{
//		return;
//	}
//	//	send continuous ajax requests until we have the correct thumbnail
//	new Ajax.Request('include/ajax_thumbnailreplace.asp',
//		{
//			onSuccess: function(transport)
//			{
//				if (AjaxUpdateImageThumbResponseHandler(transport, strThumbPath, strImageElementID))
//				{
//					return;	//	we're done
//				}
//				else
//				{
//					bAjaxUpdateImageThumbRunning = false;
//					//	set the timer to launch the next request
//					setTimeout("AjaxUpdateImageThumb('" + strThumbPath + "', '" +  strImageElementID + "')", 3000);
//				}
//			},
//			onFailure: function(transport)
//			{
//				return true;
//			},
//			method: 'get', parameters: 't=' + strThumbPath + '&n=' + Math.round(Math.random() * 10000 + 1)
//		}
//	);
//	bAjaxUpdateImageThumbRunning = true;
//}
///* Ajax Thumbnail Update Stuff - END */


function AjaxUpdateImageThumb2(strThumbPath, strImageElementID)
{
  new Ajax.Request(strThumbPath,
		{
			method: 'get',
			onSuccess: function(transport)
			{
			  //alert('Found ' + strThumbPath);
			  //	set the thumbnail
  			var e = document.getElementById(strImageElementID);
  			e.src = strThumbPath;
  			
			  return true;
			},
			onFailure: function(transport)
			{
				//alert('Not found ' + strThumbPath);
				setTimeout("AjaxUpdateImageThumb2('" + strThumbPath + "', '" +  strImageElementID + "')", 3000);
				return true;
			}
		});
}



function OpenExifViewer(strURL) {
  winExifViewer = window.open(strURL, 'winExifViewer', 'location=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,width=400,height=530');
  winExifViewer.focus();
}

function OpenVoteViewer(strURL) {
  winExifViewer = window.open(strURL, 'winVoteViewer', 'location=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,width=400,height=530');
  winExifViewer.focus();
}

function OpenSmilies(strURL) {
  winExifViewer = window.open(strURL, 'winSmiles', 'location=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,width=200,height=300');
  winExifViewer.focus();
}

function OpenFileUpload(strURL) {
  winFileUpload = window.open(strURL, 'winFileUpload', 'location=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,width=320,height=240');
  winFileUpload.focus();
}

function OpenLightbox(strURL) {
  winLightbox = window.open(strURL, 'winLightbox', 'location=yes,resizable=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,width=640,height=530');
  winLightbox.focus();
}

function OpenChat(strURL, strWindowname) {
  winChat = window.open(strURL, strWindowname, 'location=yes,resizable=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,width=640,height=530');
  winChat.focus();
}

function OpenKeywordAssistent(strURL) {
  winKA = window.open(strURL, 'winKA', 'location=no,status=yes,toolbar=no,menubar=no,scrollbars=yes,width=640,height=530');
  winKA.focus();
}

function OpenInputAssistent(strURL, objInput) {
  IASetFocus(objInput);
  winIA = window.open(strURL, 'winIA', 'location=no,status=yes,toolbar=no,menubar=no,scrollbars=yes,width=370,height=500');
  winIA.focus();
}

function OpenKeywordViewer(strURL) {
  winKV = window.open(strURL, 'winKV', 'location=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,width=400,height=530');
  winKV.focus();
}

function OpenKeywordLoader(strURL) {
  winKL = window.open(strURL, 'winKL', 'location=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,width=640,height=530');
  winKL.focus();
}


function OpenHelp(strURL) {
  winHelp = window.open(strURL, 'winHelp', 'location=no,resizable=yes,status=yes,toolbar=no,menubar=no,scrollbars=yes,width=640,height=660');
  winHelp.focus();
}

function OpenVoteWindow(strURL) {
  winVote = window.open(strURL, 'winVote', 'location=no,status=yes,toolbar=no,menubar=no,scrollbars=yes,width=640,height=530');
  winVote.focus();
}

function OpenUserselect(strURL) {
  winKV = window.open(strURL, 'winKV', 'location=yes,status=yes,toolbar=yes,menubar=yes,scrollbars=yes,width=400,height=530');
  winKV.focus();
}

function OpenColorsearch(strURL) {
  winCS = window.open(strURL, 'winCS', 'location=no,status=no,toolbar=no,menubar=no,scrollbars=no,width=445,height=540');
  winCS.focus();
}


function OpenerLink(strURL) {
  if(parent.opener){
    parent.opener.location.href = strURL;
    parent.opener.focus();
  }else{
    location.href = strURL;
  }
}


//lightbox stuff

function SelectAllPhotos() {
  var theForm = document.FormLightboxPhotos;

  for (i=0,n=theForm.elements.length;i<n;i++) {
    if (theForm.elements[i].name.indexOf('chk') == 0) theForm.elements[i].checked = true;
  }
}

function DeSelectAllPhotos() {
  var theForm = document.FormLightboxPhotos;

  for (i=0,n=theForm.elements.length;i<n;i++) {
    if (theForm.elements[i].name.indexOf('chk') == 0) theForm.elements[i].checked = false;
  }
}

function ReversePhotoSelection() {
  var theForm = document.FormLightboxPhotos;

  for (i=0,n=theForm.elements.length;i<n;i++) {
    if (theForm.elements[i].name.indexOf('chk') == 0) {
      if (theForm.elements[i].checked == false) {
        theForm.elements[i].checked = true;
      } else {
        theForm.elements[i].checked = false;
      }
    }
  }
}

function CountSelectedPhotos() {
		var theForm = document.FormLightboxPhotos;
		var selectedPhotos = 0;

		for (i=0,n=theForm.elements.length;i<n;i++) {
      if (theForm.elements[i].name.indexOf('chk') == 0 && theForm.elements[i].checked == true) selectedPhotos++;
    }

		return selectedPhotos;
}

function GetSelectedPhotoIDs() {
  var theForm = document.FormLightboxPhotos;
  var strPhotoIDs = "";

  for (i=0,n=theForm.elements.length;i<n;i++) {
  	if (theForm.elements[i].name.indexOf('chk') == 0 && theForm.elements[i].checked == true) strPhotoIDs += theForm.elements[i].value + ", ";
  }

  if (strPhotoIDs != "") {
     strPhotoIDs = String(strPhotoIDs).substring(0,String(strPhotoIDs).length-2);
  }

  return strPhotoIDs;
}

function DownloadSelectedPhotos(strFormAction) {
  var theForm = document.FormLightboxPhotos;
  var intPhotoCount = CountSelectedPhotos();

  if (intPhotoCount > 0) {
    theForm.SelectedPhotoIDs.value = GetSelectedPhotoIDs();
    theForm.target = window.opener.name;
    theForm.action = strFormAction;
    theForm.submit();
  }
}

function RemoveSelectedPhotos(strFormAction) {
  var theForm = document.FormLightboxPhotos;
  var intPhotoCount = CountSelectedPhotos();

  if (intPhotoCount > 0) {
    theForm.SelectedPhotoIDs.value = GetSelectedPhotoIDs();
    theForm.action = strFormAction;
    theForm.submit();
  }
}

function CopySelectedPhotos(strFormAction) {
  var theForm = document.FormLightboxPhotos;
  var intPhotoCount = CountSelectedPhotos();

  if (intPhotoCount > 0) {
    theForm.SelectedPhotoIDs.value = GetSelectedPhotoIDs();
    theForm.action = strFormAction;
    theForm.submit();
  }
}

function MoveSelectedPhotos(strFormAction) {
  var theForm = document.FormLightboxPhotos;
  var intPhotoCount = CountSelectedPhotos();

  if (intPhotoCount > 0) {
    theForm.SelectedPhotoIDs.value = GetSelectedPhotoIDs();
    theForm.action = strFormAction;
    theForm.submit();
  }
}


function NotificationRemoveSelected(strFormAction) {
  var theForm = document.FormNotification;

  theForm.action = strFormAction;
  theForm.submit();
}

function NotificationMoveSelected(strFormAction) {
  var theForm = document.FormNotification;

  theForm.action = strFormAction;
  theForm.submit();
}

function NotificationMarkSelectedAsRead(strFormAction) {
  var theForm = document.FormNotification;

  theForm.action = strFormAction;
  theForm.submit();
}

function NotificationToggle(theForm) {
  for (i=0,n=theForm.elements.length;i<n;i++) {
    if (theForm.elements[i].name.indexOf('chk') == 0) {
      theForm.elements[i].checked = theForm.ToggleNotifications.checked
    }
  }
}

function ReplaceInputfieldValue(objInputfield, strNewValue) {
  objInputfield.value = strNewValue
}

function AppendInputfieldValue(objInputfield, strNewValue) {
  objInputfield.value = trim(objInputfield.value);

  //enclose the current keyword with quotation marks if the keyword is a term
  if (strNewValue.indexOf(' ') != -1) strNewValue = '"' + strNewValue + '"';

  if (isEmpty(objInputfield.value)) {
  	objInputfield.value = strNewValue;
  } else {
  	objInputfield.value = objInputfield.value + ', ' + strNewValue;
  }
}


function trim(str) {
   return str.replace(/^\s*|\s*$/g,"");
}

function isEmpty(s) {
	return ((s == null) || (s.length == 0));
}


function checkPasswordSecurity(target) {
	var TestWords = false;
	var TestNumberOfChars = false;
	var TestUppercaseChars = false;
	var TestLowercaseChars = false;
	var TestDigits = false;
	var TestSpecialChars = false;
	var TestCounter = false;
	var TestWhiteSpaces = false;
	var TestSecondPassword = false;

	var counter = 0;
	strInput = target.value;
	objImage = document.images.PasswordSecurity


	/* Check if length of password is greather then 8 */

	if(strInput.length >= 8) {

		if(!TestNumberOfChars) {		// do it only if the counter is 8, if it's greather, the TestNumberOfChars will be true and the right image is shown

			TestNumberOfChars = true;

		}
	} else {

		TestNumberOfChars = false;

	}


	/* check uppercase Letters */

	if(strInput.match(/[A-Z]/)) {

		TestUppercaseChars = true;

	} else {

		TestUppercaseChars = false;

	}

	/* check lowercase letters */

	if(strInput.match(/[a-z]/)) {

		TestLowercaseChars = true;

	} else {

		TestLowercaseChars = false;

	}


	/* check for digits */

	if(strInput.match(/[0-9]/)) {

		TestDigits = true;

	} else {

		TestDigits = false;

	}


	/* check special chars */

	if(strInput.match(/[^a-zA-Z0-9]/)) {

		TestSpecialChars = true;

	} else {

		TestSpecialChars = false;

	}


	/* Check for whitespaces and ESC-Sequences */

	if(strInput.match(/\s/)) {

		TestWhiteSpaces = true;

	} else {

		TestWhiteSpaces = false;

	}


	if(TestUppercaseChars) { counter++; }
	if(TestLowercaseChars) { counter++; }
	if(TestDigits)         { counter++; }
	if(TestSpecialChars)   { counter++; }
	if(TestWhiteSpaces)   { counter++; }
	if(TestNumberOfChars)   { counter++; }

	if(counter == 0) { objImage.src = "images/pwdsec0.gif"; }
  if(counter == 1) { objImage.src = "images/pwdsec1.gif"; }
  if(counter == 2) { objImage.src = "images/pwdsec2.gif"; }
  if(counter == 3) { objImage.src = "images/pwdsec3.gif"; }
  if(counter == 4) { objImage.src = "images/pwdsec4.gif"; }
  if(counter == 5) { objImage.src = "images/pwdsec5.gif"; }
  if(counter == 6) { objImage.src = "images/pwdsec6.gif"; }

}

function ToggleBlock(obj)
{
  if (document.getElementById(obj + 'On').style.display == "none" || document.getElementById(obj + 'On').style.display == "")
  {
    document.getElementById(obj + 'On').style.display = "block";
    document.getElementById(obj + 'Off').style.display = "none";
  }
  else
  {
    document.getElementById(obj + 'On').style.display = "none";
    document.getElementById(obj + 'Off').style.display = "block";
  }
}

function InputSet(obj, text)
{
  document.getElementById(obj).value = text
}



/* popup windows */
function NewWindow(mypage, myname, w, h, scroll) {
  winprops = 'height='+h+',width='+w+',scrollbars='+scroll+',resizable=no, top=20, left=20'
  win = window.open(mypage, myname, winprops)
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

 var Behaviour = {
    register: function(rules){
      this.rules = rules;
      for(rule in this.rules){
        this.reload(rule);
      }
    },

    reload: function(rule){
      elements = $$(rule);
      for(y=0;y<elements.length;y++){
        this.rules[rule](elements[y]);
      }
    }

  }


/**
 set your behaviour rules here
*/


popuprules = {
        'a.popHelp':function(elmt) {
    	elmt.onclick = function() {
    		NewWindow(this.href, 'winHelp', '640', '660', 'yes');return false;
    	}
    },
        'a.pop640-530':function(elmt) {
    	elmt.onclick = function() {
    		NewWindow(this.href,'640x500','640','530','yes');return false;
    	}
    },
        'a.pop200-300':function(elmt) {
    	elmt.onclick = function() {
    		NewWindow(this.href,'200x300','200','300','yes');return false;
    	}
    },
        'a.pop320-240':function(elmt) {
    	elmt.onclick = function() {
    		NewWindow(this.href,'320x240','320','240','yes');return false;
    	}
    },
        'a.pop370-500':function(elmt) {
    	elmt.onclick = function() {
    		NewWindow(this.href,'370x500','370','500','yes');return false;
    	}
    },
        'a.pop400-530':function(elmt) {
    	elmt.onclick = function() {
    		NewWindow(this.href,'400x530','400','530','yes');return false;
    	}
    }

};


photosearchrules = {
  'a.toggleExtSearch':function(elmt) {
      elmt.onclick = function() {
  		new Effect.Phase('extendedSearch');
  		new Effect.toggle('stLabel','blind');
          $('searchBox').style.backgroundColor = $('searchBox').style.backgroundColor? "":"#EEEFF1";
          $('searchBox').style.borderColor = $('searchBox').style.borderColor? "":"#dedede";
  		//this.innerHTML = this.innerHTML == 'Hide advanced Search' ? 'Show advanced Search' : 'Hide advanced Search';
  		this.blur();

  		return false;
  	}
  },
  'select.PhotoResUnit':function(elmt) {
      elmt.onchange = function() {
          var px = this.value=='px';
          document.getElementsByClassName('dpi').each(function(item) {
              item.style.color = px ? '#CDCED0' : '#645D5B';
              $(item.htmlFor).disabled = px;
          });
          var px = this.value=='px';
           document.getElementsByClassName('dpi').each(function(item) {
              item.style.color = px ? '#CDCED0' : '#645D5B';
              var cb = $(item.htmlFor);
              cb.disabled = px;
              if (px)
              cb.checked = !px;
          });

  	}
  }
};
