var mouseOverElem = '';
var lightboxSlider = '';
var basketSlider = '';
var lightout = 'false';
var basket_enter = 'false';
var slideTopper_basket = 0;
var slideTopper_lightbox = 0;
var lights_status = '';
var basket_status = '';
var search_status = '';
var dragElement = '';
var posx = 0;
var posy = 0;
var lights = '';
var baskets = '';
var oFCKeditor = '';
var growing = 'false';
var timer_delay;
var original_image_height;

function change_rnd_img (imgs, b, t) {
	var i = Math.round ( (imgs.length - 1) * Math.random() );
	var img_src = b + img_rnd[ i ];
	
	var img = document.getElementById (t);
	if ( img ) {
		img.src = img_src;
	}
}

function grow_image(image_id) {
	
	if($('preview').checked == true) {
		if(dragStatus != 'drag') {
			if(growing == 'false') {
				if(image_id.id.indexOf('play_') > -1) {
					
					if(image_id.parentNode.parentNode.offsetWidth  < 160) {
						original_image_height = image_id.offsetHeight;
						//alert('width '+image_id.parentNode.parentNode.offsetWidth+', height '+image_id.parentNode.parentNode.offsetHeight);
						new Effect.Scale(image_id.parentNode.parentNode, 180, {scaleY: false});
						new Effect.Scale(image_id, 180, {scaleY: false});
						image_id.style.top = image_id.parentNode.parentNode.offsetHeight -(original_image_height+100)+'px';
						setTimeout(growing = 'true',500);
					}
				}
				else if(image_id.offsetWidth < 160) {
					original_image_height = image_id.offsetHeight;
					//alert('width '+image_id.parentNode.parentNode.offsetWidth+', height '+image_id.parentNode.parentNode.offsetHeight);
					new Effect.Scale(image_id.parentNode.parentNode, 180, {scaleY: false});
					new Effect.Scale(image_id, 180, {scaleY: false});
					image_id.style.top = image_id.parentNode.parentNode.offsetHeight -(original_image_height+100)+'px';
					setTimeout(growing = 'true',1000);
				}
			}
		}
	}
}

function norm_image(image_id,img_w, img_h) {
	if(dragStatus != 'drag') {
		setTimeout(function() {
			if(growing == 'true') {
				if(image_id.id.indexOf('lay_') > -1) {
					
					if(image_id.parentNode.parentNode.offsetWidth > 150) {
						new Effect.Scale(image_id.parentNode.parentNode, 56, {scaleY: false});
						new Effect.Scale(image_id, 56, {scaleY: false});
						image_id.style.top = image_id.parentNode.parentNode.offsetHeight -(original_image_height+102)+'px';
						setTimeout(growing = 'false',500);
					}
				}
				else if(image_id.offsetWidth > 160) {
					new Effect.Scale(image_id.parentNode.parentNode, 56, {scaleY: false});
					new Effect.Scale(image_id, 56, {scaleY: false});
					image_id.style.top = image_id.parentNode.parentNode.offsetHeight -(original_image_height+102)+'px';
					//image_id.style.bottom = '76pt';
					image_id.style.position = 'absolute'; 
					setTimeout(growing = 'false',1000);
				}
			}
		},700);
	}
}


function add_hidden_then_submit(form_name, field_name, field_value) {  
   var field_to_add = document.createElement('input');
   field_to_add.type = "hidden";
   field_to_add.name = "alpha";
   field_to_add.value = field_value;
   
   document.forms[form_name].appendChild(field_to_add);
   document.forms[form_name].submit(); 
}	

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function update_date (prop) {
   var day = document.getElementById ( prop + "_day" );
   var month = document.getElementById ( prop + "_month" );
   var year = document.getElementById ( prop + "_year" );
   
   var dest = document.getElementById ( prop );
   
   dest.value = year.value + "-" + month.value + "-" + day.value;
}

function hide( id ) {
   var itemToHide = document.getElementById( id );
   itemToHide.style.visibility = 'hidden';
}

function show( id ) {
   var itemToShow= document.getElementById( id );
   itemToShow.style.visibility = 'visible';
}

function display( id ) {
   var itemToShow= document.getElementById( id );
   itemToShow.style.display = 'block';
}



var show_hide_list = new Array ();

function add_show_hide ( f, fields ) {
   var field_a = fields.split(/\s*,\s*/);
   
   for (var i in field_a) {
      if ( show_hide_list[field_a[i]] ) {
         if ( show_hide_list[field_a[i]] == 'No' && f == 'Yes' ) {
            show_hide_list[field_a[i]] = 'Yes';
         }
      } else {
         show_hide_list[field_a[i]] = f;
      }
   }
}

function init_show_hide () {
   for (var i in show_hide_list) {
      var tf = document.getElementById("cf_" + i);
      if ( tf != null ) {
         if ( show_hide_list[i] == 'Yes' ) {
            tf.style.display = 'block';
         } else {
            tf.style.display = 'none';
         }
      }
   }
}

function field_show_hide ( f, fields ) {
   
   var field_a = fields.split(/\s*,\s*/);
   var show = f == 'Yes';
   var i;
   
   for (i in field_a) {
      var tf = document.getElementById("cf_" + field_a[i]);
      if ( show ) {
         //tf.style.visibility = 'visible';
         tf.style.display = 'block';
      } else {
         tf.style.display = 'none';
         //tf.style.visibility = 'hidden';
      }
   }
}

function showDisplayAll( id ) {
	for(i = 0; i < document.all.length; i++)
	{
		if (document.all(i).id.substr(0, id.length) == id)
		{
			document.all(i).style.display = 'inline';
		}
	}
}

function hideDisplayAll( id ) {
	for(i = 0; i < document.all.length; i++)
	{
		if (document.all(i).id.substr(0, id.length) == id)
		{
			document.all(i).style.display = 'none';
		}
	}
}

function toggleDisplay( id ) {
	var itemToToggle = document.getElementById( id );
	if (itemToToggle.style.display != 'block')
	{
		display( id );
	}
	else
	{
		itemToToggle.style.display = 'none';
	}
}

function check_toggle(t, c, o) {
	var itemSrc = document.getElementById( t.name + "d" );
	if ( itemSrc ) {
		if ( itemSrc.value == "1" ) {
			t.src = o;
			itemSrc.value = "0";
		} else {
			t.src = c;
			itemSrc.value = "1";
		}
	}
}

function checkAll(formName, c, o, check) {
	for (i = 0; i < document.forms[formName].elements.length; i++) {
		var itemSrc = document.forms[formName].elements[i];
		var nameLength = itemSrc.id.length;
		if (itemSrc.id.substr(nameLength - 2, 1) == 's' && itemSrc.id.substr(nameLength - 1, 1) == 'd') {
			if (check) {
				document.getElementById( itemSrc.id.substr(0, nameLength - 1) ).src = c;
				itemSrc.value = "1";
			} else {
				document.getElementById( itemSrc.id.substr(0, nameLength - 1) ).src = o;
				itemSrc.value = "0";
			}
		}
	}
}

function get_checked_print() {
	var checkedItems = "<html><head>";	
	var linkTags = document.getElementsByTagName('link');
	var lineBreak = 0;
	for(l=0;l<linkTags.length;l++){
		if(linkTags[l].href.indexOf('pictureme.php') > -1) {
			checkedItems += "<link href='" + linkTags[l].href + "' rel='stylesheet' type='text/css'/>"
		}
	}
	checkedItems += "<style type='text/css' media='print'> " +
			".landScape{ width: 100%; height: 100%; margin: 0% 0% 0% 0%; " +
			"filter: progid:DXImageTransform.Microsoft.BasicImage(Rotation=3);}</style>";
	checkedItems += "</head><body class='landScape'>"
	var allItems = document.getElementsByClassName('popPreview');
	
		for(k=0; k < allItems.length; k++) {
			var checkItem = document.getElementById(allItems[k].id + "sd");
			
			if(checkItem) {
				if(checkItem.value == '1') {
					lineBreak ++;
					checkedItems += "<div id='" + allItems[k].id + "_p' " +
					"style='float:left; height:250px; margin-bottom:10px; margin-left:5px; " +
					"margin-right:5px; overflow:hidden; padding:0 0 6px; position:relative; " +
					"text-align:left; width:150px; margin-top: 10px;'>" +
					"<div style='background-color:#FFFFFF;height:158px;padding-top:6px;'>" +
					"<img src='" + document.getElementById("thumb_" + allItems[k].id).src + "' " +
					"width='" + document.getElementById("thumb_" + allItems[k].id).width + "' " +
					"style='bottom:76pt;cursor:pointer;position:absolute;'/>" +
					"</div><div>" + document.getElementById('img_title_' + allItems[k].id).innerHTML +
					"</div></div>";
					
					if(lineBreak > 3) {
						checkedItems += "<div style='clear:both;'></div>";
						lineBreak = 0;
					}	
				}
			}
		}
	checkedItems += "</body></html>";
	return checkedItems;
}

function displayExpiryDate( id, selected ) {
   var selectedToTest = document.getElementById( selected );
   if ( selectedToTest ) {
      if ( selectedToTest.value == 'expires_on' )
         show( id ); 
      else
         hide( id );
   }
}
function doSomething(e) {
	
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}

	//document.getElementById('text').value = posx+":"+posy + " , left:" + $('basket_images').offsetLeft + ", top:" + $('basket_images').offsetTop;
	
	
	
//for images going out of lightbox
	if(lights_status == '1' & basket_status == '1' & search_status == '1') {
		if(posy > 545 & posy < 753) {
			if(posx > 1035 & posx < 1235) {
			//alert('dfgdfg');
			}
		}
	}
	if(lights_status == '1' & basket_status == '1' & search_status == '0') {
		if(posy > 414 & posy < 613) {
			if(posx > 1035 & posx < 1235) {
			//alert('dfgdfg');
			}
		}
	}
	if(lights_status == '1' & basket_status == '1' & search_status == '2') {
		if(posy > 584 & posy < 782) {
			if(posx > 1035 & posx < 1235) {
			//alert('dfgdfg');
			}
		}
	}
}

function getXY(e) {
  x = (window.Event) ? e.pageX : event.clientX;
  y = (window.Event) ? e.pageY : event.clientY;

  document.getElementById('text').value = x+":"+y;
}
function init( ) {
// todo: find a way to specify which init javascript funciton to run
   displayExpiryDate( 'valid_to', 'expire' );
   initDynamicOptionLists();
   document.onmousemove = doSomething;


//   if(!NiftyCheck())
//    return;
//RoundedTop("div#container","#FFF","#e7e7e7");
//RoundedBottom("div#container","#FFF","#e7e7e7");
//RoundedTop("ul#nav li","transparent","#FFC");
//Rounded("div#box","#C0CDF2","#E4E7F2");
//Rounded("div#bktpics li","#F2F2F2","#FFF");
//Rounded("div#minipics li","#F2F2F2","#FFF");
//RoundedTop("div.gradient","#FFF","#B8B8B8");
//RoundedBottom("div.gradient","#FFF","#F2F2F2");  
}

function hideSideBar () {
	var s = document.getElementById ("panel_content");
	var m = document.getElementById ("main_content");
	
	s.innerHTML = "";
	s.style.width = "0%";
	m.style.width = "100%";
	
}

function addLoadEvent(func) { 
   var oldonload = window.onload; 
   if (typeof window.onload != 'function') { 
      window.onload = func; 
   } else { 
      window.onload = function(){ oldonload(); func(); } 
   }
} 

var openwin;
function popupwin(url,myname,w,h,s) { 
   settings='height='+h+',width='+w+',scrollbars='+s+',toolbar=no,location=no,status=no,menubar=no,resizable=no,dependent=no';
   openwin=window.open(url,myname,settings);
}

function popupwin_toolbar(url,myname,w,h,s) { 
   settings='height='+h+',width='+w+',scrollbars='+s+',toolbar=yes,location=yes,status=no,menubar=yes,resizable=no,dependent=no';
   openwin=window.open(url,myname,settings);
}




function details_onload() {
   var hidelink = document.getElementById ("ei_p");
   if ( hidelink === null ) {
      return;
   }
   hidelink.innerHTML = '<a href="javascript:showDetails();">More details &gt;&gt;</a>';

   var detailDiv = document.getElementById ("ei_d");
   detailDiv.style.height = "0";
   detailDiv.style.display = "none";
   
   var hidelink = document.getElementById ("ei_el");
   hidelink.innerHTML = '<br><a href="javascript:hideDetails();">&lt;&lt; hide details</a>';
}

function showDetails() {
  var detailDiv = document.getElementById ("ei_d");
  detailDiv.style.height = "";
  detailDiv.style.display = "inline";
  
  var hidelink = document.getElementById ("ei_p");
  hidelink.style.display = "none";
}

function hideDetails() {
  var detailDiv = document.getElementById ("ei_d");
  detailDiv.style.height = "0";
  detailDiv.style.display = "none";
  
  var hidelink = document.getElementById ("ei_p");
  hidelink.style.display = "inline";
}





function check_fields()
{
  
 
	 
	//alert(document.forms[0].elements.length);
	
	if (document.forms[0].elements["project_details[1]"].value == "" ||
	    document.forms[0].elements["project_details[2]"].value == "" )
	{
		alert("Please fill in all compulsory fields");
				
		return false;
	}
	else
	  return true;
	
	
	
  alert(document.forms[0].elements["project_details[1]"].value);
	 
		
  
	
	return false;
	
}

function check_delete () {
 
  var totalForms = document.forms.length;
  var del = false;
  // loops through forms on page
  for (f = 0; f < totalForms; f++){
    var len = document.forms[f].elements.length;
    // loops through elements in form  
    for (i = 0; i < len; i++ ){
      var name = document.forms[f].elements[i].name;
      // finds checkbox with name "del"
      if (name.substr(0, 3) == "del"){
        // returns true if "del" checkbox checked
        var delBox = document.forms[f].elements[i].checked;
        if (delBox){ 
          del = true;
        }
      }
    }
  }
  
  if (del){ 
    return confirm ("Are you sure you want to Delete?");
  }
return true;
}



// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

// HISTORY
// ------------------------------------------------------------------
// March 31, 2004: First release
/* 

DESCRIPTION: This library allows you to easily create select boxes whose
contents depend on the value in a parent select box. It supports default
options, preselected options, single or multiple-select lists, multiple
form fields referencing the same list structure, form resetting, and most
importantly, it's backwards-compatible way back to Netscape 4!

COMPATABILITY: Netscape 4+, IE, Opera >5 (O5 didn't support new Option()),
and should work on all other newer browsers.

USAGE:

	// Create a new object, passing in the fields that make up the dynamic set 
	// of lists.
var dol = new DynamicOptionList("Field1","Child1","Child2");
	
	// Or, you can create it empty, and pass in sets of select objects later
var dol = new DynamicOptionList();
dol.addDependentFields("Field1","Child1","Child2");

	// Once you have the list object defined, you can additional sets of dependent
	// fields, too. These sets will act as separate groups of related fields, but
	// will all use the same options and data.
dol.addDependentOptions("Field1","Child2-1","Child2-2");

	// By default, the script will automatically find the form where your select
	// objects exist. But you can explicitly set it if you wish, either by form 
	// name or index.
dol.setFormName("MyForm");
dol.setFormIndex(1);

	// Now define the options that will exist in sub-lists. This is done in a 
	// very logical way - you say for an option in the parent, populate the child
	// with specific options. When selecting which parent option you're dealing
	// with, you can either select by its value or its display text. This command
	// says, for an option in the parent list that has value="Value1", if it is
	// selected then populate the child list with the given sub-options.
dol.forValue("Value1").addOptions("Suboption1","Suboption2","Suboption3");

	// And you can also say, for an option in the parent list that has display
	// text of "Text1", if it is selected then populate the child list with the
	// given sub-options.
dol.forText("Text1").addOptions("Suboption1","Suboption2","Suboption3");

	// For multi-level lists, you just continue the chain...
	// This says, if an option with value "Value1" is selected in the first list,
	// then an option with values "Value2" is selected in the second list, populate
	// the third list with these options.
dol.forValue("Value1").forValue("Value2").addOptions("1","2","3");

	// If the options you want to add should have different values and dislplay
	// text, you can do that
dol.forValue("Value1").addOptionsTextValue("Text2","Value2");

	// When an option is selected from the first list, and the options in the 
	// second list are populated, you may want to have one of the options in the
	// child list be selected by default.
dol.forValue("Value1").setDefaultOptions("MyValue");

	// When the page first loads, you may set the values of the dependent select
	// lists to be selected by default. For example, when a user is editing an
	// existing record where they've already selected from the parent/child
	// relationships. This is different from the default option in that this
	// value is only selected when the page LOADS. If the user changes selections,
	// this will be lost.
dol.forValue("Value1").setValues("MyPreselectedValue");

	// By default, if there are is no option which should be selected in the child
	// list, the code will automatically select the first option in the list. If 
	// you want it to instead set selectedIndex = -1 (nothing selected - works in
	// most browsers but not all) than you can tell it to do that instead
dol.selectFirstOption = false;

// MODIFYING THE HTML
// If you are supporting Netscape 4.x browsers, you will need to insert a call to
// the library to populate options. This is because Netscape4 will not expand the
// size of the select box as new options are added, so you have to "pad" the list
// with blank options in order for it to work right. 
// This is the ONLY change you should need to make to your HTML. To do this, just
// add a javascript block between your <select> </select> tags like this:

<select name="list1"><script>dol.printOptions("list1")</script></select>

// You only need to pass it the name of the select options that it should print
// options for.


NOTES:
 - There seems to be an issue with Netscape6, if you hit Reload on the page. It
   doesn't happen every time, and I can't figure out why it happens at all.

 - If your select objects have onChange handlers in them, you'll need to manually
   add a call to the DynamicOptionList code to trigger the population of the child
   list. For example,
   
   <select onChange="yourfunction(); dol.change(this)">
 
*/


function menu_hover(htmlElement, imageSrc) {
	htmlElement.getElementsByTagName('img')[0].src = '/images/'+imageSrc;
	if(imageSrc.indexOf('hover') > -1) {
		htmlElement.getElementsByTagName('h2')[0].className = 'h2_hover';
	}
	else {
		htmlElement.getElementsByTagName('h2')[0].className = 'h2_normal';
	}
}

function select_search() {
	document.getElementById('welcome_top').className = 'menu_label';
	document.getElementById('welcome_link').style.color = '#747577';
	document.getElementById('search_link').style.color = '#ffffff';
	document.getElementById('search_top').className = 'menu_label_current';
	document.getElementById('img_welcome_selected').style.display = 'none';
	document.getElementById('img_welcome_not_selected').style.display = 'block';
}
// Global objects to keep track of DynamicOptionList objects created on the page
var dynamicOptionListCount=0;
var dynamicOptionListObjects = new Array();

// Init call to setup lists after page load. One call to this function sets up all lists.
function initDynamicOptionLists() {
	// init each DynamicOptionList object
	for (var i=0; i<dynamicOptionListObjects.length; i++) {
		var dol = dynamicOptionListObjects[i];

		// Find the form associated with this list
		if (dol.formName!=null) { 
			dol.form = document.forms[dol.formName];
		}
		else if (dol.formIndex!=null) {
			dol.form = document.forms[dol.formIndex];
		}
		else {
			// Form wasn't set manually, so go find it!
			// Search for the first form element name in the lists
			var name = dol.fieldNames[0][0];
			for (var f=0; f<document.forms.length; f++) {
				if (typeof(document.forms[f][name])!="undefined") {
					dol.form = document.forms[f];
					break;
				}
			}
			if (dol.form==null) {
				alert("ERROR: Couldn't find form element "+name+" in any form on the page! Init aborted"); return;
			}
		}

		// Form is found, now set the onchange attributes of each dependent select box
		for (var j=0; j<dol.fieldNames.length; j++) {
			// For each set of field names...
			for (var k=0; k<dol.fieldNames[j].length-1; k++) {
				// For each field in the set...
				var selObj = dol.form[dol.fieldNames[j][k]];
				if (typeof(selObj)=="undefined") { alert("Select box named "+dol.fieldNames[j][k]+" could not be found in the form. Init aborted"); return; }
				// Map the HTML options in the first select into the options we created
				if (k==0) {
					if (selObj.options!=null) {
						for (l=0; l<selObj.options.length; l++) {
							var sopt = selObj.options[l];
							var m = dol.findMatchingOptionInArray(dol.options,sopt.text,sopt.value,false);
							if (m!=null) {
								var reselectForNN6 = sopt.selected;
								var m2 = new Option(sopt.text, sopt.value, sopt.defaultSelected, sopt.selected);
								m2.selected = sopt.selected; // For some reason I need to do this to make NN4 happy
								m2.defaultSelected = sopt.defaultSelected;
								m2.DOLOption = m;
								selObj.options[l] = m2;
								selObj.options[l].selected = reselectForNN6; // Reselect this option for NN6 to be happy. Yuck.
							}
						}
					}
				}
				if (selObj.onchange==null) {
					// We only modify the onChange attribute if it's empty! Otherwise do it yourself in your source!
					selObj.onchange = new Function("dynamicOptionListObjects["+dol.index+"].change(this)");
				}
			}
		}
	}
	// Set the preselectd options on page load 
	resetDynamicOptionLists();
}

// This function populates lists with the preselected values. 
// It's pulled out into a separate function so it can be hooked into a 'reset' button on a form
// Optionally passed a form object which should be the only form reset
function resetDynamicOptionLists(theform) {
	// reset each DynamicOptionList object
	for (var i=0; i<dynamicOptionListObjects.length; i++) {
		var dol = dynamicOptionListObjects[i];
		if (typeof(theform)=="undefined" || theform==null || theform==dol.form) {
			for (var j=0; j<dol.fieldNames.length; j++) {
				dol.change(dol.form[dol.fieldNames[j][0]],true); // Second argument says to use preselected values rather than default values
			}
		}
	}
}

// An object to represent an Option() but just for data-holding
function DOLOption(text,value,defaultSelected,selected) {
	this.text = text;
	this.value = value;
	this.defaultSelected = defaultSelected;
	this.selected = selected;
	this.options = new Array(); // To hold sub-options
	return this;
}

// DynamicOptionList CONSTRUCTOR
function DynamicOptionList() {
	this.form = null;// The form this list belongs to
	this.options = new Array();// Holds the options of dependent lists
	this.longestString = new Array();// Longest string that is currently a potential option (for Netscape)
	this.numberOfOptions = new Array();// The total number of options that might be displayed, to build dummy options (for Netscape)
	this.currentNode = null;// The current node that has been selected with forValue() or forText()
	this.currentField = null;// The current field that is selected to be used for setValue()
	this.currentNodeDepth = 0;// How far down the tree the currentNode is
	this.fieldNames = new Array();// Lists of dependent fields which use this object
	this.formIndex = null;// The index of the form to associate with this list
	this.formName = null;// The name of the form to associate with this list
	this.fieldListIndexes = new Object();// Hold the field lists index where fields exist
	this.fieldIndexes = new Object();// Hold the index within the list where fields exist
	this.selectFirstOption = true;// Whether or not to select the first option by default if no options are default or preselected, otherwise set the selectedIndex = -1
	this.numberOfOptions = new Array();// Store the max number of options for a given option list
	this.longestString = new Array();// Store the longest possible string 
	this.values = new Object(); // Will hold the preselected values for fields, by field name
	
	// Method mappings
	this.forValue = DOL_forValue;
	this.forText = DOL_forText;
	this.forField = DOL_forField;
	this.forX = DOL_forX;
	this.addOptions = DOL_addOptions;
	this.addOptionsTextValue = DOL_addOptionsTextValue;
	this.setDefaultOptions = DOL_setDefaultOptions;
	this.setValues = DOL_setValues;
	this.setValue = DOL_setValues;
	this.setFormIndex = DOL_setFormIndex;
	this.setFormName = DOL_setFormName;
	this.printOptions = DOL_printOptions;
	this.addDependentFields = DOL_addDependentFields;
	this.change = DOL_change;
	this.child = DOL_child;
	this.selectChildOptions = DOL_selectChildOptions;
	this.populateChild = DOL_populateChild;
	this.change = DOL_change;
	this.addNewOptionToList = DOL_addNewOptionToList;
	this.findMatchingOptionInArray = DOL_findMatchingOptionInArray;

	// Optionally pass in the dependent field names
	if (arguments.length > 0) {
		// Process arguments and add dependency groups
		for (var i=0; i<arguments.length; i++) {
			this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;
			this.fieldIndexes[arguments[i].toString()] = i;
		}
		this.fieldNames[this.fieldNames.length] = arguments;
	}
	
	// Add this object to the global array of dynamicoptionlist objects
	this.index = window.dynamicOptionListCount++;
	window["dynamicOptionListObjects"][this.index] = this;
}

// Given an array of Option objects, search for an existing option that matches value, text, or both
function DOL_findMatchingOptionInArray(a,text,value,exactMatchRequired) {
	if (a==null || typeof(a)=="undefined") { return null; }
	var value_match = null; // Whether or not a value has been matched
	var text_match = null; // Whether or not a text has been matched
	for (var i=0; i<a.length; i++) {
		var opt = a[i];
		// If both value and text match, return it right away
		if (opt.value==value && opt.text==text) { return opt; }
		if (!exactMatchRequired) {
			// If value matches, store it until we complete scanning the list
			if (value_match==null && value!=null && opt.value==value) {
				value_match = opt;
			}
			// If text matches, store it for later
			if (text_match==null && text!=null && opt.text==text) {
				text_match = opt;
			}
		}
	}
	return (value_match!=null)?value_match:text_match;
}

// Util function used by forValue and forText
function DOL_forX(s,type) {
	if (this.currentNode==null) { this.currentNodeDepth=0; }
	var useNode = (this.currentNode==null)?this:this.currentNode;
	var o = this.findMatchingOptionInArray(useNode["options"],(type=="text")?s:null,(type=="value")?s:null,false);
	if (o==null) {
		o = new DOLOption(null,null,false,false);
		o[type] = s;
		useNode.options[useNode.options.length] = o;
	}
	this.currentNode = o;
	this.currentNodeDepth++;
	return this;
}

// Set the portion of the list structure that is to be used by a later operation like addOptions
function DOL_forValue(s) { return this.forX(s,"value"); }

// Set the portion of the list structure that is to be used by a later operation like addOptions
function DOL_forText(s) { return this.forX(s,"text"); }

// Set the field to be used for setValue() calls
function DOL_forField(f) { this.currentField = f; return this; }

// Create and add an option to a list, avoiding duplicates
function DOL_addNewOptionToList(a, text, value, defaultSelected) {
	var o = new DOLOption(text,value,defaultSelected,false);
	// Add the option to the array
	if (a==null) { a = new Array(); }
	for (var i=0; i<a.length; i++) {
		if (a[i].text==o.text && a[i].value==o.value) {
			if (o.selected) { 
				a[i].selected=true;
			}
			if (o.defaultSelected) {
				a[i].defaultSelected = true;
			}
			return a;
		}
	}
	a[a.length] = o;
}

// Add sub-options to the currently-selected node, with the same text and value for each option
function DOL_addOptions() {
	if (this.currentNode==null) { this.currentNode = this; }
	if (this.currentNode["options"] == null) { this.currentNode["options"] = new Array(); }
	for (var i=0; i<arguments.length; i++) {
		var text = arguments[i];
		this.addNewOptionToList(this.currentNode.options,text,text,false);
		if (typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined") {
			this.numberOfOptions[this.currentNodeDepth]=0;
		}
		if (this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]) {
			this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;
		}
		if (typeof(this.longestString[this.currentNodeDepth])=="undefined" || (text.length > this.longestString[this.currentNodeDepth].length)) {
			this.longestString[this.currentNodeDepth] = text;
		}
	}
	this.currentNode = null;
	this.currentNodeDepth = 0;
}

// Add sub-options to the currently-selected node, specifying separate text and values for each option
function DOL_addOptionsTextValue() {
	if (this.currentNode==null) { this.currentNode = this; }
	if (this.currentNode["options"] == null) { this.currentNode["options"] = new Array(); }
	for (var i=0; i<arguments.length; i++) {
		var text = arguments[i++];
		var value = arguments[i];
		this.addNewOptionToList(this.currentNode.options,text,value,false);
		if (typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined") {
			this.numberOfOptions[this.currentNodeDepth]=0;
		}
		if (this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]) {
			this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;
		}
		if (typeof(this.longestString[this.currentNodeDepth])=="undefined" || (text.length > this.longestString[this.currentNodeDepth].length)) {
			this.longestString[this.currentNodeDepth] = text;
		}
	}
	this.currentNode = null;
	this.currentNodeDepth = 0;
}

// Find the first dependent list of a select box
// If it's the last list in a chain, return null because there are no children
function DOL_child(obj) {
	var listIndex = this.fieldListIndexes[obj.name];
	var index = this.fieldIndexes[obj.name];
	if (index < (this.fieldNames[listIndex].length-1)) {
		return this.form[this.fieldNames[listIndex][index+1]];
	}
	return null;
}

// Set the options which should be selected by default for a certain value in the parent
function DOL_setDefaultOptions() {
	if (this.currentNode==null) { this.currentNode = this; }
	for (var i=0; i<arguments.length; i++) {
		var o = this.findMatchingOptionInArray(this.currentNode.options,null,arguments[i],false);
		if (o!=null) {
			o.defaultSelected = true;
		}
	}
	this.currentNode = null;
}

// Set the options which should be selected when the page loads. This is different than the default value and ONLY applies when the page LOADS
function DOL_setValues() {
	if (this.currentField==null) { 
		alert("Can't call setValues() without using forField() first!");
		return;
	}
	if (typeof(this.values[this.currentField])=="undefined") {
		this.values[this.currentField] = new Object();
	}
	for (var i=0; i<arguments.length; i++) {
		this.values[this.currentField][arguments[i]] = true;
	}
	this.currentField = null;
}

// Manually set the form for the object using an index
function DOL_setFormIndex(i) {
	this.formIndex = i;
}

// Manually set the form for the object using a form name
function DOL_setFormName(n) {
	this.formName = n;
}

// Print blank <option> objects for Netscape4, since it refuses to grow or shrink select boxes for new options
function DOL_printOptions(name) {
	// Only need to write out "dummy" options for Netscape4
    if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) <= 4)){
		var index = this.fieldIndexes[name];
		var ret = "";
		if (typeof(this.numberOfOptions[index])!="undefined") {
			for (var i=0; i<this.numberOfOptions[index]; i++) { 
				ret += "<OPTION>";
			}
		}
		ret += "<OPTION>";
		if (typeof(this.longestString[index])!="undefined") {
			for (var i=0; i<this.longestString[index].length; i++) {
				ret += "_";
			}
		}
		document.writeln(ret);
	}
}

// Add a list of field names which use this option-mapping object.
// A single mapping object may be used by multiple sets of fields
function DOL_addDependentFields() {
	for (var i=0; i<arguments.length; i++) {
		this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;
		this.fieldIndexes[arguments[i].toString()] = i;
	}
	this.fieldNames[this.fieldNames.length] = arguments;
}

// Called when a parent select box is changed. It populates its direct child, then calls change on the child object to continue the population.
function DOL_change(obj, usePreselected) {
	if (usePreselected==null || typeof(usePreselected)=="undefined") { usePreselected = false; }
	var changedListIndex = this.fieldListIndexes[obj.name];
	var changedIndex = this.fieldIndexes[obj.name];
	var child = this.child(obj);
	if (child == null) { return; } // No child, no need to continue
	if (obj.type == "select-one") {
		// Treat single-select differently so we don't have to scan the entire select list, which could potentially speed things up
		if (child.options!=null) {
			child.options.length=0; // Erase all the options from the child so we can re-populate
		}
		if (obj.options!=null && obj.options.length>0 && obj.selectedIndex>=0) {
			var o = obj.options[obj.selectedIndex];
			this.populateChild(o.DOLOption,child,usePreselected);
			this.selectChildOptions(child,usePreselected);
		}
	}
	else if (obj.type == "select-multiple") {
		// For each selected value in the parent, find the options to fill in for this list
		// Loop through the child list and keep track of options that are currently selected
		var currentlySelectedOptions = new Array();
		if (!usePreselected) {
			for (var i=0; i<child.options.length; i++) {
				var co = child.options[i];
				if (co.selected) {
					this.addNewOptionToList(currentlySelectedOptions, co.text, co.value, co.defaultSelected);
				}
			}
		}
		child.options.length=0;
		if (obj.options!=null) {
			var obj_o = obj.options;
			// For each selected option in the parent...
			for (var i=0; i<obj_o.length; i++) {
				if (obj_o[i].selected) {
					// if option is selected, add its children to the list
 					this.populateChild(obj_o[i].DOLOption,child,usePreselected);
				}
			}
			// Now go through and re-select any options which were selected before
			var atLeastOneSelected = false;
			if (!usePreselected) {
				for (var i=0; i<child.options.length; i++) {
					var m = this.findMatchingOptionInArray(currentlySelectedOptions,child.options[i].text,child.options[i].value,true);
					if (m!=null) {
						child.options[i].selected = true;
						atLeastOneSelected = true;
					}
				}
			}
			if (!atLeastOneSelected) {	
				this.selectChildOptions(child,usePreselected);
			}
		}
	}
	// Change all the way down the chain
	this.change(child,usePreselected);
}
function DOL_populateChild(dolOption,childSelectObj,usePreselected) {
	// If this opton has sub-options, populate the child list with them
	if (dolOption!=null && dolOption.options!=null) {
		for (var j=0; j<dolOption.options.length; j++) {
			var srcOpt = dolOption.options[j];
			if (childSelectObj.options==null) { childSelectObj.options = new Array(); }
			// Put option into select list
			var duplicate = false;
			var preSelectedExists = false;
			for (var k=0; k<childSelectObj.options.length; k++) {
				var csi = childSelectObj.options[k];
				if (csi.text==srcOpt.text && csi.value==srcOpt.value) {
					duplicate = true;
					break;
				}
			}
			if (!duplicate) {
				var newopt = new Option(srcOpt.text, srcOpt.value, false, false);
				newopt.selected = false; // Again, we have to do these two statements for NN4 to work
				newopt.defaultSelected = false;
				newopt.DOLOption = srcOpt;
				childSelectObj.options[childSelectObj.options.length] = newopt;
			}
		}
	}
}

// Once a child select is populated, go back over it to select options which should be selected
function DOL_selectChildOptions(obj,usePreselected) {
	// Look to see if any options are preselected=true. If so, then set then selected if usePreselected=true, otherwise set defaults
	var values = this.values[obj.name];
	var preselectedExists = false;
	if (usePreselected && values!=null && typeof(values)!="undefined") {
		for (var i=0; i<obj.options.length; i++) {
			var v = obj.options[i].value;
			if (v!=null && values[v]!=null && typeof(values[v])!="undefined") {
				preselectedExists = true;
				break;
			}
		}
	}
	// Go back over all the options to do the selection
	var atLeastOneSelected = false;
	for (var i=0; i<obj.options.length; i++) {
		var o = obj.options[i];
		if (preselectedExists && o.value!=null && values[o.value]!=null && typeof(values[o.value])!="undefined") {
			o.selected = true;
			atLeastOneSelected = true;
		}
		else if (!preselectedExists && o.DOLOption!=null && o.DOLOption.defaultSelected) {
			o.selected = true;
			atLeastOneSelected = true;
		}
		else {
			o.selected = false;
		}
	}
	// If nothing else was selected, select the first one by default
	if (this.selectFirstOption && !atLeastOneSelected && obj.options.length>0) {
		obj.options[0].selected = true;
	}
	else if (!atLeastOneSelected &&  obj.type=="select-one") {
		obj.selectedIndex = -1;
	}
}

// Update the colour preview when editing site look and feel
function updateColour(id)
{
	var colourCell = document.getElementById('new-' + id);
	var colour = document.getElementById('edit-' + id);
	colourCell.bgColor = '#' + colour.value;
}

// Go to URL
function goToURL(url) {
	this.location.href = url;
}


// Delivery Option Extras AJAX code
function replaceOptionExtras(result) {
	var content = [];
	for (i = 0; i < result['data'].length; i++) {
		if (i > 0) {
			content += "<br/>";
		}
		content += result['data'][i]['page_content'];
	}

	var replacedNode = $("extra[" + result['item_id'] + "]");
	replacedNode.innerHTML = content;
}

function get_extras(item_id, formvars) {
	var name = 'format[' + item_id + ']';
	var option_id = formvars[name].value;
   var d = loadJSONDoc("../delivery/admin.me?action=get_extras&id=" + option_id + "&item_id=" + item_id);
   d.addCallback(replaceOptionExtras);

   return false;
}


// Enter details price calculations AJAX code
function replacePrices(result) {
	for (var i in result['item_prices']) {
		$("item_price[" + i + "]").innerHTML = result['item_prices'][i];
		$("item_price_val[" + i + "]").value = result['item_prices'][i];
	}
	$("sub_total").innerHTML = result['sub_total'];
	$("sub_total_bottom").innerHTML = "<strong>" + result['sub_total'] + "</strong>";
	$("sub_total_top").innerHTML = "<strong>" + result['sub_total'] + "</strong>";
	$("sub_total_val").value = result['sub_total'];
	$("delivery").innerHTML = result['delivery'];
	$("delivery_val").value = result['delivery'];
	$("total_price").innerHTML = result['total_price'];

	// GST is optional
	var gst = $("gst");
	if (gst) {
		$("gst").innerHTML = result['gst'];
	}
}

function update_prices(formvars) {
	var url = "../order/enter_details.me?get_prices_json=1";

	for (var i = 0; i < formvars.length; i++) {
		if ((formvars[i].name.substring(0,7) == 'format[') || (formvars[i].name.substring(0,16) == 'order_item_data[')) {
			url += '&' + formvars[i].name + '=' + escape(formvars[i].value);
		}
	}

	var d = loadJSONDoc(url);
	d.addCallback(replacePrices);
	return false;
}

function disable_element( id ) {
   var item = document.getElementById( id );
   item.disabled = true;
}

function enable_element( id ) {
   var item = document.getElementById( id );
   item.disabled = false;
}

function createSeperator(sepNum){
		for (var p = 0; p < sepNum; p++) {
			var newSep = document.createElement('div');
			newSep.setAttribute('id','sep'+ p);
			newSep.setAttribute('class', 'seperator');
			//document.getElementById('main_content').appendChild(newSep);
			alert(document.getElementById('demoSep').parentNode.id);
			document.getElementById('demoSep').parentNode.appendChild(newSep);
			//alert(document.getElementById('main_content').innerHTML);
		}
	}
function whichelement(e) {
  var x = event.clientX;
  var y = event.clientY;
  
  if (window.event.srcElement.name) {
	mouseOverElem = window.event.srcElement.name;
  }
  else {
    mouseOverElem = "";
  }
  window.status = mouseOverElem;
  return mouseOverElem;
}

function makeDroppable(dropObjId, panelName, navURL, acceptClass){
	var thisLoc = document.location.pathname;
	var receivedObject;
	var newHoverClass = '';
	if(navURL != '') {
		newHoverClass = 'hover';
	}
	if (thisLoc.indexOf('signup.me') <= -1) {
		Droppables.add(dropObjId, {
			accept: acceptClass,
			hoverclass: newHoverClass,
			onDrop: function(){
				
				if(acceptClass == 'popPreview') {
					receivedObject = document.getElementById("thumb_"+dragImgId);
				}
				/*
				if(acceptClass == 'panel_pics_box_light') {
					
					receivedObject = document.getElementById("light_"+dragImgId);
				}
				if(acceptClass == 'panel_pics_box_basket') {
					receivedObject = document.getElementById("basket_"+dragImgId);
				}
				*/
				receivedObject.style.display = 'none';
				
				dragStatus = "drop";
				addNavUrl = navURL + dragImgId;
				if (dragImgId.length > 0 && navURL.length > 0) {
					//alert(dragImageId + ", " + addNavUrl);
					//window.location = addNavUrl;
					//alert(imgItemId + ", " + dropObjId + ", " + addNavUrl);
					ajaxFunction(imgItemId, dropObjId, addNavUrl);
					new Effect.Pulsate(dropObjId,{ pulses: 1, duration: 1.0 });
				}
				
				
				setTimeout(function() {
					Effect.Appear(receivedObject.id,{ duration: 3.0 });
					if(acceptClass == 'popPreview') {
						document.getElementById(dragImgId).style.left = '0px';
						document.getElementById(dragImgId).style.top = '0px';
					}
					else {
						$(dropObjId).style.left = '0px';
						$(dropObjId).style.top = '0px';
					}
					
				}, 200);
				
				/*
				if (document.getElementById(panelName)) {
					$(panelName).highlight();
				}
				*/
			}
		});
	}
}

function setSliderValue(slider, value) {
	// due to onChange code above we need this or 
	// a 0 will be put in the text box when you delete the value
	if(slider) {
	if (value == '') return;
	if (isNaN(value))
		slider.setValue(0);
	else
		slider.setValue(value/100);
	}
}

function scrollVertical(value, element, slider) {
	//alert(element.scrollTop);
	element.scrollTop = Math.round(value/slider.maximum*(element.scrollHeight-element.offsetHeight));
	//document.getElementById('text').value = Math.round(value/slider.maximum*(element.scrollHeight-element.offsetHeight));
	//document.getElementById('text').value = window.screenY;
	if(element.id.indexOf('lightbox') > -1){
		
		slideTopper_lightbox = Math.round(value/slider.maximum*(element.scrollHeight-element.offsetHeight));
		document.getElementById('light_slider_scroll').value = slideTopper_lightbox;
	}
	if(element.id.indexOf('basket') > -1){
		slideTopper_basket = Math.round(value/slider.maximum*(element.scrollHeight-element.offsetHeight));
		document.getElementById('basket_slider_scroll').value = slideTopper_basket;
	}
	//slideTopper = parseInt(slideTopper) + parseInt(window.pageYOffset);
}

function increasePanelHeight(pics_light, panelName){
	
	//alert(pics_light+', '+panelName);
	var handle = panelName + "Handle";
	var track = panelName + "Track";
	if(lightboxSlider) {
		setSliderValue(lightboxSlider,'0');
	}
	if(basketSlider) {
		setSliderValue(basketSlider,'0');
	}
	setTimeout(function(){
		if (pics_light >= 1) {
			document.getElementById(panelName).style.height = '60px';
		}
		if (pics_light >= 4) {
			document.getElementById(panelName).style.height = '141px';
		}
		
		if (pics_light >= 7) {
			if(panelName.indexOf('lightbox') > -1) {
				//Scroller.reset('lightbox_thumbnails');
				
				 lightboxSlider = new Control.Slider(handle, track, {
					range: $R(0, 0.98),
					sliderValue: 0,
					axis: 'vertical',
					onSlide: function(v) { scrollVertical(v, $(panelName), lightboxSlider); $('light_slider_value').value = v },
					onChange: function(v) { scrollVertical(v, $(panelName), lightboxSlider); $('light_slider_value').value = v}
				});
				
			}
			if(panelName.indexOf('basket') > -1) {
				basketSlider = new Control.Slider(handle, track, {
					range: $R(0, 0.98),
					sliderValue: 0,
					axis: 'vertical',
					onSlide: function(v) { scrollVertical(v, $(panelName), basketSlider); $('basket_slider_value').value = v },
					onChange: function(v) { scrollVertical(v, $(panelName), basketSlider); $('basket_slider_value').value = v }
				});
			}
			document.getElementById(handle).innerHTML = "<img src='/images/scrollbar-handle.png'></img>";
			document.getElementById(track).style.backgroundColor = "#7B7B7B";
		}
		if(pics_light <= 6) {
			document.getElementById(handle).innerHTML = "";
			document.getElementById(track).style.backgroundColor = "transparent";
		}
		/*
		if (pics_light >= 10) {
			document.getElementById(panelName).style.height = '260px';
		}
		if (pics_light >= 13) {
			document.getElementById(panelName).style.height = '330px';
		}
		*/
	}, 50);
}

function showHelp(helpContent) {
	document.getElementById('helpText').innerHTML = helpContent;
}

function hideHelp() {
	document.getElementById('helpText').innerHTML = '';
}

function update_mini_keywords(mini_id, keys_text, obj_id, command) {
	
var xmlHttp;
var xmlText="";
try
  {  // Firefox, Opera 8.0+, Safari  
  xmlHttp=new XMLHttpRequest();  }

catch (e)
  {  // Internet Explorer  
  try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      
	  		 return false;      }    }  }
  xmlHttp.onreadystatechange=function()
    { 
	
    if (xmlHttp.readyState == 4) {
		xmlText = xmlHttp.responseText;
		xml_split = xmlText.split(":");
		
		xml_split[1] = xml_split[1].replace (/\s+/g, '');
		var unique_array = xml_split[1].split(",");
		var current_keys = unique(unique_array);
		document.getElementById(keys_text).value = current_keys.join(",");
		
		xml_split[0] = xml_split[0].replace (/\s+/g, '');
		unique_array = xml_split[0].split(",");
		current_keys = unique(unique_array);
		document.getElementById(obj_id).value = current_keys.join(",");
		
		trim(document.getElementById(obj_id));
		trim(document.getElementById(keys_text));
		
		return xmlText;
}
    }
	trim(document.getElementById(keys_text));
 	xmlHttp.open("GET", "http://" + document.location.host + "/fetched.php?mini_id="+mini_id+"&command="+command+"&new_keys="+document.getElementById(keys_text).value,true);

  xmlHttp.send(null);  
  
}
function trim(ogg) {
ogg.value = ogg.value.replace (/\s+/g, '');
} 

function unique(arrayName)
            {
                var newArray=new Array();
                label:for(var i=0; i<arrayName.length;i++ )
                {  
                    for(var j=0; j<newArray.length;j++ )
                    {
                        if(newArray[j]==arrayName[i]) 
                            continue label;
                    }
                    newArray[newArray.length] = arrayName[i];
                }
                return newArray;
            }

function update_collection_privileges(mini_id,command,priv_id) {
	
var xmlHttp;
var xmlText="";
var select_html ="";
var selected_text = "";
var w = document.getElementById(priv_id).selectedIndex;
selected_text = document.getElementById(priv_id).options[w].value;
try
  {  // Firefox, Opera 8.0+, Safari  
  xmlHttp=new XMLHttpRequest();  }

catch (e)
  {  // Internet Explorer  
  try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      
	  		 return false;      }    }  }
  xmlHttp.onreadystatechange=function()
    { 
	
    if (xmlHttp.readyState == 4) {
		xmlText = xmlHttp.responseText;
		
		xmlText_values = xmlText.split(":");
		
		var option_text = xmlText_values[0].split(",");
		var option_values = xmlText_values[1].split(",");
		
		for(u=0; u<option_text.length; u++) {
			select_html = select_html + "<option value='" + option_values[u] + "'>" + option_text[u] + "</option>";
		}
		BetterInnerHTML(document.getElementById(priv_id),select_html);
		
	}
   }
	
 	xmlHttp.open("GET", "http://" + document.location.host + "/fetched.php?mini_id="+mini_id+"&command="+command+"&new_keys="+selected_text,true);


  xmlHttp.send(null);  
  document.getElementById('access_msg').style.display = "block";
}

function update_mini_category(id_remove, cat_add_names, cat_old_names) {
	
	
	
		var xmlHttp;
		var xmlText = "";
		
		
		try { // Firefox, Opera 8.0+, Safari  
			xmlHttp = new XMLHttpRequest();
		} 
		
		catch (e) { // Internet Explorer  
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e) {
				try {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch (e) {
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		xmlHttp.onreadystatechange = function(){
		
			if (xmlHttp.readyState == 4) {
				xmlText = xmlHttp.responseText;
			}
		}
		
		//alert("to-remove:"+id_remove + ", to-add: " + cat_add_names + ", to-update: " + cat_old_names);
		xmlHttp.open("GET", "http://" + document.location.host + "/fetched.php?mini_id_remove=" + id_remove + "&mini_id_add=" + cat_add_names + "&mini_id_update=" + cat_old_names, true);
		xmlHttp.send(null);
		setTimeout(function() {location.reload(true);},300);
	
}	

function update_mini_values() {
	
		//calculate the ids to be removed 
		var cat_remove = document.getElementById('collection_remove').value;
		
		cat_remove = cat_remove.substring(0, cat_remove.length - 1);
		
		var cat_remove_array = cat_remove.split(",");
		var id_remove = '';
		var mini_id_cat = '';
		for (p = 0; p < cat_remove_array.length; p++) {
			
			if (cat_remove_array[p] != '') {
				mini_id_cat = "mini_id_" + cat_remove_array[p];
				
				if (document.getElementById(mini_id_cat) != null) {
					
					id_remove = id_remove + document.getElementById(mini_id_cat).value + ",";
					
					
				}
			}
		}
		
		//calculate the categories to be added
		var cat_add = document.getElementsByClassName("new_cat");
		var cat_add_names = '';
		for (c = 0; c < cat_add.length; c++) {
			cat_add_names = cat_add_names + cat_add[c].value + ",";
		}
		
		//update the categories
		var cat_old = document.getElementsByClassName("old_cat");
		var cat_old_names = '';
		for (c = 0; c < cat_old.length; c++) {
			if (document.getElementById('mini_id_' + cat_old[c].id.substring(5, cat_old[c].id.length))) 
				cat_old_names = cat_old_names + document.getElementById('mini_id_' + cat_old[c].id.substring(5, cat_old[c].id.length)).value + ":" + cat_old[c].value + ",";
		}
		
		id_remove = id_remove.substring(0, id_remove.length - 1);
		cat_add_names = cat_add_names.substring(0, cat_add_names.length - 1);
		cat_old_names = cat_old_names.substring(0, cat_old_names.length - 1);
		
		update_mini_category(id_remove, cat_add_names, cat_old_names);

}

function remove_mini_category(m_category) {
	
	var totalCategories = document.getElementById('collection_categories').value;
	var totalCategoriesArray = totalCategories.split(",");
	var lastElement = '';
	var cur_lastElement = totalCategoriesArray[totalCategoriesArray.length-1];
	
	if (totalCategoriesArray.length > 1) {
		document.getElementById('c' + m_category).parentNode.removeChild(document.getElementById('c' + m_category));
		
		for (o = 0; o < totalCategoriesArray.length; o++) {
			
			if (m_category == totalCategoriesArray[o]) {
				document.getElementById('collection_remove').value = document.getElementById('collection_remove').value + totalCategoriesArray[o] + ",";
				totalCategoriesArray.splice(o, 1);
			}
			if (o == (totalCategoriesArray.length - 1)) {
				lastElement = totalCategoriesArray[o];
			}
		}
		if (!document.getElementById('plus_' + o)) {
			
			
			if (lastElement == '') {
				
				if (document.getElementById('c' + totalCategoriesArray[totalCategoriesArray.length-1])) {
					var li_innerHTML = document.getElementById('c' + totalCategoriesArray[totalCategoriesArray.length-1]).innerHTML;
					
					li_innerHTML = "<input type='text' id='mini_" + totalCategoriesArray[totalCategoriesArray.length-1] + "' style='width:150px;float:left;' value='" + document.getElementById('mini_' + totalCategoriesArray[totalCategoriesArray.length-1]).value + "' class='old_cat'/><img src='/images/icon_md_minus.gif' style='padding-left:4px;width:15px;' id='minus_" + totalCategoriesArray[totalCategoriesArray.length-1] + "' onclick=\"remove_mini_category('" + totalCategoriesArray[totalCategoriesArray.length-1] + "')\">" + "</img><img id=\"plus_" + totalCategoriesArray[totalCategoriesArray.length-1] + "\" onclick=\"add_mini_category('" + totalCategoriesArray[totalCategoriesArray.length-1] + "')\" style=\"padding-left: 4px; width: 15px;\" src=\"/images/icon_md_plus.gif\"></img>";
					
					document.getElementById('c' + totalCategoriesArray[totalCategoriesArray.length-1]).innerHTML = li_innerHTML;
					document.getElementById('plus_' + totalCategoriesArray[totalCategoriesArray.length-1]).onclick = function(){
						add_mini_category('' + totalCategoriesArray[totalCategoriesArray.length-1]);
					};
				}
			}
			
		}
		totalCategories = totalCategoriesArray.join(",");
		document.getElementById('collection_categories').value = totalCategories;
	}
	
	//document.getElementById('collection_remove').value = document.getElementById('collection_remove').value.substring(0,(document.getElementById('collection_remove').value.length-1));
	//alert(document.getElementById('collection_remove').value + ", " +document.getElementById('collection_remove').value.length);
}
function add_mini_category(afterElement){

	if (document.getElementById('mini_' + afterElement).value != '') {
		var totalCategories = document.getElementById('collection_categories').value;
		var totalCategoriesArray = totalCategories.split(",");
		var lastElement = '';
		
		document.getElementById('plus_' + afterElement).parentNode.removeChild(document.getElementById('plus_' + afterElement));
		var ul_innerHTML = document.getElementById('mcc').innerHTML;
		
		//create and add the new list element
		var new_li = document.createElement('li');
		new_li.setAttribute("id", "c" + (parseInt(afterElement) + 1));
		document.getElementById('mcc').appendChild(new_li);
		
		//create and add the new textbox to the list created above
		var new_text = document.createElement('input');
		new_text.setAttribute("type", "text");
		new_text.setAttribute("id", "mini_" + (parseInt(afterElement) + 1));
		new_text.setAttribute("style", "width:150px;float:left;");
		new_text.style.width = '150px';
		new_text.style.float = 'left';
		new_text.setAttribute("class", "new_cat");
		new_li.appendChild(new_text);
		
		//create and add the minus and plus buttons
		img_innerHTML = "<img src='/images/icon_md_minus.gif' style='padding-left:4px;width:15px;' id='minus_" + (parseInt(afterElement) + 1) + "' onclick=\"remove_mini_category('" + (parseInt(afterElement) + 1) + "')\"></img><img id=\"plus_" + (parseInt(afterElement) + 1) + "\" onclick=\"add_mini_category('" + (parseInt(afterElement) + 1) + "')\" style=\"padding-left: 4px; width: 15px;\" src=\"/images/icon_md_plus.gif\"></img>";
		var li_innerHTML = new_li.innerHTML + img_innerHTML;
		//BetterInnerHTML(new_li, li_innerHTML);
		new_li.innerHTML = li_innerHTML;
		document.getElementById('plus_' + (parseInt(afterElement) + 1)).onclick = function(){
			add_mini_category('' + (parseInt(afterElement) + 1));
		};
		document.getElementById('minus_' + (parseInt(afterElement) + 1)).onclick = function(){
			remove_mini_category('' + (parseInt(afterElement) + 1));
		};
		
		totalCategories = totalCategories + "," + (parseInt(afterElement) + 1);
		document.getElementById('collection_categories').value = totalCategories;
	}
}

function update_mini_search(update_msg){
	
	if(document.getElementById('message_head')) {
		document.getElementById('message_head').innerHTML = update_msg;
	}
	
	var xmlHttp;
		var xmlText = "";
		
		try { // Firefox, Opera 8.0+, Safari  
			xmlHttp = new XMLHttpRequest();
		} 
		
		catch (e) { // Internet Explorer  
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e) {
				try {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch (e) {
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		xmlHttp.onreadystatechange = function(){
		
		if (xmlHttp.readyState == 4) {
			xmlText = xmlHttp.responseText;
			var alert_start = xmlText.indexOf('confirm_msg_start-->') + 20;
			var alert_end = xmlText.indexOf('<!--confirm_msg_end');
			alert(xmlText.substring(alert_start,alert_end));
			if(document.getElementById('message_head')) {
				document.getElementById('message_head').innerHTML = xmlText.substring(alert_start,alert_end);
			}
		}
	}
		xmlHttp.open("GET", "/mini_collection/update_index.me", true);
		xmlHttp.send(null);
	
}
function fckedit(textAreaId, toolType) {
	oFCKeditor = new FCKeditor(textAreaId);
	oFCKeditor.BasePath = sBasePath;
	oFCKeditor.ToolbarSet	= toolType;
	oFCKeditor.Config['ToolbarStartExpanded'] = false ;
	var sSkin = 'silver';
	var sSkinPath = sBasePath + 'editor/skins/' + sSkin + '/' ;
	oFCKeditor.Config['SkinPath'] = sSkinPath ;
	oFCKeditor.Config['PreloadImages'] =
	sSkinPath + 'images/toolbar.start.gif' + ';' +
	sSkinPath + 'images/toolbar.end.gif' + ';' +
	sSkinPath + 'images/toolbar.buttonbg.gif' + ';' +
	sSkinPath + 'images/toolbar.buttonarrow.gif' ;
	//FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/silver/';
	oFCKeditor.ReplaceTextarea();
	
}

function editBasic(editorInstance)
{
  var oEditor = FCKeditorAPI.GetInstance(editorInstance) ;
  oEditor.ToolbarSet.Load( 'Basic' ) ;
}

function editDefault(editorInstance)
{
  var oEditor = FCKeditorAPI.GetInstance(editorInstance) ;
  oEditor.ToolbarSet.Load( 'Default' ) ;
}

function round(obj_id, obj_val) {

  ans = obj_val * 1000
  ans = Math.round(ans /10) + ""
  while (ans.length < 3) {ans = "0" + ans}
  len = ans.length
  ans = ans.substring(0,len-2) + "." + ans.substring(len-2,len)
  document.getElementById(obj_id).value = ans;

}

function ajaxformPOST(thisform,formhandler,currentValue)
{
    // Set up data variable
    var formdata = "";

    // Set up Ajax request variable
    try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}

    // Loop through form fields
    for (i=0; i < thisform.length; i++)
    {
	
         //Build Send String
         if(thisform.elements[i].type == "text"){ //Handle Textbox's
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         }else if(thisform.elements[i].type == "textarea"){ //Handle textareas
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         }else if(thisform.elements[i].type == "checkbox"){ //Handle checkbox's
                 formdata = formdata + thisform.elements[i].name + "=" + thisform.elements[i].checked + "&";
         }else if(thisform.elements[i].type == "radio"){ //Handle Radio buttons
                  if(thisform.elements[i].checked==true){
                     formdata = formdata + thisform.elements[i].name + "=" + thisform.elements[i].value + "&";
                  }
         }else{
                  //finally, this should theoretically this is a select box.
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         }
    }

    //Send Ajax Request
    xmlhttp.onreadystatechange = function(){
               //Check page is completed and there were no problems.
               if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
                      //What to do once the form is submitted - to inform the user.
		      //replaceLightBox(formhandler);
		      if(thisform.name == 'main_light') {
			animatedcollapse.hide('lightbox_start');
			setTimeout(function() {
				var new_lightbox = xmlhttp.responseText;
				var startLight = new_lightbox.indexOf('<!--Start light content-->');
				var endLight = new_lightbox.indexOf('<!--End light content-->');
				new_lightbox = new_lightbox.substring(startLight, endLight);
				//BetterInnerHTML(document.getElementById('lightbox_start'), new_lightbox);
				document.getElementById('lightbox_start').innerHTML = new_lightbox;
				ajaxformPOST(document.getElementById('side_lightbox'),formhandler,currentValue);
				}, 900);
			
			//document.getElementById('search-results').innerHTML = xmlhttp.responseText;
			setTimeout(function() {animatedcollapse.show('lightbox_start');},1000);
		      }
               }
    }
    //Make connection
    
    xmlhttp.open("POST", formhandler);
    //Set Headers
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    //Send data
    xmlhttp.send(formdata);
    //stops form from submitting normally
    return false;
}

function replaceLightBox(pageURL) {
	
	
	var xmlHttp;
	var xmlText="";
try
  {  // Firefox, Opera 8.0+, Safari  
  xmlHttp=new XMLHttpRequest();  }

catch (e)
  {  // Internet Explorer  
  try
    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      
	  		 return false;      }    }  }
  xmlHttp.onreadystatechange=function()
    { 
    if (xmlHttp.readyState == 4) {
	alert('asdfasd');
    }	
  xmlHttp.open("GET",pageURL,true);
  xmlHttp.send(null);  
    
    }
}

function change_list_value(listName,newVal) {
	var hidden_list = document.getElementsByName(listName);
	for(i=0; i<hidden_list.length; i++) {
		hidden_list[i].value = newVal;
	}
	
}
function img_toggle(anchor_id) {
    
    if(document.getElementById(anchor_id).getElementsByTagName("img")[0].src == "http://" + document.location.host + "/images/icon_md_minus.gif"){
	document.getElementById(anchor_id).getElementsByTagName("img")[0].src = "http://" + document.location.host + "/images/icon_md_plus.gif";
    }
    else {
	document.getElementById(anchor_id).getElementsByTagName("img")[0].src = "http://" + document.location.host + "/images/icon_md_minus.gif";
    }
}

function get_box(box_name) {
	var xmlHttp;
	var xmlText="";
	var img_id_small ='';
	var box_of_images;
	var startIndex = 0;
try
  {  // Firefox, Opera 8.0+, Safari  
  
  xmlHttp=new XMLHttpRequest();  }

catch (e)
  {  // Internet Explorer  
  try
    {    
	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  catch (e)
    {    try
      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      
	  		 return false;      }    }  }
  xmlHttp.onreadystatechange=function()
    { 
	
    if (xmlHttp.readyState == 4) {
		xmlText = xmlHttp.responseText;
		var startIndex = xmlText.indexOf('<!--start_thumbnails-->');
		var endIndex = xmlText.indexOf('<!--end_thumbnails-->');
		if(document.getElementById(box_name + "_thumbnails")) {
			BetterInnerHTML(document.getElementById(box_name + "_thumbnails"),xmlText.substring(startIndex, endIndex));
			//document.getElementById(box_name + "_thumbnails").innerHTML = xmlText.substring(startIndex, endIndex);
			if(box_name.indexOf('basket') > -1) {
				if(document.getElementById("list_basket_thumbnails")) {
					BetterInnerHTML(document.getElementById("list_basket_thumbnails"),"");
				}
				box_of_images = getElementsByClassName("panel_pics_box_basket");
				if(box_of_images.length < 1) {
					document.getElementById('dragBasketHelp').style.display = 'block';
					document.getElementById('basketPanel').style.height = '70px';
				}
				startIndex = 7;
				$('basket_images').observe('mousemove', function(event){
					basket_enter = 'true';
				});
			}
				
			
			if(box_name.indexOf('lightbox') > -1) {
				if(document.getElementById("list_light_thumbnails")) {
					BetterInnerHTML(document.getElementById("list_light_thumbnails"),"");
				}
				box_of_images = getElementsByClassName("panel_pics_box_light");
				if(box_of_images.length < 1) {
					document.getElementById('dragLightHelp').style.display = 'block';
					document.getElementById('lightboxPanel').style.height = '70px';
				}
				startIndex = 6;
			}
			
			for(i=0; i < box_of_images.length; i++) {
				
				$(box_of_images[i].id).observe('mouseover', function(event){
					dragImgId = this.id.substring(startIndex,this.id.length);
				});
				
				$(box_of_images[i].id).observe('mousedown', function(event){
					mouse_down();
				});
				
				$(box_of_images[i].id).observe('mouseup', function(event){
					mouse_up(box_name + dragImgId,dragImgId);
				});
				
				makeImageDraggable(box_of_images[i].id,box_name + "_thumbnails");
				
			}
		}
	}
    }
	
 xmlHttp.open("GET", "http://" + document.location.host + "/" + box_name + "/list.me?get=true",true);


  xmlHttp.send(null); 
}

function swapSibling(node1, node2) {
        //node1.parentNode.replaceChild(node1, node2);
      node1.parentNode.insertBefore(node2, node1); 
}
   
      function getElementsByStyleClass(classname, node) {
   
      if(!node) node = document.getElementsByTagName("body")[0];
   
      var a = [];
   
      var re = new RegExp('\\b' + classname + '\\b');
   
      var els = node.getElementsByTagName("*");
   
      for(var i=0,j=els.length; i<j; i++)
   
      if(re.test(els[i].className))a.push(els[i]);
   
      return a;
   
      }


function show_hide_link(hide_link, show_link, chgBox, displayValue) {
	
	//$(show_link).style.display='none';
	if(show_link != '') {$(show_link).show();}
	if(hide_link != '') {$(hide_link).hide();}
	if(chgBox == 'side_panel') {
		if(displayValue == '0'){
			Effect.BlindRight('side-panel');
			hide_contents('hideLinkSearchBox');
			hide_contents('hideLinkLightBox');
			hide_contents('hideLinkBasketBox');
		}
		if(displayValue == '1'){
			Effect.BlindLeft('side-panel');
			if($('search_images').style.display == 'none') {
				show_contents('hideLinkSearchBox');
			}
			if($('light_images').style.display == 'none') {
				show_contents('hideLinkLightBox');
			}
			if($('basket_images').style.display == 'none') {
				show_contents('hideLinkBasketBox');
			}
		}
	}
	
	updateBoxState("http://" + document.location.host + "/fetched.php?chgBox="+ chgBox + "-" + $('lui').value + "-" +displayValue);
	
}		
      
      function show_contents(element_id) {
	
	if(element_id == 'edit_terms') {
		hide_contents('edit_privacy');
	}
	if(element_id == 'edit_privacy') {
		hide_contents('edit_terms');
	}
	if(element_id == 'default') {
		hide_contents('iframe');
	}
	if(element_id == 'iframe') {
		hide_contents('default');
	}
	
	
	Effect.BlindDown(element_id, { duration: 0.5 });
	if(element_id == 'light_images') {		
		get_box('lightbox');
		
		$("lightboxPanelTrack").style.height = '122px';
		$("lightboxPanelHandle").style.height = '1em';
		setTimeout(function() {
			if(lights) {
				increasePanelHeight(lights, 'lightboxPanel');
			}
		}, 50);
	}
	if(element_id == 'basket_images') {		
		
		get_box('basket');
		$("basketPanelTrack").style.height = '122px';
		$("basketPanelHandle").style.height = '1em';
		
		setTimeout(function() {
			if(baskets) {
				increasePanelHeight(baskets, 'basketPanel');
			}
		}, 50);
	}
	
      }
       
      function hide_contents(element_id) {
	Effect.BlindUp(element_id, { duration: 0.5 });
      }
      /*
      function load_detail_video(playerName, videoURL, splashImg) {
	flashembed(playerName, "http://dev.iv.lookat.me/video/example/flowplayer-3.1.3.swf", {
		plugins:  {
	
		// controlbar settings
			controls:  {
				backgroundGradient: 'none',
				backgroundColor: 'transparent',
				all:false,
				scrubber:true,
				mute: true,
				height:40
			} 
		},
	    // "config" parameter is a complex JSON object, not just a simple value 
		config: { 
			clip:  { 
			    autoPlay: false, 
			    autoBuffering: true, 
			    url: videoURL 
			}
			
		},
		canvas: { 
			backgroundImage: splashImg 
		}
		
	});
      }
      */
      function load_detail_video(playerName) {
	
	$f(playerName, "http://dev.iv.lookat.me/video/example/flowplayer-3.1.3.swf", {

		// don't start automcatically
		clip: {
			autoPlay: false,
			autoBuffering: true
		},
		// disable default controls
		plugins: {
			lighttpd: { 
				url: 'http://dev.iv.lookat.me/video/example/flowplayer.pseudostreaming-3.1.3.swf' 
			}
		}

	// install HTML controls inside element whose id is "hulu"
	});

      }
      
      function seek_video() {
	$f().seek(5);
      }
      
      function load_video(itemId) {
	//$f().unload();
	dragImgId = itemId;
	if(dragStatus != 'drag') {
		grow_image(document.getElementById('play_' + dragImgId));
		$f('play_'+itemId).load();
		$f('play_'+itemId).play();	
	}
      }
      //function load_search_video(playerName, videoURL,scWidth, scHeight) {
	function load_search_video(playerName) {
	
	$f(playerName, {src: "http://dev.iv.lookat.me/video/example/flowplayer-3.1.3.swf",wmode:'opaque',allowfullscreen:'false'},
		{
		   onMouseOut: function() {
			clearTimeout(timer_delay);
			$f().unload();
			dragStatus = 'drop';
			norm_image(document.getElementById('play_' + dragImgId), '256');
		   },		   
		   onPause: function() {
			if(dragStatus != 'drag') {
				window.location = "http://" + document.location.host + "/item/details.me?item=" + dragImgId;
			}
			else{
				dragStatus = 'drop';
				$f().unload();
			}
		   },
		   plugins: {
			controls: null,
			lighttpd: { 
				url: 'http://dev.iv.lookat.me/video/example/flowplayer.pseudostreaming-3.1.3.swf' 
			}
		   },
		   //onLoad: function() {
			//$f().setVolume(50).seek(40).onFinish( function(){this.unload();});
		   //},
		   clip: {
			autoPlay: false, 
			autoBuffering: true,
			linkURL: "http://" + document.location.host + "/item/details.me?item=" + dragImgId
		   },
		   onBeforeClick: function() {
			$f().unload();
		   }
		});
	/*
	$f(playerName,
	   {
		src: "http://dev.iv.lookat.me/video/example/flowplayer-3.1.3.swf",
		bgcolor: '#ffffff'
	   },
	
	{ 
		// use first frame from the video as "splash image" 
		clip: { 
			url: videoURL, 
			autoPlay: false, 
			autoBuffering: true
		}, 
 
		// custom labels on the play button 
		//play: { 
		  //  label: 'Play', 
		    //replayLabel: 'Replay' 
		//}, 
 
		// screen dimensions are 1 pixel less than the rounded canvas 
		
		//screen: { 
		//	width:scWidth, 
		//	height:scHeight
		//}, 
 
		// rounded canvas is done with borderRadius 
		
		canvas: { 
			backgroundColor: '#ffffff', 
			borderRadius:8 
		}, 
 
		// don't use default controls 
		plugins: {
			
			controls: null,
			lighttpd: { 
				url: 'http://dev.iv.lookat.me/video/example/flowplayer.pseudostreaming-3.1.3.swf' 
			}
		}
	});
	*/
      }
    // use HTML controls instead. place it inside element named "htmlControls" 
    
    function addTabs(tabName) {
  	var allTabs = document.getElementsByTagName('li');
	/*
	for(u=0; u<10; u++) {
			
		if(document.getElementById('leftCornertab_'+u)) {
			document.getElementById('leftCornertab_'+u).style.backgroundImage = 'url(/images/tab_left.jpg)';
		}
		
		if (document.getElementById('rightCornertab_' + u)) {
			document.getElementById('rightCornertab_'+u).style.backgroundImage = 'url(/images/tab_right1.jpg)';
			document.getElementById('rightCornertab_'+u).style.width = '5px';
		}
	}
	
	if(document.getElementById('leftCornertab_n')) {
			document.getElementById('leftCornertab_n').style.backgroundImage = 'url(/images/tab_left.jpg)';
	}
	
	if (document.getElementById('rightCornertab_n')) {
			document.getElementById('rightCornertab_n').style.backgroundImage = 'url(/images/tab_right1.jpg)';
			document.getElementById('rightCornertab_n').style.width = '5px';
	}
	
	var l_curImg = document.getElementById('leftCorner'+tabName);
	var r_curImg = document.getElementById('rightCorner'+tabName);
	
	l_curImg.style.backgroundImage = 'url(/images/tab_left_active.jpg)';
	r_curImg.style.backgroundImage = 'url(/images/tab_right_active1.jpg)';
	r_curImg.style.width = '7px';
	*/
	
  }
  
      document.observe('dom:loaded', function() {
	get_box('lightbox');
	get_box('basket');
	
	if($('org_welcome')) {
		fckedit('org_welcome','Basic');
	}
	if($('terms_conditions')) {
		fckedit('terms_conditions', 'Basic');
	}
	if($('privacy_stmt')) {
		fckedit('privacy_stmt', 'Basic');
		$('edit_privacy').style.display = 'none';
	}
	if($('custom_msg')) {
		fckedit('custom_msg', 'Basic');
	}
	
	/*start video scripts*/
	
	
	
	
	/*end video scripts*/
	});