/*
# # # # # # #
# CHANGELOG
#
# V0.01 SDW      2008-11-26                         Original Code
# V0.02 SDW      2008-11-26                         Implement Themes; 
# V0.03 SDW      2008-11-27                         Fixed bug in resizePage(); when using a page border and a fixed height site
#													Fixed bug using float on fixed height sites	
# V0.04 SDW      2008-12-02                         Add draw flash function; Add scrollDiv function
# V0.05 SDW      2008-12-09                         Added loadArticle and updateSearchArticles functions
#
*/
var is_IE = 0;
var is_firefox = 0;
var loaded = 0;
nav  = navigator.userAgent;

var global_url = "http://www.thepeoplepod.co.uk/";
var s_global_url = 'http://www.thepeoplepod.co.uk/';

re = /MSIE/gi;
if(nav.match(re)){
	is_IE = 1;
}else{
	re = /Firefox/gi;
	if(nav.match(re)){
		is_firefox = 1;
	}
	
}

var load_side_only = 0;
var logon_form = null;
var page_y = 100;
var option_y = 100;
var menu_y = 100;
var speed = 10;
var inc = 10;
var inc_x = 40;
var inc_y = 10;
var flash_frame_h = 0;
var show_laymans = false;
var site_fixed_height = 0;
var site_float = 0;
var site_width = 1000;
var flash_disabled = 0;
var last_menu_obj = null;
var menu_in_obj = null;
var menu_out_obj = null;
var menus_loaded = Array();
var page_type = "";
var page_id = "";
var products = Array();
var qa_arr = Array();
var menu_width= 200;
var left_menu_width = 200;
var right_menu_width = 200;
var header_img_repeat = 0;
var main_overflow_x = 0;
var main_overflow_y = 1;
var left_overflow_x = 0;
var left_overflow_y = 1;
var right_overflow_x = 0;
var right_overflow_y = 1;
var site_float_y = 0;
var flash_color_1 = "#ffffff";
var flash_color_2 = "#ffffff";
var flash_highlight_color = "#666666";
var flash_main_color_1 = "#ffffff";
var flash_main_color_2 = "#ffffff";
var flash_bg_color = "#ffffff";
var flash_back_width = 450;
var default_postage = 4.95;
var non_default_postage = 10.95;
var default_postage_text = "Postage & Insurance";
var non_default_postage_text = "International Postage";	
var top_bar_font_color = '#666666';
var dropdown_menu_left_offset = 0;
var mem_allow_logon = 1;
var gallery_show_img_name = 0;
var gallery_img_name_color ='#ff0000';
var header_height = 150;
var header_type = 1;
var can_get_basket = 0;
var footer_bar_height = 80;
var print_header = "<table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" align=\"center\" border=\"0\" style=\"border-bottom:1px solid #000000;\"> <tbody> <tr> <td><img height=\"200\" alt=\"\" width=\"351\" src=\"/uploads/image/all_3.png\" /></td> <td width=\"200\"><img height=\"150\" alt=\"The People Pod | Call 0871 789 4111\" width=\"200\" src=\"/uploads/image/logo_tel.png\" /></td> </tr> </tbody></table>";
var gallery_background_random = 0;
var page_back_img_below_header = 0;
var basket_empty_txt ="Your basket is currently empty";
var main_menu_btn_spacing = 1;
var dropdown_min_height = 30;
var form_error_color = "#ff0000";
var ARTICLES_TITLE = "Industry News";
var USE_HTACCESS_REWRITE = 1;

function flashAction(action){
	closeAllMenus();
	switch(action){
	}
}

function checkEnterPressed(e){
	
	if( !e ) { 
		if( window.event ) { 
			e = window.event;
		}else{
			return false;
		}
	}
	
	if( typeof( e.which ) == 'number' ) { 
		e = e.which; 
		if (e=='13')return true;	
	} else if( typeof( e.keyCode ) == 'number' ) { 
		//IE, NS 6+, Mozilla 0.9+ 
		e = e.keyCode; 
		if (e=='13')return true;	 
	} else if( typeof( e.charCode ) == 'number' ) { 
		//also NS 6+, Mozilla 0.9+ 
		e = e.charCode; 
		if (e=='13')return true;	
	} else { 
		return false;; 
	} 

}

function bookmark(){
	
	title = document.title;
	url = document.location;
	
	if (window.external){ 
		try{
			window.external.AddFavorite(url,title);
		}catch(e){
		}
	}
	if (window.sidebar){
		try{
			window.sidebar.addPanel(title,url,'');
		}catch(e){
		}
	} 

}


function updateDivHTML(id,txt,is_encoded){
	
	if(document.getElementById(id)){
		document.getElementById(id).innerHTML = (is_encoded == 1) ? decode64(txt) : txt;
	}
	
}

function checkemail(email){
		
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (filter.test(email))
			return true;
		else{
			return false;
		}
		
}

function printPrep(html){
               re = /(<[^>]*)\bname[\s]*=[\s]*(['"]?)[^\2\s>]+/gi;
                if(html.match(re)){
                                html = html.replace(re,"$1");
                }
                re = /(<[^>]*)\bid[\s]*=[\s]*(['"]?)[^\2\s>]+/gi;
                if(html.match(re)){
                                html = html.replace(re,"$1");
                }
                re = /<script>.*?<\/script>/gi;
                if(html.match(re)){
                                html = html.replace(re,"");
                }
				
				re = /overflow: hidden;/gi;
                if(html.match(re)){
                                html = html.replace(re,"");
                }
                return html;
}

function printDiv(div){
	if(div && document.getElementById('print_div')){
		document.getElementById('print_div').innerHTML = print_header;
		document.getElementById('print_div').innerHTML += printPrep(div.innerHTML);
		window.print();
	}
}

function updatePrintDiv(){
	
	if((document.getElementById('main_content')) && (document.getElementById('print_div'))){
		document.getElementById('print_div').innerHTML = print_header;
		document.getElementById('print_div').innerHTML += printPrep(document.getElementById('main_content').innerHTML);
	}
	
}

function createControls(){
	
	document.write("<iframe name=\"main_frame\" id=\"main_frame\"></iframe>\r\n");
	document.write("<iframe name=\"process_frame\" id=\"process_frame\"></iframe>\r\n");
	document.write("<iframe name=\"logon_frame\" id=\"logon_frame\"></iframe>\r\n");
		
}

function formatQAItem(str){
	
	re=/<AND>/gi
	str = str.replace(re,"&");
	
	re=/<DBLQUOTE>/gi
	str = str.replace(re,'"');
	
	re=/<SGLQUOTE>/gi
	str = str.replace(re,"'");
	
	return str;
	
}

function loadQA(id){

	try{
		
		if(qa_arr[id]){
				
			arr = qa_arr[id];
			last_cat1 = "";
			last_cat2 = "";
			current_list = null;
			for(i=0;i<arr.length;i++){
			
				cat1 = arr[i]["category1"];
				cat2 = arr[i]["category2"];
				if(last_cat1 != cat1){
					last_cat1 = cat1;
					last_cat2 = cat2;
					newItem = document.createElement('option');
					newItem.value = cat2;
					
					newItem.text = (cat2 != "") ? "-- "+formatQAItem(cat2) : "-- "+formatQAItem(cat1);
					
					re=/\W/gi;
					cat_str = cat1.replace(re,"").toLowerCase();
					list = document.getElementById(cat_str+"_cat2_"+id);
					if(list){
						current_list = list;
						try{
							list.add(newItem,null);
						}catch(ie_err){
							list.add(newItem);
						}
					}else{
						//alert("list not exist");
						current_list = null;
					}
				}
				
				if((last_cat2 != cat2)&&(current_list)){
					last_cat2 = cat2;
					newItem = document.createElement('option');
					newItem.value = cat2;
					newItem.text = "-- "+cat2;
					try{
						list.add(newItem,null);
					}catch(ie_err){
						list.add(newItem);
					}
				}
				
			
			}
			
			
			
		}
	
	}catch(qa_err){
		//alert(qa_err);
	}
	
}

function clearList(list){
	
	if((list)&&(list.length > 0)){
		
		for(l=(list.length-1);l>=0;l--){
			list.remove(l);
		}
		list.length = 0;
		
	}
	
}

function showQABlank(cat_str,cat,id){
	
	//alert("BLANK\r\n"+cat_str+"\r\n"+cat+"\r\n"+id);
	blank_div = document.getElementById(cat_str+"_blank_"+id);
	if((blank_div)&&(qa_arr[id])){
		//run though arr and hide all other in the category
		
		arr = qa_arr[id];
		for(a=0;a<arr.length;a++){
			
			if(arr[a]["category1"] == cat){
				
				div = document.getElementById("txt_div_"+a+"_"+id);
				if(div){
					div.style.display = "none";
				}
			}
			
		}
		
		blank_div.style.display = "block";
	}
	
	
}

function loadQuestions(list,index,cat,id){
	
	//alert(list.id+"\r\n"+index+"\r\n"+cat+"\r\n"+id);
	if(index > -1){
		val = list[index].value;
		//alert(val);
		re=/\W/gi;
		cat_str = cat.replace(re,"").toLowerCase();
		list = document.getElementById(cat_str+"_qs_"+id);
		
		if(list){
			 //clear list first
			 clearList(list);
			 showQABlank(cat_str,cat,id);
			 
			 if(val == "resetlist"){
				 //alert("list reset");
				if(document.getElementById('qs_div_'+id)){
					document.getElementById('qs_div_'+id).innerHTML = "&nbsp;";
				}
				
			 }else{
			 	//alert("load questions");
				if(document.getElementById('qs_div_'+id)){
					document.getElementById('qs_div_'+id).innerHTML = "Now choose your question";
				}
				newItem = document.createElement('option');
				newItem.value = "reset";
				newItem.text = "Select your question here";
				newItem.style.color = "#666666";
				try{
					list.add(newItem,null);
				}catch(ie_err){
					list.add(newItem);
				}
				
				arr = qa_arr[id];
				for(a=0;a<arr.length;a++){
					if((arr[a]["category1"] == cat)&&(arr[a]["category2"] == val)){
						newItem = document.createElement('option');
						newItem.value = a;
						newItem.text = "-- "+formatQAItem(arr[a]["question"]);
						try{
							list.add(newItem,null);
						}catch(ie_err){
							list.add(newItem);
						}
					}
					
				}
			 
			 }
			 
		}else{
			//alert("list not found");
		}
		
	}
	
}

function loadAnswer(list,index,cat,id){
	//alert("LOAD ANSWER\r\n"+list.id+"\r\n"+index+"\r\n"+id);
	if(index > -1){
		val = list[index].value;
		Math.abs(val);
		//alert(val);
		re=/\W/gi;
		cat_str = cat.replace(re,"").toLowerCase();
		
		if(qa_arr[id]){
			//run though arr and hide all other in the category
			found = 0;
			arr = qa_arr[id];
			for(a=0;a<arr.length;a++){
				
				if(arr[a]["category1"] == cat){
					div = document.getElementById("txt_div_"+a+"_"+id);
					if(div){
						div.style.display = (a == val) ? "block":"none";
						if(a==val){
							found = 1;
						}
					}
				}
				
			}
			blank_div = document.getElementById(cat_str+"_blank_"+id);
			if(blank_div){
				blank_div.style.display = (found == 1)? "none" : "block";
			}
		}
		
	}
	
}

function stopScrollDiv(id){
	//alert("STOP "+id);
	if(window[id]){
		clearTimeout(window[id]);
	}
	
}

function startScrollDiv(id){
	//alert("Start "+id);
	if(window[id]){
		clearTimeout(window[id]);
	}
	window[id] = setInterval("scrollDiv('"+id+"')",60);
}

function scrollDiv(id){
			
	if((document.getElementById("d_"+id))&&(document.getElementById("s_"+id))){
			
			try{
			
				frame_h = parseInt(parent.document.getElementById("d_"+id).style.height);
				div_h = document.getElementById("s_"+id).clientHeight;
				
				t = parseInt(document.getElementById("s_"+id).style.top);

				if(t > (0-div_h)){
					document.getElementById("s_"+id).style.top = (t-1) +"px";
				}else{
					document.getElementById("s_"+id).style.top = frame_h +"px";
				}
				
				
			}catch(e){
			
			}
		
	}
	
}


function toggleShowSearch(div,search_box_tag){
	
	if(search_box_tag){
		search_box_tag = "_"+search_box_tag;
	}else{
		search_box_tag = "";
	}
	
	img = div+"_img";
	
	re1=/_down/gi;
	re2=/_up/gi;
	
	if(document.getElementById(img)){
		
		shown = (document.getElementById(img).src.match(re1)) ? 1:0
		
	
		document.getElementById(img).src = (shown == 1)? document.getElementById(img).src.replace(re1,"_up") : document.getElementById(img).src.replace(re2,"_down");
		
		
		if(document.getElementById(div)){
			
			document.getElementById(div).style.display = (shown==1) ? "block":"none";
			resizePage();
			
		}
		
		show_search_box = (shown==1) ? 1:0;
		
		expireDate = new Date;
		expireDate.setMonth(expireDate.getMonth()+6);
	
		parent.document.cookie = "show_search_box"+search_box_tag+"="+show_search_box+";expires="+expireDate.toGMTString()+";path=/";
	
	}
	
	
}



function toggleMainMenu(bool){
	if(document.getElementById('header_menu')){
		document.getElementById('header_menu').style.display=(bool)? "block":"none";
	}
}


function toggleHeader(bool){
	
	check_h = (bool)? "block":"none";
	if(document.getElementById('header').style.display != check_h){
		document.getElementById('header').style.height =(bool)? header_height+"px":"0px";
		document.getElementById('header').style.display =(bool)? "block":"none";
	}
	
	if((document.getElementById('custom_header'))&&(document.getElementById('custom_header').style.display != check_h)){
		document.getElementById('custom_header').style.display =(bool)? "block":"none";
	}
	

}

function toggleFooter(bool){
	
	check_h = (bool)? "block":"none";
	if((document.getElementById('footer_menu'))&&(document.getElementById('footer_menu').style.display != check_h)){
		document.getElementById('footer_menu').style.display =(bool)? "block":"none";
	}
	
}


function updateHeader(html){
	if(document.getElementById('custom_header')){
		if(document.getElementById('custom_header').innerHTML != decode64(html)){
			document.getElementById('custom_header').innerHTML=decode64(html);
		}
	}
}

function removeLastSearchOption(){
	
	
		search_options = "";
	
		theCookie=""+parent.document.cookie;
		cookieName = "search_options";
		
		ind=theCookie.indexOf(cookieName);
			
		if (ind==-1 || cookieName=="") {
				basket = "";
		}else{
				ind1=theCookie.indexOf(';',ind);
				if (ind1==-1) {
					ind1=theCookie.length; 
				}
				val =  unescape(theCookie.substring(ind+cookieName.length+1,ind1));
				search_options = val;
				
		}
		
		//alert(search_options);
		if(search_options != ""){
			search_opt_arr = search_options.split("|");
			
			new_search_options = "";
			for(i=0;i<search_opt_arr.length-1;i++){
					new_search_options += (new_search_options != "") ? "|" : "";
					new_search_options += search_opt_arr[i];
			}
			
			//alert(new_search_options);
			expireDate = new Date;
			expireDate.setMonth(expireDate.getMonth()+2);
			document.cookie = "search_options="+new_search_options+";expires="+expireDate.toGMTString()+";path=/";
			
			if(current_page != ""){
				p_url = global_url+current_page.substr(1);
				//check query
				//alert(p_url);
				
				q_arr = p_url.split("?");
				q_arr2 = q_arr[1].split("&");
				
				new_q_str = "";
				for(i=0;i<q_arr2.length;i++){
					
					if((q_arr2[i].split("=")[0] != "rs") && (q_arr2[i].split("=")[0] != "cp")){
						new_q_str += (new_q_str == "") ? q_arr2[i] : "&"+q_arr2[i];
					}
				}	
				
				p_url = q_arr[0]+"?"+new_q_str;
				//alert(p_url);
				loadPage(p_url);
			}
			
		}
	
	
}


function getCalenderPosition(coord,myevent){
	
	w = document.documentElement.clientWidth;
	h = document.documentElement.clientHeight;
	
	val = getCurrentMousePosition(coord,myevent);
	
	if(coord == "x"){
		w += document.documentElement.scrollLeft;
		cal_center_w =  Math.ceil( parseInt(document.getElementById('calender').clientWidth)/2);
		if((val + cal_center_w) > w){
			x = w - (cal_center_w * 2)
		}else{
			x = val - cal_center_w
		}
		return x;
	}
	
	if(coord == "y"){
		h += document.documentElement.scrollTop;
		cal_center_h =  Math.ceil( parseInt(document.getElementById('calender').clientHeight)/2);
		if((val + cal_center_h) > h){
			y = h - (cal_center_h * 2)
		}else{
			y = val - cal_center_h
		}
		return y;
	}
	
	return 0;
	 
}

function getCurrentMousePosition(coord,myevent){
	
	try{
		start_move = 0;
		if(mouse_move_started == 0){
			start_move = 1;
			startMouseMove();
		}
		getMouseXY(myevent);
		if(start_move == 1){
			mouse_move_started = 0;
			document.onmousemove = null;
		}
		
		if(coord == "x"){
			return tempX;
		}
		
		if(coord == "y"){
			return tempY;
		}
		
	}catch(er){
	}
	
	return 0;
}

function clearSearchOptions(reload_p){	
		
		expireDate = new Date;
		expireDate.setMonth(expireDate.getMonth()-2);
		document.cookie = "search_options=;expires="+expireDate.toGMTString()+";path=/";
		if(USE_HTACCESS_REWRITE == 0){
			document.cookie = "search_article_options=;expires="+expireDate.toGMTString()+";path=/";
			document.cookie = "show_search_box_article=;expires="+expireDate.toGMTString()+";path=/";
		}
		document.cookie = "show_search_box=;expires="+expireDate.toGMTString()+";path=/";

		if(reload_p){
			
			if(current_page != ""){
				p_url = global_url+current_page.substr(1)+"&clear";
				//check query
				//alert(p_url);
				
				q_arr = p_url.split("?");
				q_arr2 = q_arr[1].split("&");
				
				new_q_str = "";
				for(i=0;i<q_arr2.length;i++){
					
					if((q_arr2[i].split("=")[0] != "rs") && (q_arr2[i].split("=")[0] != "cp")&& (q_arr2[i].split("=")[0] != "show_all")){
						new_q_str += (new_q_str == "") ? q_arr2[i] : "&"+q_arr2[i];
					}
				}	
				
				p_url = q_arr[0]+"?"+new_q_str;
				//alert(p_url);
				loadPage(p_url);
			}

			
		}
	
}

function updateSearchArticles(keyword,category,date_from,date_to){
	
	str = encode64(keyword+"") + "|" + encode64(category+"") + "|" + encode64(date_from+"") + "|" + encode64(date_to+"");
	expireDate = new Date;
	expireDate.setMonth(expireDate.getMonth()+2);
	document.cookie = "search_article_options="+str+";expires="+expireDate.toGMTString()+";path=/";
	
	if(current_page != ""){
		p_url = global_url+current_page.substr(1)+"&1";
		//check query
		q_arr = p_url.split("?");
		q_arr2 = q_arr[1].split("&");
		
		var load_cat_tag = "";
		
		new_q_str = "";
		for(i=0;i<q_arr2.length;i++){
			if(q_arr2[i].split("=")[0] == "load_article"){
				load_cat_tag = q_arr2[i].split("=")[1];
			}
			
			if((q_arr2[i].split("=")[0] != "rs") && (q_arr2[i].split("=")[0] != "cp")){
				new_q_str += (new_q_str == "") ? q_arr2[i] : "&"+q_arr2[i];
			}
		}	
		if(USE_HTACCESS_REWRITE == 1){
			var url = global_url + (urlencode(ARTICLES_TITLE))+"/";
			if(load_cat_tag != ""){
				load_cat_tag = decode64(load_cat_tag);
				var dir = load_cat_tag.split(",")[2];
				if(dir != ""){
					var re=/<AND>/gi;
					dir = dir.replace(re,"&");
					url += urlencode(dir)+"/";
				}
			}
			window.location = url.toLowerCase();
		}else{
			p_url = q_arr[0]+"?"+new_q_str;
			loadPage(p_url);
		}
	}
	
}

function updateSearchOption(opt,type){
	
	if(opt != ""){
		
		//alert(opt);
		
		search_options = "";
	
		theCookie=""+parent.document.cookie;
		cookieName = "search_options";
		
		ind=theCookie.indexOf(cookieName);
			
		if (ind==-1 || cookieName=="") {
				basket = "";
		}else{
				ind1=theCookie.indexOf(';',ind);
				if (ind1==-1) {
					ind1=theCookie.length; 
				}
				val =  unescape(theCookie.substring(ind+cookieName.length+1,ind1));
				search_options = val;
				
		}
		
		//alert(search_options);
		if(search_options != ""){
			search_opt_arr = search_options.split("|");
			//search_opt_arr.sort();
		}else{
			search_opt_arr = Array();
		}
		
		if(type == "add"){
			
			found = 0;
			for(i=0;i<search_opt_arr.length;i++){
				if(search_opt_arr[i] == opt){
					found = 1;
					break;
				}
			}
			
			if(found == 0){
				search_opt_arr.push(opt);
			}
			
		}else if(type == "remove"){
			
			found = 0;
			for(i=0;i<search_opt_arr.length;i++){
				if(search_opt_arr[i] == opt){
					search_opt_arr.splice(i,1);
					break;
				}
			}
			
			
		}
		
		new_search_options = "";
		for(i=0;i<search_opt_arr.length;i++){
				new_search_options += (new_search_options != "") ? "|" : "";
				new_search_options += search_opt_arr[i];
		}
	
		
		//alert(new_search_options);
		
		expireDate = new Date;
		expireDate.setMonth(expireDate.getMonth()+2);
		document.cookie = "search_options="+new_search_options+";expires="+expireDate.toGMTString()+";path=/";
		
		
		if(search_options != new_search_options){
			//alert(current_page);
			
			if(new_search_options == ""){
				loc = window.location.href;
				window.location.href = loc;
				
			}else if(current_page != ""){
				p_url = global_url+current_page.substr(1)+"&1";
				//check query
				//alert(p_url);
				
				q_arr = p_url.split("?");
				q_arr2 = q_arr[1].split("&");
				
				new_q_str = "";
				for(i=0;i<q_arr2.length;i++){
					
					if((q_arr2[i].split("=")[0] != "rs") && (q_arr2[i].split("=")[0] != "cp")){
						new_q_str += (new_q_str == "") ? q_arr2[i] : "&"+q_arr2[i];
					}
				}	
				
				p_url = q_arr[0]+"?"+new_q_str;
				//alert(p_url);
				loadPage(p_url);
			}
		}
	
	}
	
}

function showLoading(){
	
		document.getElementById('main_content').innerHTML = "<div style=\"padding:20px;\">loading please wait...</div>";
		//document.getElementById('left_content').innerHTML = "";
		//document.getElementById('right_content').style.display="none";//innerHTML = "";
		
}


function updateMainContent(){
	frame = window.frames['main_frame'];
	document.getElementById('main_frame').style.display = "block";
	if(frame.document.getElementById('page_details')){
	
		document.getElementById('main_content').innerHTML = frame.document.getElementById('page_details').innerHTML;
		updatePrintDiv();
		//alert(document.getElementById('main_content').innerHTML);
		//page_y = parseInt(frame.document.getElementById('page_details').clientHeight) +20;
		
		try{
		
				if(frame.document.getElementById('left_menu_details')){
					
					if(frame.document.getElementById('left_menu_details').innerHTML != "LEAVE"){
						document.getElementById('left_content').innerHTML = frame.document.getElementById('left_menu_details').innerHTML;
						//menu_y = parseInt(frame.document.getElementById('left_menu_details').clientHeight) +20;
						
					}
					
				}else{
					
					if(document.getElementById('left_content')){
						document.getElementById('left_content').innerHTML = "";
					}
					menu_y = 100;
					
				}
				
				
				if(frame.document.getElementById('right_menu_details')){
					
					document.getElementById('right_content').style.display = "block";
					if(frame.document.getElementById('right_menu_details').innerHTML != "LEAVE"){
						document.getElementById('right_content').innerHTML = frame.document.getElementById('right_menu_details').innerHTML;
						//option_y = parseInt(frame.document.getElementById('right_menu_details').clientHeight) +20;
						
					}
					
				}else{
					if(document.getElementById('right_content')){
						document.getElementById('right_content').innerHTML = "";
					}
					option_y = 100;
					
				}
				try{
					closeAllMenus();
				}catch(e){
				}
		
		}catch(e1){
		}
		
		try{
			frame.onPageComplete();
		}catch(e){
			//alert(e);
		}
		
	}
	
	
	window.frames['main_frame'].src = "";
	resizePage();
	document.getElementById('main_frame').style.display = "none";
}


function loadFlashPage(type,p){
	
	if(type != ""){
		loadPage(global_url+"scripts/pages.php?page_type="+type+"&p="+p);
	}else{
		loadPageNum(p);
	}
	
}

var auto_load_cat = "";

function rtnHome(){
	
	var str = decode64("aHR0cDovLw==");
	var re = new RegExp("https://");
	window.location.href =  global_url.replace(re,str);
}


function loadMenu(type,id,page_type){
	
	frame = (type == 1) ? "side_menu_frame":"features_frame";
	
	str = type+"|"+id+"|"+page_type;
	str = encode64(str);
	document.getElementById(frame).src = global_url+"scripts/options.php?"+str;
	
}

var gallery_style = 0;
var gallery_downloads = 0;

var flash_load_str = "";
var load_flash_on_complete = 0;
var side_menu_moving = 0;
var right_menu_moving = 0;
function loadFlash(str){
	if(!str){
		str = "";
	}
	if(str != ""){
			temp = str.split(":");
			flash = temp[0].toLowerCase();
			
			re1 = /\s{1,}/gi;
			flash = flash.replace(re1,"_");
			size = temp[1];
			if(!temp[2]){
				xtra = "";
			}else{
				xtra = temp[2];
			}
			
			var w = Math.abs(temp[4]);
			
			if(side_menu_moving == 0){
				
				if((flash_in==0)||(flash_frame_h != size)){
						
						load_flash_on_complete = 1;
						flash_load_str = str;
						document.getElementById('flash_frame').innerHTML = "";
						
						if(flash_frame_h < size){
							flash_frame_h = size;
							flashIn();
						
						}else{
							flash_frame_h = size;
							flash_out_h=size;
							flashOut();
						
						}
						
				}else{
					
						load_flash_on_complete = 0;
						flash_load_str = "";
						re=/gallery carousel/gi;
						if(str.match(re)){
								f_file = loadSWF(flash,flash+".swf?global_url="+global_url+"&gallery="+temp[2]+"&page="+temp[3]+"&style="+gallery_style+"&downloads="+gallery_downloads+"&high_c="+flash_highlight_color+"&show_name="+gallery_show_img_name+"&name_c="+gallery_img_name_color+"&bg_color="+flash_bg_color+"&w="+w);
							}else{
								f_file =loadSWF(flash,flash+".swf?global_url="+global_url+"&c1="+flash_color_1+"&c2="+flash_color_2+"&high_c="+flash_highlight_color+"&main_c1="+flash_main_color_1+"&main_c2="+flash_main_color_2+"&bw="+flash_back_width+"&xtra="+xtra+"&w="+w);
						}
						document.getElementById('flash_frame').innerHTML = f_file;
				
				}
				
			}else{
				load_flash_on_complete = 1;
				flash_load_str = str;
			}
	
	
	}else if(flash_in ==1){
		load_flash_on_complete = 0;
		flash_out_h = 0;
		flash_load_str = "";
		document.getElementById('flash_frame').innerHTML = "";
		flashOut();
	}
	
}

function loadFlashDiv(str,divname){
	
	div = document.getElementById(divname);
	if(div){
		if(str == ""){
			div.innerHTML = "";
		}else{
			
			temp = str.split(":");
			flash = temp[0].toLowerCase();
			
			re1 = /\s{1,}/gi;
			flash = flash.replace(re1,"_");
			size = temp[1];
			if(!temp[2]){
				xtra = "";
			}else{
				xtra = temp[2];
			}
			
			var w = Math.abs(temp[4]);
			
			re=/gallery carousel/gi;
			if(str.match(re)){
					f_file = loadSWF(flash,flash+".swf?global_url="+global_url+"&gallery="+temp[2]+"&page="+temp[3]+"&style="+gallery_style+"&downloads="+gallery_downloads+"&high_c="+flash_highlight_color+"&show_name="+gallery_show_img_name+"&name_c="+gallery_img_name_color+"&bg_color="+flash_bg_color+"&w="+w);
				}else{
					f_file =loadSWF(flash,flash+".swf?global_url="+global_url+"&c1="+flash_color_1+"&c2="+flash_color_2+"&high_c="+flash_highlight_color+"&main_c1="+flash_main_color_1+"&main_c2="+flash_main_color_2+"&bw="+flash_back_width+"&xtra="+xtra+"&w="+w);
			}
			div.innerHTML = f_file;
		}
	}
}

function loadSWF(f,fs,width,height,path,scale,salign){
	//alert(f);
	//alert(fs);
	
	if((!path)||(path == "")){
		path = global_url+'flash/';
	}
	if(!width){
		width = "100%";
	}
	if(!height){
		height = "100%";
	}
	if(!scale){
		scale = "noscale";
	}
	if(!salign){ //lt rt t lb b rb
		salign = "";
	}
	f_file = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'" id="'+f+'" align="middle"><param name="salign" value="'+salign+'" /><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+path+fs+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="scale" value="'+scale+'" /><param name="wmode" value="transparent" /><embed src="'+path+fs+'" loop="false" menu="false" quality="high"  scale="'+scale+'" wmode="transparent"  width="'+width+'" height="'+height+'" salign="'+salign+'" name="'+f+'"  align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	return f_file;
}

function drawFlash(f,fs,w,h,path,scale){
	//alert("draw flash");
	//alert(fs);
	document.write(loadSWF(f,fs,w,h,path,scale));
}


function loadSWFBackground(swf_back_file,swf_scale_type,swf_alignment){
	document.write(loadSWF("swf_back",swf_back_file,"100%","100%",global_url+"flash/",swf_scale_type,swf_alignment));
}

function openWindow(id,url,w,h){
	
	resizeable = "no";
	if(!w){
		w = "800";
		resizeable = "yes";
	}
	if(!h){
		h = "600";
		resizeable = "yes";
	}
	params = 'width='+w+', height='+h+', resizable='+resizeable+', scrollbars=no, toolbars=no, location=no, directories=no, status=no, menubar=no, copyhistory=no';
	var fwin = window.open(url, id, params);
	if (fwin && window.focus) fwin.focus();

	
}

var last_cat_src = "";
function loadCatalogue(product_id,cat1,cat2,brand,tag,auto){
	
	moveCalender(-2000,-2000);
	str = str1 = product_id+","+cat1+","+cat2+","+brand+","+tag;
	str = encode64(str);
	showLoading();
	document.getElementById('main_frame').src = last_cat_src = global_url+"scripts/pages.php?load_catalogue="+str;
	
}

function loadArticle(article_id,list_type,category,no_of_records,date_from,date_to){
	
	moveCalender(-2000,-2000);
	str = str1 = article_id+","+list_type+","+category+","+no_of_records+","+date_from+","+date_to;
	str = encode64(str);
	showLoading();
	document.getElementById('main_frame').src = last_cat_src = global_url+"scripts/pages.php?load_article="+str;
	
}

function cancelStyle(){
}

function loadPageStyle(img,flag,background_image,background_repeat){
	
	//alert(img+"\r\n"+flag+"\r\n"+background_image+"\r\n"+background_repeat);
	re_img=/.jpg/gi;
	
	flag = Math.abs(flag);
	
	try{
		
		folder_path = (img == "header_default.jpg") ? "images/" : "uploads/image/";
		header_img = ((img != "")&&(flag=='1')) ? "url("+global_url+folder_path+img+")" :  "none";
		
		if(document.getElementById('header_img_div').style.backgroundImage != header_img){
			document.getElementById('header_img_div').style.backgroundImage = header_img ;
			
			document.getElementById('header_img_div').style.backgroundRepeat = (header_img_repeat == 1) ? "repeat-x" : "no-repeat";
			document.getElementById('header_img_div').style.backgroundPosition = "50% 0px";
			
		}
		
	}catch(e1){
		document.getElementById('header').style.backgroundImage ="none";
	}
	
	try{
		if((background_image)&&(background_image != "")&&(background_image.substr(0,8) != "gallery:")){
				if(document.getElementById('main_page_back').style.backgroundImage != "url("+global_url+"uploads/image/"+background_image+")"){
					document.getElementById('main_page_back').style.backgroundImage = "url("+global_url+"uploads/image/"+background_image+")";
				}
				document.getElementById('main_page_back').style.backgroundRepeat = (background_repeat != "") ? background_repeat : "repeat";
			
		}else if(background_image.substr(0,8) != "gallery:"){
				document.getElementById('main_page_back').style.backgroundImage = 'none';
		}
		
		
	}catch(e1){
	}
	
	
	
	
}

function drawFlashHeader(rtn){
	
	obj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100%" height="100%" id="flash_header" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+global_url+'flash/flash_header.swf?global_url='+global_url+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="salign" value="t" /><param name="wmode" value="transparent" /><embed src="'+global_url+'flash/flash_header.swf?global_url='+global_url+'" loop="false" menu="false" quality="high" scale="noscale" wmode="transparent" salign="t" width="100%" height="100%" name="flash_header" swLiveConnect=true align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	if((is_IE == 0)&&(is_firefox==0)){		
		ver = GetSwfVer();
		if(ver < "10.0.22"){
				obj = '<div style=\"padding:50px;\" align=\"right\">Please download the latest <a href=\"http://get.adobe.com/flashplayer/\" target=\"_blank\" style=\"color:#000000;\"><u>flash player</u></a></div>';
		}
	}
	if(!rtn){
		document.write(obj);
	}else{
		return obj;
	}
}

function drawFlashHeaderMC(){
	site_f_width = (site_width == 0) ? parseInt(document.documentElement.clientWidth) : site_width;
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+site_f_width+'" height="100%" id="flash_header_mc" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+global_url+'flash/flash_header_mc.swf?global_url='+global_url+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="wmode" value="transparent" /><embed src="'+global_url+'flash/flash_header_mc.swf?global_url='+global_url+'" loop="false" menu="false" quality="high" scale="noscale" wmode="transparent" width="'+site_f_width+'" height="100%" name="flash_header_mc" swLiveConnect=true align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

var lastbg_color = "transparent";
var lastf_color = top_bar_font_color;
function toggleBackStyle(field,tog){
	
	try{
		if(tog == 1){
			lastbg_color = (field.style.backgroundColor) ? field.style.backgroundColor : lastbg_color;
			lastf_color = (field.style.color) ? field.style.color : lastf_color;
		}
		field.style.backgroundColor = (tog == 1) ? "#ffffff":lastbg_color;
		field.style.color = (tog == 1) ? "#000000": lastf_color;
	}catch(transErr){
	}
	
}

function forgotPassword(secure_flag){
	var str = (secure_flag ==1) ? "s_forgot_password":"forgot_password";
	document.getElementById('main_frame').src = last_cat_src = global_url+"scripts/pages.php?"+str;
}

function flashSearch(txt){
	
	re=/\s/gi
	
	test = txt.replace(re,"");
	
	
	if(test != ""){
		
		txt = encode64(txt);
		loadPage(global_url+"scripts/search.php?"+txt);
		
	}else{
		rtnHome();
	}
	
}

var default_search_txt = "enter keyword";
function checkClearSearch(){
	
	if(document.search_form.search_txt.value  == default_search_txt){
		document.search_form.search_txt.value='';
	}
}

function checkSearch(){
	
	closeAllMenus();
	
	fm = document.search_form;
	
	if((fm.search_txt.value  == "")||(fm.search_txt.value  == default_search_txt)||(fm.search_txt.value  == "searching...")){
	
		fm.search_txt.value = default_search_txt;
		fm.search_txt.focus();
		fm.search_txt.select();
	
	}else{
		
		flashSearch(fm.search_txt.value);
		toggleBackStyle(fm.search_txt,0);
		
	}
	
	
}

function reloadPage(){
	if(current_page != ""){
		document.getElementById('main_frame').src = global_url+current_page;
	}
}

function openDocument(doc){
	
	window.open(global_url+"scripts/document.php?"+doc);
	setTimeout("reloadPage()",5000);
	
}

function askQuestion(){
	
	
	document.getElementById('main_frame').src = global_url+"scripts/ask_question.php?edit=new";
	
	
}


function formatPassword(field){
	
	val = field.value;
	re = /\W/gi
	
	if(val.match(re)){
		val = val.replace(re,'');	
		if(document.getElementById('error_txt')){
			document.getElementById('error_txt').innerHTML = "Your password can only contain letters, numbers or the underscore(_)";
			if(document.getElementById('error_box')){
				document.getElementById('error_box').style.display = "block";
			}
			resizePage();
		}else{
			alert("Your password can only contain letters, numbers or the underscore(_)")
		}
		field.focus();
		field.value = val;
	}else{
		if(document.getElementById('error_txt')){
			  document.getElementById('error_txt').innerHTML = "&nbsp;";
			  if(document.getElementById('error_box')){
					document.getElementById('error_box').style.display = "none";
				}
			  resizePage();
		}
	}
	
	
}

function checkPasswordLength(field){
	if((field.value.length < 6)&&(field.value.length > 0)){
		if(document.getElementById('error_txt')){
			  document.getElementById('error_txt').innerHTML = "Your password must be at least 6 characters in length";
			  if(document.getElementById('error_box')){
					document.getElementById('error_box').style.display = "block";
				}
			  resizePage();
		}else{
			alert("Your password must be at least 6 characters in length");
		}
		field.value = "";
	 	field.focus();
	}else{
		if(document.getElementById('error_txt')){
			  document.getElementById('error_txt').innerHTML = "&nbsp;";
			  if(document.getElementById('error_box')){
					document.getElementById('error_box').style.display = "none";
				}
			  resizePage();
		}
	}
	
	
}

function checkPasswordMatch(field,original,rtn){
	
	if((original) && (field.value != "") && (original.value != "")){

			if(rtn){
				return (original.value == field.value)? true : false;
			}else{
				if(original.value != field.value){
					if(document.getElementById('error_txt')){
						document.getElementById('error_txt').innerHTML = "Please re-confirm your password";
						if(document.getElementById('error_box')){
							document.getElementById('error_box').style.display = "block";
						}
						resizePage();
					}else{
						alert("Please re-confirm your password")
					}
					field.value = "";
					field.focus();
				}else{
					if(document.getElementById('error_txt')){
						  document.getElementById('error_txt').innerHTML = "&nbsp;";
						  if(document.getElementById('error_box')){
								document.getElementById('error_box').style.display = "none";
							}
						  resizePage();
					}
				}
			}
			
	}else{
		if(document.getElementById('error_txt')){
			  document.getElementById('error_txt').innerHTML = "&nbsp;";
			  if(document.getElementById('error_box')){
					document.getElementById('error_box').style.display = "none";
				}
			  resizePage();
		}
	}
	
	return true;
	
}

function closeSearch(clear){
	
	fm = document.search_form;
	fm.search_txt.value  = (clear)?"":last_search;
	fm.search_txt.disabled = false;
	fm.search_btn.value  = "product code"
	fm.search_btn.disabled = false;
	
	
}

var last_search = "";
function searchProduct(keyword){

	last_search = keyword;
	
	fm = document.search_form;
	fm.search_txt.value  = "searching..."
	fm.search_txt.disabled = true;
	fm.search_btn.value  = "..."
	fm.search_btn.disabled = true;
	
	str = str1 = "search_products|"+keyword+"|";
	str = encode64(str);
	document.getElementById('main_frame').src = global_url+"scripts/pages.php?load_catalogue="+str;
	
	
	
	
}


function showSearchResults(clear){
	
	
	fm = document.search_form;
	fm.search_txt.value  = (clear)?"":last_search;
	fm.search_txt.disabled = false;
	fm.search_btn.value  = "product code"
	fm.search_btn.disabled = false;
	
	
	
}



var flash_in = 0;

function flashIn(){
	
	if(flash_disabled == 0){
		  h=flash_frame_h;
		  document.getElementById('flash_frame').style.height = h + "px";
		  document.getElementById('main_content').style.top = document.getElementById('right_content').style.top = h + "px";
		  document.getElementById('main_content').style.borderTop = document.getElementById('right_content').style.borderTop = "1px solid #333333";
		  resizePage();
		  flash_in = 1;
		  loadFlash(flash_load_str);
	}
	
}

var flash_out_h = 0;

function flashOut(){
	
		  h = flash_out_h;
		  document.getElementById('flash_frame').style.height = h + "px";
		  document.getElementById('main_content').style.top = document.getElementById('right_content').style.top = h + "px";
		  
		  if(flash_out_h > 0){
							  
				  flash_in = 1;
				  loadFlash(flash_load_str);
			  
		  }else{
				  flash_in = 0;
				  flash_load_str = "";
				  loadFlash(flash_load_str);
				  document.getElementById('main_content').style.borderTop = document.getElementById('right_content').style.borderTop = "0px solid #333333";
				  
		  }
		  flash_frame_h = flash_out_h;
		  resizePage();
	
}




function featuresIn(){
	
	site_f_width = (site_width == 0) ? parseInt(document.documentElement.clientWidth) : site_width;
	w = right_menu_width;
	document.getElementById('right_content').style.width = w + "px";
	side_w = parseInt(document.getElementById('left_content').style.width);
	document.getElementById('right_content').style.left = (site_f_width +  1-w) + "px";
	document.getElementById('main_content').style.width = (site_f_width - side_w - w) + "px";
	
}



function featuresOut(){
	
	site_f_width = (site_width == 0) ? parseInt(document.documentElement.clientWidth) : site_width;
	option_y = 100;
	w = 0;
	document.getElementById('right_content').style.width = w + "px";
	side_w = parseInt(document.getElementById('left_content').style.width);
	document.getElementById('right_content').style.left = (site_f_width + 1-w) + "px";
	document.getElementById('main_content').style.width = (site_f_width - side_w - w) + "px";
	
}





function sideMenuIn(){
	
	site_f_width = (site_width == 0) ? parseInt(document.documentElement.clientWidth) : site_width;
	w = left_menu_width;
	document.getElementById('left_content').style.width = w + "px";
	document.getElementById('main_content').style.left = (w+1) + "px";
	document.getElementById('flash_frame').style.width = (site_f_width - left_menu_width) + "px";
	document.getElementById('flash_frame').style.left = left_menu_width + "px";
	features_w = parseInt(document.getElementById('right_content').style.width);
	if(right_menu_moving == 1){
		features_w -= 20;
	}
	document.getElementById('main_content').style.width =  (site_f_width - features_w - w) + "px";
}



function sideMenuOut(){
	
	site_f_width = (site_width == 0) ? parseInt(document.documentElement.clientWidth) : site_width;
	menu_y = 100;
	w=0;
	document.getElementById('left_content').style.width = w + "px";
	document.getElementById('main_content').style.left =   (w+1) + "px";
	document.getElementById('flash_frame').style.left = "0px";
	document.getElementById('flash_frame').style.width = site_f_width + "px";
	features_w = parseInt(document.getElementById('right_content').style.width);
	document.getElementById('main_content').style.width = (site_f_width - features_w) + "px";
	
}


var resize_running = 0;

function resizePage(){
	
	
		
		if(resize_running == 0){
			resize_running = 1;
			
			//return false;
			h = parseInt(document.documentElement.clientHeight);
			w = parseInt(document.documentElement.clientWidth);
			w_start = w;
			
			if((document.getElementById('header'))&&(document.getElementById('header').innerHTML == "")){
				//document.getElementById('header').style.height="100px";
			}
			
			if((document.getElementById('background_header_div'))&&(document.getElementById('background_header_div').style.display=='none')){
				document.getElementById('background_header_div').style.display='block';
			}
			
			if((document.getElementById('background_footer_div'))&&(document.getElementById('background_footer_div').style.display=='none')){
				document.getElementById('background_footer_div').style.display='block';
			}
		
			if((document.getElementById('footer_menu'))&&(parseInt(document.getElementById('footer_menu').style.top = -1000))){
				document.getElementById('footer_menu').style.top = "0px";
			}
			
			if(is_IE == 1){//fix for ie
				if(document.getElementById('custom_header')){
					document.getElementById('custom_header').style.width = (w) +"px";
				}
				if(document.getElementById('main_div')){
					document.getElementById('main_div').style.width = (w) +"px";
				}
			}
			
	
			
			try{
				if((site_fixed_height > 0) && (site_float_y == 1)){
					
					t = ( Math.floor((h - site_fixed_height)/2) > 0) ? Math.floor((h - site_fixed_height)/2) : 0;
					
					if(document.getElementById('main_div')){
							document.getElementById('main_div').style.top= (t) +"px";
					}
					
					if(document.getElementById('background_header_div')){
							document.getElementById('background_header_div').style.top= (t) +"px";
					}
					
					
					
				}
				
			}catch(e){
				//alert(1);
			}
			
			
		
			try{
				
				if(site_width == 0){
					
					
					if(document.getElementById('main_page')){
							document.getElementById('main_page').style.width = (w) +"px";
					}
					if(document.getElementById('main_page_back')){
							document.getElementById('main_page_back').style.width = (w) +"px";
					}
					if(document.getElementById('background_header_div')){
							document.getElementById('background_header_div').style.width = (w) +"px";
					}
					
					if(document.getElementById('background_footer_div')){
							document.getElementById('background_footer_div').style.width = (w) +"px";
					}
					
					if(document.getElementById('flash_background')){
							document.getElementById('flash_background').style.width = (w) +"px";
					}
					
					if(document.getElementById('header_img_div')){
							document.getElementById('header_img_div').style.width = (w) +"px";
					}
					
					if(document.getElementById('header')){
							document.getElementById('header').style.width = (w) +"px";
					}
					if(document.getElementById('header_menu')){
							document.getElementById('header_menu').style.width = (w) +"px";
					}
					
					
					
					if(document.getElementById('footer_menu')){
							document.getElementById('footer_menu').style.width = (w) +"px";
					}
					
					
					
					if(document.getElementById('main_menu')){
							document.getElementById('main_menu').style.width = (w) +"px";
					}
					
					
					if(document.getElementById('dropdown_menus')){
						document.getElementById('dropdown_menus').style.left = 0 +"px";
					}
					
					left_w = 0;
					right_w = 0;
					
					if(document.getElementById('left_content')){
						auto = 0;
						if(document.getElementById('left_content').style.overflowY == "auto"){
							document.getElementById('left_content').style.overflowY = "hidden";
							auto = 1;
						}
						left_w = parseInt(document.getElementById('left_content').clientWidth);
						
						if(auto == 1){
							document.getElementById('left_content').style.overflowY = "auto";
						}
					}
					
					if(document.getElementById('right_content')){
						
						auto = 0;
						if(document.getElementById('right_content').style.overflowY == "auto"){
							document.getElementById('right_content').style.overflowY = "hidden";
							auto = 1;
						}
						right_w = parseInt(document.getElementById('right_content').clientWidth);
						if(auto == 1){
							document.getElementById('right_content').style.overflowY = "auto";
						}
					}
					
					m_w = 0;
					
				
					
					if(document.getElementById('main_content')){
							m_w = ((w-left_w-right_w) > 100) ? (w-left_w-right_w) : 100;
							document.getElementById('main_content').style.width = (m_w) +"px";
							//alert(left_w+"r\n"+right_w+"\r\n"+m_w);
					}
					
					if(document.getElementById('right_content')){
						 document.getElementById('right_content').style.left = (m_w + left_w+2) + "px";
					}
					
					
					m_w = 0;
					
	
					if(document.getElementById('flash_frame')){
							m_w = ((w-left_w) > 10) ? (w-left_w) : 10;
							document.getElementById('flash_frame').style.width = (m_w) +"px";
					}
					
					
					
				}else{
					
					if(document.getElementById('dropdown_menus')){
						drop_left = Math.round((w-(site_width+2))/2);
						if(drop_left < 0){ drop_left = 0; }
						
						document.getElementById('dropdown_menus').style.left = drop_left +"px";
					}
											
				
					/*this_w = (w > site_width) ? w : site_width;
					if(document.getElementById('background_header_div')){
							document.getElementById('background_header_div').style.width = (this_w) +"px";
					}
					
					if(document.getElementById('background_footer_div')){
							document.getElementById('background_footer_div').style.width = (this_w) +"px";
					}*/
					
					
				}
				
				
			}catch(e){
			}
			
		
			try{
		
					
					header_h = ((document.getElementById('header'))&&(document.getElementById('header').style.display == "block")) ? parseInt(document.getElementById('header').clientHeight) : 0 ;
					flash_h = (document.getElementById('flash_frame')) ? parseInt(document.getElementById('flash_frame').style.height):0 ;
					flash_h += (document.getElementById('flash_frame')) ? parseInt(document.getElementById('flash_frame').style.top):0 ;
					header_menu_h = ((document.getElementById('header_menu'))&&(document.getElementById('header_menu').style.display == "block")) ? parseInt(document.getElementById('header_menu').style.height) : 0;
					
					if(document.getElementById('main_content')){
						document.getElementById('main_content').style.display = "block";
						page_y = parseInt(document.getElementById('main_content').clientHeight)+20;
						
						 

					}
					
					if((document.getElementById('main_page_back')) && (document.getElementById('main_page_back').style.display == "none")){
						document.getElementById('main_page_back').style.display = "block";
					}
					
					if(document.getElementById('left_content')){
						 menu_y = parseInt(document.getElementById('left_content').clientHeight) + 20;
					}
					
					if(document.getElementById('right_content')){
						 option_y = parseInt(document.getElementById('right_content').clientHeight)+20;
					}
					
					footer_h = 0;
					if(document.getElementById('footer_menu')){
						 footer_h = parseInt(document.getElementById('footer_menu').clientHeight);
					}
					
					if(document.getElementById('main_content')){
						document.getElementById('main_content').style.overflowX = (main_overflow_x == 1) ? "auto" : "hidden";
					}
					
					if(document.getElementById('right_content')){
						document.getElementById('right_content').style.overflowX = (right_overflow_x == 1) ? "auto" : "hidden";
					}
					
					if(document.getElementById('left_content')){
						document.getElementById('left_content').style.overflowX = (left_overflow_x == 1) ? "auto" : "hidden";
					}
					
					
					
					if(site_fixed_height == 0){
					
							
							this_page_y = page_y+flash_h;
							this_option_y = option_y + flash_h;
							
							t_y = (menu_y > this_page_y)? menu_y : this_page_y;
							t_y = (this_option_y > t_y)? this_option_y : t_y;
							
							//alert("page_y:"+this_page_y+"\r\nmenu_y:"+menu_y+"\r\noption_y:"+this_option_y+"\r\nt_y:"+t_y+"\r\n(h - header_h  - footer_h):"+(h - header_h  - footer_h));
							
						
							
							if((t_y ) > (h - header_h - header_menu_h  - footer_h)){
								
									h1 = (t_y - flash_h - footer_h) ;
					
									h2 = (t_y  );
								
									h3 = (t_y - 1);
									
									if(document.getElementById('main_page')){
										document.getElementById('main_page').style.height = (t_y) +"px";
									}
									
									if(document.getElementById('dropdown_menus')){
										document.getElementById('dropdown_menus').style.top = (header_h + header_menu_h) +"px";
									}
									
									if(document.getElementById('main_page_back')){
										
										main_page_back_h = t_y  + header_h + header_menu_h + footer_h+ 4;
										main_page_back_t = 0;
										if(page_back_img_below_header >0){
											main_page_back_h -= header_h;
											main_page_back_t += header_h;
										}
										if((page_back_img_below_header ==2)&&(document.getElementById('main_menu'))){
											main_page_back_h -= header_menu_h;
											main_page_back_t += header_menu_h;
										}
										
										document.getElementById('main_page_back').style.height = main_page_back_h +"px";
										document.getElementById('main_page_back').style.top = main_page_back_t +"px";
									}
									
									
									if(document.getElementById('background_shadow_left')){
										document.getElementById('background_shadow_left').style.height = (t_y  + header_h + header_menu_h  + footer_h + 4) +"px";
									}
									if(document.getElementById('background_shadow_right')){
										document.getElementById('background_shadow_right').style.height = (t_y  + header_h + header_menu_h  + footer_h + 4) +"px";
										document.getElementById('background_shadow_left').style.display = document.getElementById('background_shadow_right').style.display = ((w >= (site_width+22)) && (site_width > 0)) ? "block":"none";
									}
									
									if(document.getElementById('flash_background')){
										document.getElementById('flash_background').style.height = (t_y  + header_h + header_menu_h  + footer_h+ 4) +"px";
									}
									if(document.getElementById('header_img_div')){
										document.getElementById('header_img_div').style.height = ((t_y  + header_h + header_menu_h  + footer_h+ 4) - parseInt(document.getElementById('header_img_div').style.top))  +"px";
									}
									
									if(document.getElementById('background_header_div')){
										document.getElementById('background_header_div').style.height = (t_y  + header_h + header_menu_h  + footer_h+ 4) +"px";
									}
									
									
									if(document.getElementById('background_footer_div')){
										document.getElementById('background_footer_div').style.height =(t_y  + header_h + header_menu_h  + footer_h+ 4) +"px";
										document.getElementById('background_footer_div').style.top = (0)  +"px";
									}
									
									
									if(document.getElementById('disable_page')){
										document.getElementById('disable_page').style.height = (t_y  + header_h + header_menu_h  + footer_h+ 4) +"px";
									}
									
									
								
									
								
							}else{
									
									h1 = (h-header_h-footer_h - header_menu_h  - flash_h);
									if(h1 < 10){h1=10;};
							
									h2 = (h-header_h - header_menu_h -footer_h);
									if(h2 < 10){h2=10;};
							
									h3 = (h-header_h- header_menu_h -101 - footer_h - flash_h);
									if(h3 < 10){h3=10;};
									
								
									
									if(document.getElementById('main_page')){
										document.getElementById('main_page').style.height = (h2-4) +"px";
										
									}
									
									if(document.getElementById('dropdown_menus')){
										document.getElementById('dropdown_menus').style.top = (header_h + header_menu_h) +"px";
									}
									
									if(document.getElementById('main_page_back')){
										main_page_back_h = h;
										main_page_back_t = 0;
										if(page_back_img_below_header >0){
											main_page_back_h -= header_h;
											main_page_back_t += header_h;
										}
										
										if((page_back_img_below_header ==2)&&(document.getElementById('main_menu'))){
											
											main_page_back_h -= header_menu_h;
											main_page_back_t += header_menu_h;
										}
										

										document.getElementById('main_page_back').style.height = main_page_back_h +"px";
										document.getElementById('main_page_back').style.top = main_page_back_t +"px";
										
									}
									
									
									if(document.getElementById('background_shadow_left')){
										document.getElementById('background_shadow_left').style.height = (h) +"px";
									}
									if(document.getElementById('background_shadow_right')){
										document.getElementById('background_shadow_right').style.height = (h) +"px";
										document.getElementById('background_shadow_left').style.display = document.getElementById('background_shadow_right').style.display = ((w >= (site_width+22)) && (site_width > 0)) ? "block":"none";
									}
									
									
									if(document.getElementById('header_img_div')){
										document.getElementById('header_img_div').style.height =  ((h)- parseInt(document.getElementById('header_img_div').style.top)) +"px";
									}
									
									if(document.getElementById('background_header_div')){
										document.getElementById('background_header_div').style.height = "100%";
									}
									
									if(document.getElementById('background_footer_div')){
										document.getElementById('background_footer_div').style.height = "100%";
									}
									
									if(document.getElementById('flash_background')){
										document.getElementById('flash_background').style.height = "100%"
									}
									
									
									if(document.getElementById('disable_page')){
										document.getElementById('disable_page').style.height = (h) +"px";
									}
									
									
									
									
							}
					
					
					}else{			
									body_h = h;
									h = site_fixed_height;
									//check min size of main content
									min_size = h-flash_h-footer_h-50;
									if(min_size < 50){
										
										//check flash_h and close if needed
										if(flash_h>0){
											
											flash_disabled =1;
											flash_out_h =0;
											
											if(window['flash_out']){
												clearTimeout(window['flash_out']);
											}
											if(window['flash_in']){
												clearTimeout(window['flash_in']);
											}
											flashOut();
										
											flash_h = 0;
											
											min_size = h-header_h-flash_h-header_menu_h-footer_h-50;
											
											
											if(min_size < 50){
												site_fixed_height = h + Math.abs(min_size) + 50;
											}
										}
									}
									
								
									if(site_float == 1){
										h_top = Math.round((body_h - h)/2);
										if(h_top < 0){ h_top = 0; }
									}else{
										h_top = 0;
									}
									
									if(site_float == 2){
										
											var page_border = (document.getElementById('main_page_back')) ? parseInt(document.getElementById('main_page_back').style.borderTopWidth) : 0;
											
											if(document.getElementById('main_content')){
												document.getElementById('main_content').style.top  = (flash_h>0) ? flash_h+"px" : page_border+"px";
												//document.getElementById('main_content').style.overflowY = (main_overflow_y == 1) ? "auto" : "hidden";
												document.getElementById('main_content').style.height = (h-header_menu_h-flash_h) +"px";
											}
											
											if(document.getElementById('right_content')){
												document.getElementById('right_content').style.top  = (flash_h>0) ? flash_h+"px" : page_border+"px";
												//document.getElementById('right_content').style.overflowY = (right_overflow_y == 1) ? "auto" : "hidden";
												document.getElementById('right_content').style.height =  (h-header_menu_h-flash_h) +"px";
											}
											
											if(document.getElementById('left_content')){
												document.getElementById('left_content').style.top =  page_border+"px";
												//document.getElementById('left_content').style.overflowY = (left_overflow_y == 1) ? "auto" : "hidden";
												document.getElementById('left_content').style.height = (h-header_menu_h) +"px";
												
											}
											
											
											if(document.getElementById('main_page')){
												document.getElementById('main_page').style.height = (h-header_menu_h-2) +"px";
												document.getElementById('main_page').style.top = 0 + "px";
											}
											
											if(document.getElementById('dropdown_menus')){
												document.getElementById('dropdown_menus').style.top = (header_h + header_menu_h) +"px";
											}
											
											
										
											
											
											if(document.getElementById('main_page_back')){
												document.getElementById('main_page_back').style.top = header_h + "px";
												document.getElementById('main_page_back').style.height = (h) +"px";
											}
										
									}else{
									
											if(document.getElementById('main_content')){
												document.getElementById('main_content').style.top  = (flash_h>0) ? flash_h+"px" : page_border+"px";
												//document.getElementById('main_content').style.overflowY = (main_overflow_y == 1) ? "auto" : "hidden";
												document.getElementById('main_content').style.height = (h-header_h-header_menu_h-flash_h) +"px";
											}
											
											if(document.getElementById('right_content')){
												document.getElementById('right_content').style.top  =  (flash_h>0) ? flash_h+"px" : page_border+"px";
												//document.getElementById('right_content').style.overflowY = (right_overflow_y == 1) ? "auto" : "hidden";
												document.getElementById('right_content').style.height = (h-header_h-header_menu_h-flash_h) +"px";
											}
											
											if(document.getElementById('left_content')){
												document.getElementById('left_content').style.top =  page_border+"px";
												//document.getElementById('left_content').style.overflowY = (left_overflow_y == 1) ? "auto" : "hidden";
												document.getElementById('left_content').style.height =  (h-header_h-header_menu_h) +"px";
												
											}
											
											if(document.getElementById('main_page')){
												document.getElementById('main_page').style.height = (h-header_h-header_menu_h-2) +"px";
												document.getElementById('main_page').style.top = 0 + "px";
											}
											
											if(document.getElementById('dropdown_menus')){
												document.getElementById('dropdown_menus').style.top = (0- (h-header_h-2)) +"px";
											}
									
											
											if(document.getElementById('main_page_back')){
												document.getElementById('main_page_back').style.top = h_top + "px";
												document.getElementById('main_page_back').style.height = (h) +"px";
											}
													
									
									}
									
									
									
									
									
									
									
									if(document.getElementById('flash_background')){
										document.getElementById('flash_background').style.height = (h) +"px";
									}
									
									if(document.getElementById('disable_page')){
										h2 = (parseInt(document.documentElement.clientHeight) > h) ? parseInt(document.documentElement.clientHeight) : h;
										document.getElementById('disable_page').style.height = (h2) +"px";
									}
										
									if(document.getElementById('header_img_div')){
										document.getElementById('header_img_div').style.top = h_top + "px";
										document.getElementById('header_img_div').style.height =  (h+header_h) +"px";
									}
									
									
									if(document.getElementById('background_shadow_left')){
										document.getElementById('background_shadow_left').style.top = h_top + "px";
										document.getElementById('background_shadow_left').style.height = (h) +"px";
									}
									if(document.getElementById('background_shadow_right')){
										document.getElementById('background_shadow_right').style.top = h_top + "px";
										document.getElementById('background_shadow_right').style.height = (h) +"px";
										document.getElementById('background_shadow_left').style.display = document.getElementById('background_shadow_right').style.display = ((w >= (site_width+22)) && (site_width > 0)) ? "block":"none";
									}
									
									h += header_h + footer_h;
									back_h = (body_h > h) ? body_h : h;
									if(document.getElementById('background_header_div')){
										document.getElementById('background_header_div').style.height = (back_h) +"px";
										document.getElementById('background_header_div').style.top = (0)  +"px";
									}
									
									if(document.getElementById('background_footer_div')){
										document.getElementById('background_footer_div').style.height = (back_h) +"px";
										document.getElementById('background_footer_div').style.top = (0)  +"px";
									}
									
								
					}
					
					
					
					
			
			}catch(e){
			}
			
			
			try{
				
				if(document.getElementById('page_logo') && (document.getElementById('page_logo').style.display != "block")){
						document.getElementById('page_logo').style.display = "block";
				}
				
			}catch(e){
			}
			resize_running = 0;
			//fix for IE
			w = parseInt(document.documentElement.clientWidth);
			if(w != w_start){
				resizePage();
			}
		}
	
		

}


var submenu_left = menu_width;
var submenu_width = menu_width;

var menu_image_height = 200;
var submenu_height = menu_image_height;
var submenu_top = 0;

var item_menu_left = menu_width * 2;
var item_menu_width = 400;
var item_menu_height = menu_image_height;
var disable_item_out = 0;
var disable_sub_out = 0;


var last_goto = 0;

function shopCheckOut(){
	window.location.href = s_global_url + "checkout";
}

function viewBasket(){
	window.location.href = s_global_url + "basket";
}

function memberLogin(type,details,reload_page,is_member,is_logged_in){
	try{
		closeLightBox();
	}catch(lb_err){
	}
	//alert(type+"\r\n"+details+"\r\n"+reload_page+"\r\n"+is_member+"\r\n"+is_logged_in);
	if(mem_allow_logon == 1){
		if(type == 0){
				
			expireDate = new Date;
			expireDate.setMonth(expireDate.getMonth()-6);
			expires = expireDate.toGMTString();
			document.cookie = "m_details=;expires="+expires+";path=/";
			document.cookie = "is_logged_in=;expires="+expires+";path=/";
			document.cookie = "is_member=;expires="+expires+";path=/";
			
			if(Math.abs(reload_page) == 1){
				rtnHome();
				//window.location.href = s_global_url+mem_logon_text.toLowerCase();
			}else{
				memberStatus(0,0,'');
			}
		}
		
		if(type == 1){
			current_page = "/scripts/members.php";
			document.getElementById('main_frame').src = global_url+"scripts/members.php?1";
		}
		
		if(type == 2){
			
			d = decode64(details);
			d_arr = d.split("|");
			if(d_arr.length >= 5){
				
				member_name = decode64(d_arr[0]);
				expireDate = new Date;
				expireDate.setMonth(expireDate.getMonth()+3);
				expires = expireDate.toGMTString();
				document.cookie = "m_details="+details+";expires="+expires+";path=/";
				document.cookie = "is_member=1;expires="+expires+";path=/";
				expireDate = new Date;
				expireDate.setMinutes(expireDate.getMinutes()+120);
				expires = expireDate.toGMTString();
				document.cookie = "is_logged_in=1;expires="+expires+";path=/";
				
				memberStatus(1,1,member_name);
				
				if(Math.abs(reload_page) == 1){
					if(current_page != ""){
						src = global_url+current_page.substr(1)+Math.random();
						document.getElementById('main_frame').src = src;
					}
				}
				
			}else{
				memberStatus(0,0,'');
				if(Math.abs(reload_page) == 1){
					if(current_page != ""){
						src = global_url+current_page.substr(1)+Math.random();
						document.getElementById('main_frame').src = src;
					}
				}
			}
			
		}
		
		if(type == 3){ //update details
			
			d = decode64(details);
			d_arr = d.split("|");
			if(d_arr.length >= 5){
				member_name = decode64(d_arr[0]);
				expireDate = new Date;
				expireDate.setMonth(expireDate.getMonth()+3);
				expires = expireDate.toGMTString();
				document.cookie = "m_details="+details+";expires="+expires+";path=/";
				document.cookie = "is_member="+is_member+";expires="+expires+";path=/";
				expireDate = new Date;
				expireDate.setMinutes(expireDate.getMinutes()+120);
				expires = expireDate.toGMTString();
				document.cookie = "is_logged_in="+is_logged_in+";expires="+expires+";path=/";
				memberStatus(is_member,is_logged_in,member_name);
				
			}else{
				memberStatus(0,0,'');
			}
			
		}
		
		if(type == 4){
			current_page = "/scripts/members.php";
			document.getElementById('main_frame').src = global_url+"scripts/members.php?2";
		}
		
	
	}
	
	
}

var mem_logon_text = "Your Client/Candidate Account";
var mem_logon_text_dir = "Your Account";

function memberStatus(is_member,is_logged_in,member_name){
	
	//alert(is_member+"\r\n"+is_logged_in+"\r\n"+member_name);
	if(mem_allow_logon == 1){
		
		div = document.getElementById('main_frame');
		
		txt = "";
		if(is_member == 1){
			txt = "Welcome "+member_name;
		}
		if((is_logged_in == 0)&&(div)){
			//txt += "<a href=\"#"+mem_logon_text+"\" onmouseover=\"javascript:this.style.cursor='pointer';\" onclick=\"javascript:memberLogin(1);\">";
			txt += "<a href=\""+s_global_url+mem_logon_text_dir.toLowerCase()+"\">";
			txt += (is_member == 1)? "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;"+mem_logon_text : mem_logon_text;
			txt += "</a>";
		}else if(is_member == 1){
			if(div){
				txt += "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\""+s_global_url+mem_logon_text_dir.toLowerCase()+"\">"+mem_logon_text+"</a>";
			}
			if(is_logged_in == 1){
				txt += "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href=\"#logout\" onclick=\"javascript:memberLogin(0,'',1);\">Sign&nbsp;Out</a>";
			}else if(!div){
				txt += "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;You are not signed in.";
			}
		}
		
		updateLogOnTxt(txt);
	}
	
}

var log_txt = "";
function updateLogOnTxt(txt){
	
	if(document.getElementById('logon_status_txt')){
		try{
		document.getElementById('logon_status_txt').innerHTML = txt;
		}catch(e){
		}
	}
	
}



function start(){
	expireDate = new Date;
	expireDate.setMonth(expireDate.getMonth()-2);
	parent.document.cookie = "search_catalogue_order=;expires="+expireDate.toGMTString()+";path=/";
	
	if(is_IE == 1){
		document.body.scroll = "yes";
	}
	clearSearchOptions();
	updatePrintDiv();
	
	try{
		onPageComplete();
	}catch(e){
		//alert(e);
	}
	
	
	//document.getElementById('main_content').style.display = "block";
	//document.getElementById('left_content').style.display = "block";
	//document.getElementById('right_content').style.display = "block";
	//document.getElementById('flash_frame').style.display = "block";
	resizePage();
	setThemeDefaults();
	if(mem_allow_logon == 1){
		document.getElementById('logon_frame').src = global_url+"scripts/members.php?checklogon";
	}
	if(can_get_basket == 1){
		document.getElementById('process_frame').src = global_url+"scripts/catalogue.php?getBasket";
	}
	
	if(page_images.length > 0){
		loadOtherImages();
	}
	
		
}

var default_bg_top_img = "";
var default_bg_bottom_img = "";
var default_pg_border_color = ""; 
var default_menu_border_color = "";
var default_menu_font_color = "";
var current_menu_font_color = "";

function setThemeDefaults(){
	if(document.getElementById('background_header_div')){
		default_bg_top_img = document.getElementById('background_header_div').style.backgroundImage;
	}
	if(document.getElementById('background_footer_div')){
		default_bg_bottom_img = document.getElementById('background_footer_div').style.backgroundImage;
	}
	if(document.getElementById('main_page_back')){
		if(document.getElementById('main_page_back').style.borderColor){
			default_pg_border_color = document.getElementById('main_page_back').style.borderColor;
		}else if(document.getElementById('main_page_back').style.borderTopColor){
			default_pg_border_color = document.getElementById('main_page_back').style.borderTopColor;
		}else if(document.getElementById('main_page_back').style.borderBottomColor){
			default_pg_border_color = document.getElementById('main_page_back').style.borderBottomColor;
		}else if(document.getElementById('main_page_back').style.borderLeftColor){
			default_pg_border_color = document.getElementById('main_page_back').style.borderLeftColor;
		}else if(document.getElementById('main_page_back').style.borderRightColor){
			default_pg_border_color = document.getElementById('main_page_back').style.borderRightColor;
		}
	}
	
	if(document.getElementById('header_menu')){
		if(document.getElementById('header_menu').style.borderColor){
			default_menu_border_color = document.getElementById('header_menu').style.borderColor;
		}else if(document.getElementById('header_menu').style.borderTopColor){
			default_menu_border_color = document.getElementById('header_menu').style.borderTopColor;
		}else if(document.getElementById('header_menu').style.borderBottomColor){
			default_menu_border_color = document.getElementById('header_menu').style.borderBottomColor;
		}else if(document.getElementById('header_menu').style.borderLeftColor){
			default_menu_border_color = document.getElementById('header_menu').style.borderLeftColor;
		}else if(document.getElementById('header_menu').style.borderRightColor){
			default_menu_border_color = document.getElementById('header_menu').style.borderRightColor;
		}
	}
	
	if(total_btns > 0){
		for(i=1;i<(total_btns+1);i++){
			if(document.getElementById('main_btn_'+i)){
				default_menu_font_color = current_menu_font_color = document.getElementById('main_btn_'+i).style.color;
				break;
			}
		}
	}
	
	
}


function updateTheme(bg_top_img,bg_bottom_img,pg_border_color,menu_border_color,menu_font_color){
	
	current_menu_font_color = (menu_font_color != "") ? menu_font_color : default_menu_font_color;
	
	if(document.getElementById('background_header_div')){
		if(bg_top_img == "none"){
			document.getElementById('background_header_div').style.backgroundImage ="none";
		}else{
			document.getElementById('background_header_div').style.backgroundImage = (bg_top_img != "") ? "url("+bg_top_img+")" : default_bg_top_img;
		}
	}
	if(document.getElementById('background_footer_div')){
		if(bg_bottom_img == "none"){
			document.getElementById('background_footer_div').style.backgroundImage ="none";
		}else{
			document.getElementById('background_footer_div').style.backgroundImage = (bg_bottom_img != "") ? "url("+bg_bottom_img+")" : default_bg_bottom_img;
		}
	}
	if(document.getElementById('main_page_back')){
		obj = document.getElementById('main_page_back').style;
		obj.borderColor=obj.borderTopColor=obj.borderBottomColor=obj.borderLeftColor=obj.borderRightColor= (pg_border_color != "") ? pg_border_color : default_pg_border_color;
	}
	if(document.getElementById('header_menu')){
		obj = document.getElementById('header_menu').style;
		obj.borderColor=obj.borderTopColor=obj.borderBottomColor=obj.borderLeftColor=obj.borderRightColor= (menu_border_color != "") ? menu_border_color : default_menu_border_color;
	}
	if(total_btns > 0){
		for(i=1;i<(total_btns+1);i++){
			if(document.getElementById('main_btn_'+i)){
				document.getElementById('main_btn_'+i).style.color = (menu_font_color != "") ? menu_font_color : default_menu_font_color;
			}
		}
	}
	
}

var menu_dif = 0;
var menu_z = 0;



function loadTopPage(p){
	top.location.href=p;
}
function loadPage(p){
	closeAllMenus();
	moveCalender(-2000,-2000);
	showLoading();
	document.getElementById('main_frame').src = p;

	try{
		document.getElementById('main_frame').focus();
	}catch(e){
	}
	
}

function loadPageJS(p){
	closeAllMenus();
	moveCalender(-2000,-2000);
	showLoading();
	document.getElementById('main_frame').src = p;
	try{
		document.getElementById('main_frame').focus();
	}catch(e){
	}
	
}

function loadPageNum(p){
	closeAllMenus();
	moveCalender(-2000,-2000);
	showLoading();
	document.getElementById('main_frame').src = global_url+"scripts/pages.php?p="+p;
	
	try{
		document.getElementById('main_frame').focus();
	}catch(e){
	}
	
}


function loadMemberPageNum(p){
	closeAllMenus();
	moveCalender(-2000,-2000);
	showLoading();
	document.getElementById('main_frame').src = global_url+"scripts/members.php?p="+p;
	
	try{
		document.getElementById('main_frame').focus();
	}catch(e){
	}
	
}

function checkMenuOut(m){
	
	if(window[m+'out']){
		clearTimeout(window[m+'out']);
	}
	window[m+'out'] = setTimeout("menuOut('"+m+"')",250);
		
}

function clearMenuOut(m){

	if(window[m+'out']){
		clearTimeout(window[m+'out']);
	}
}

function reloadMenu(mod){
	
	if(mod!=current_module){
		current_module = mod;
		menu_height_array = Array();
		document.getElementById('dropdown_menus').innerHTML = "";
		document.getElementById('main_menu').innerHTML = "<div style=\"font-size:5px;\">&nbsp</div><div style=\"width:100%;text-align:center;\" id=\"menu_loading_txt\">loading menu...</div>";
		document.getElementById('process_frame').src = global_url+"scripts/menu.php?main|"+encode64(mod)+"|"+encode64(current_menu_font_color+"");
	}
	
}

function createMenu(menu_table_enc,menu_enc,main_menu_back_width,main_menu_width,main_menu_left,t_btns,btn_width){
	
	total_btns = total_menus = t_btns;
	menu_width = btn_width;
	document.getElementById('main_menu').style.left = main_menu_left +"px";
	document.getElementById('main_menu').innerHTML = decode64(menu_table_enc);
	document.getElementById('dropdown_menus').innerHTML = decode64(menu_enc);
	
}


var menu_max_height = 550;
var menu_height_array = Array();
var menu_width_array = Array();

function menuIn(m){

	abort = 0
	
	if(document.getElementById('main_btn_'+m)){
	
		num = Math.abs(m);
		site_f_width = (site_width == 0) ? parseInt(document.documentElement.clientWidth) : site_width;
		
				//update btn background
		checkMainBtnOver(m);
		closeAllMenus(m);
		
		try{
			if(document.getElementById('menu_'+m)){
					if(!menu_height_array[num]){
		
						this_l = document.getElementById('menu_'+m).style.left;
						document.getElementById('menu_'+m).style.left = "-2000px";
						document.getElementById('menu_'+m).style.top = "-6000px";
						document.getElementById('menu_'+m).style.display = "block";
						
						this_div = document.getElementById('menu_content_'+num);
						if(this_div){
								d_w = parseInt(this_div.clientWidth);
								d_h = parseInt(this_div.clientHeight);
								menu_height_array[num] = d_h;
								menu_width_array[num] = d_w;
								if(document.getElementById("menu_shadow_"+num)){
									document.getElementById("menu_shadow_"+num).style.width = d_w +"px"; 
								}
								document.getElementById('menu_'+m).style.display = "none";
								document.getElementById('menu_'+m).style.left = ((parseInt(this_l) + d_w) < (menu_width * total_menus)) ?  this_l : parseInt(this_l) + num + ((menu_width * total_menus) - (parseInt(this_l) + d_w)) + "px"; 
								document.getElementById('menu_'+m).style.top = "0px";
						}else{
							abort = 1;
						}
		
					}
		
					if(abort == 0){
		
							menu_z ++;
							document.getElementById('menu_'+m).style.zIndex = menu_z;
	
							height = menu_height_array[num];	
							
							//fixed for IE7
							var html = "OK";
							try{
								var elements = document.getElementsByName('dd_menu_links');
								html = elements[(num-1)].innerHTML;
							}catch(html_err){
							}
										
							//if(menu_can_move == 0){
		
										if((height > dropdown_min_height)&&(html != "")){
											
													h = height;
													//work out left
													
													l = parseInt(document.getElementById('main_menu').style.left) + dropdown_menu_left_offset;
													if(m > 1){
														l +=1;
													}
													for(b=1;b<(num);b++){
														this_w = parseInt(document.getElementById("main_btn_"+b).clientWidth)
														l +=this_w;
														if(b > 1){
															l+=main_menu_btn_spacing;
														}
													}
		
													//l = parseInt(document.getElementById(m).style.left);
													w = menu_width_array[num];
		
													//avail = parseInt(document.documentElement.clientWidth) - (((parseInt(document.documentElement.clientWidth)-site_f_width) / 2) + l);
													avail = site_f_width - l;
												
													if(avail < w){
														document.getElementById('menu_'+m).style.left = (l - (w - avail) - 1) + "px";
													}else{
														document.getElementById('menu_'+m).style.left = (l) + "px";
													}
													if(document.getElementById("menu_shadow_"+num)){
														document.getElementById("menu_shadow_"+num).style.height = (h+4) + "px";
													}
													document.getElementById('menu_'+m).style.display = "block";
													
													process_menu = null;
													process_height = 0;
		
		
										}
		
							//}
							
		
					}else{
		
								process_menu = null;
								process_height = 0;
					}
			}else{
				//menu doesn't exist
			}
		
		}catch(err){
			alert(err);
		}
		
	
	}
	
	
}
var closeAll = 0;
var current_menu = 0;

function closeAllMenus(menu){
		
		for(i=1;i<=total_menus;i++){
			this_m = "menu_"+(i);
			if(document.getElementById(this_m)){
					
					if((menu) && (menu == i)){
					}else if(current_menu == (i)){
					}else{
						menuOut(i);
					}
			}		
			
		}
	
}



function menuOut(m,debug){

	if(debug){
		
	}
	if(window[m+'out']){
		clearTimeout(window[m+'out']);
	}
	checkMainBtnOut(m);
	if(document.getElementById('menu_'+m)){
				document.getElementById('menu_'+m).style.display = "none";
				process_menu = null;
				process_height = 0;
	}
	
}


function checkMainBtnOver(id){
		for(i=1;i<=total_btns;i++){		
				if(i != id){
					 checkMainBtnOut(i);
				}
		}
		if(document.getElementById('main_btn_'+id)&&(document.getElementById('main_btn_'+id).className != "main_menu_selected")){
			w = parseInt(document.getElementById('main_btn_'+id).clientWidth);
			x = 0 - 200 - Math.floor((200 - w)/2);
			document.getElementById('main_btn_'+id).style.backgroundPosition = x+"px 0px ";
		}
}

function checkMainBtnOut(id){
	if(document.getElementById('main_btn_'+id)&&(document.getElementById('main_btn_'+id).className != "main_menu_selected")){
		w = parseInt(document.getElementById('main_btn_'+id).clientWidth);
		x = 0 - Math.floor((200 - w)/2);	
		document.getElementById('main_btn_'+id).style.backgroundPosition = x+"px 0px";
	}
}


var current_date_div = null;
var calender_left = -2000;
var calender_top = -2000;
function showCalender(field,left,top,dateMin,dateMax,startdate,div){
		
		value = field.value;
		current_date_div = (div) ? div : null;
		current_date_field  = field;
		
		if((value == "")&&(startdate)){
			value = startdate;
		}
		
		calender_left = left;
		calender_top  = top;
		document.getElementById('calender_frame').src = global_url+"admin/calendar_popup.php?field="+field+"&value="+value+"&date_min="+dateMin+"&date_max="+dateMax;

}

function moveCalender(left,top){
		
		document.getElementById('calender').style.left = left +"px";
		document.getElementById('calender').style.top = top +"px";
	
}

function formatDate(div,date){
	if(div){
		date_arr = date.split("-");
		div.innerHTML = ((date == "")||(date == "0000-00-00")) ? "&nbsp" : date_arr[2]+" "+date_arr[1]+" "+date_arr[0];
	}
}


function updateDiv(date){
	
	if(current_date_div){
		formatDate(current_date_div,date);
	}
	
}

function checkOver(btn){
	
		btn.className = btn.className +"_over";
		btn.style.cursor='pointer';
		
}

function checkOut(btn){
	
	re = /_over/gi;
	if(btn.className.match(re)){
		newClass = btn.className.replace(re,"");
		btn.className = newClass;
	}
	btn.style.cursor='default';
	
}


function getCookieValue(cookieName){
	
	theCookie=""+document.cookie;
	
	ind=theCookie.indexOf(cookieName);
 	if (ind==-1 || cookieName=="") {
			val = "";
	}else{
 			ind1=theCookie.indexOf(';',ind);
 			if (ind1==-1) {
				ind1=theCookie.length; 
			}
			val =  unescape(theCookie.substring(ind+cookieName.length+1,ind1));
			
	}
	
	if(val == ";"){
		val = "";
	}
	
	return val;
	
}

function urlencode (str) {
    
    var hexStr = function (dec) {
        return '%' + dec.toString(16).toUpperCase();
    };
 
    var ret = '',
            unreserved = /[\w.-]/; // A-Za-z0-9_.- // Tilde is not here for historical reasons; to preserve it, use rawurlencode instead
    str = (str+'').toString();
 
    for (var i = 0, dl = str.length; i < dl; i++) {
        var ch = str.charAt(i);
        if (unreserved.test(ch)) {
            ret += ch;
        }
        else {
            var code = str.charCodeAt(i);
            // Reserved assumed to be in UTF-8, as in PHP
            if (code === 32) {
                ret += '%20'; // %20 in rawurlencode
            }
            else if (code < 128) { // 1 byte
                ret += hexStr(code);
            }
            else if (code >= 128 && code < 2048) { // 2 bytes
                ret += hexStr((code >> 6) | 0xC0);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 2048 && code < 65536) { // 3 bytes
                ret += hexStr((code >> 12) | 0xE0);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 65536) { // 4 bytes
                ret += hexStr((code >> 18) | 0xF0);
                ret += hexStr(((code >> 12) & 0x3F) | 0x80);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
        }
    }
    return ret;
}


var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
   
   return output;
}

function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}


//image transitions function

var cache_page_images = new Array();

var current_image = 0;
var current_image_url = global_url+"images/trans.gif";
var image_change_delay = (is_IE)? 14 * 1000  : 10 * 1000; // 10 seconds
var inital_image_change_delay = 5 * 1000; // 7 seconds
var divid = "main_page_back";
var imageid = "main_page_back_img";
function loadOtherImages() {
	
	if(page_images.length > 1){
		var d = new Date();
		var before;
		var after;
		var j = 0;
		var start_swap_img = 0;
		for (var i in page_images)
		{
			d = new Date();
			before = d.getTime();
			if(j==0){
				changeOpac(0, imageid);
				if(document.getElementById(imageid).src != global_url+"images/" + page_images[i]){
					document.getElementById(imageid).src = current_image_url;
					blendimage(divid, imageid, global_url+"images/" + page_images[i], 2500) ;
				}else{
					document.getElementById(imageid).src  = global_url+"images/" + page_images[i] ;
					start_swap_img = 1;
					current_image_url = global_url+"images/" + page_images[i];
				}
			}
	
			cache_page_images[j] = new Image();
			cache_page_images[j].src = global_url+"images/" + page_images[i];
			
			d = new Date();
			after = d.getTime();
	
			// don't bother if it takes too long
			if ((after - before) >  5000) break;
			j++;
		}
		
		if(start_swap_img == 1){
			if(window['image_changer']){
				clearTimeout(window['image_changer']);
			}
			window['image_changer'] = setTimeout("swapImage()",inital_image_change_delay);
		}
	
	}else{
		document.getElementById(imageid).src  = global_url+"images/" + page_images[0] ;
		current_image_url = global_url+"images/" + page_images[0];
	}
	//swapImage();
}


function clearSwapImages(){
	
	if(window['image_changer']){
		clearTimeout(window['image_changer']);
	}
	for(i = 0; i <= 100; i++) { 
		if(window['opt_'+i]){
			clearTimeout(window['opt_'+i]);
		}
	}
	if((imageid)&&(document.getElementById(imageid))){
		changeOpac(0, imageid);
		document.getElementById(imageid).src = current_image_url;
		document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
	}
	image_changer = null;
	page_images = new Array();
	cache_page_images = new Array();
	current_image = 0;
	
}
var next_img = 0;
function swapImage() 
{
	
	if(window['image_changer']){
		clearTimeout(window['image_changer']);
	}
	
	for(i = 0; i <= 100; i++) { 
		if(window['opt_'+i]){
			clearTimeout(window['opt_'+i]);
		}
	}
	
	var n = cache_page_images.length;


	if(gallery_background_random == 1){
			do 
			{	
					i = Math.floor(Math.random() * n);
			} 
			while (!cache_page_images[i] || (i == current_image && n > 1));
	
	}else{
			i = Math.abs(next_img) + 1;
			if(i == n){
				i=0;
			}
			next_img = i;
	}
	
	if(cache_page_images[i]){
		//alert(cache_page_images[i].src);
		blendimage(divid, imageid, cache_page_images[i].src, 2500)
		current_image = i;
	}
	
	
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
	
	
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
	if((id)&&(document.getElementById(id))){
		var object = document.getElementById(id).style; 
		object.opacity = (opacity / 100); 
		object.MozOpacity = (opacity / 100); 
		object.KhtmlOpacity = (opacity / 100); 
		object.filter = "alpha(opacity=" + opacity + ")";
		//debug(opacity+", ");
	}
}

function shiftOpacity(id, millisec) { 
    //if an element is invisible, make it visible, else make it ivisible 
    if(document.getElementById(id).style.opacity == 0) { 
        opacity(id, 0, 100, millisec); 
    } else { 
        opacity(id, 100, 0, millisec); 
    } 
}

function blendimage(divid, imageid, imagefile, millisec) { 
	
	if( document.getElementById(divid)){
		var speed = Math.round(millisec / 100); 
		var timer = 0; 
		 
		//set the current image as background 
	
		document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
		current_image_url = imagefile;
	
		 
		//make image transparent 
		changeOpac(0, imageid); 
		
		if(document.getElementById('debug_txt')){
			document.getElementById('debug_txt').innerHTML = current_image_url+"<br>";
		}
		 
		//make new image 
		document.getElementById(imageid).src = imagefile; 
		document.getElementById(imageid).display = "block";
	
		//fade in image 
		for(i = 0; i <= 100; i++) { 
			window['opt_'+i] = setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
			timer++; 
		}
		
		window['image_changer'] = setTimeout("swapImage()",image_change_delay);
		
	}
}

/******************************
CHECK NUMBER
******************************/

function checkNumber(field,type){

	switch(type){
		case "full":		thisNum = parseInt(field.value);
		break;
		
		case "decimal":		t1 = field.value;
							t2 = round_decimals(t1, 2);
							t3 = pad_with_zeros(t2, 2);
							thisNum = t3;
		break;
		
	}

	thisNum1 = ""+ thisNum;
	if(thisNum1.substr(0,3) == "NaN"){
		field.value = (type == "full") ? "0" : "0.00";
	}else{
		field.value = thisNum
	}
}


function formatNumber(num,type){
	switch(type){
		

		case "full":		thisNum = parseInt(num);
		break;
		
		case "decimal":		t1 = num
							t2 = round_decimals(t1, 2);
							t3 = pad_with_zeros(t2, 2);
							thisNum = t3;
		break;
		
	}
	
	thisNum1 = ""+ thisNum;
	if(thisNum1.substr(0,3) == "NaN"){
		return  (type == "full") ? "0" : "0.00";
	}else{
		return  thisNum;
	}
	
	
}

function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}



function pad_with_zeros(rounded_value, decimal_places) {

  
    var value_string = rounded_value.toString()
    var decimal_location = value_string.indexOf(".")
    if (decimal_location == -1) {
        decimal_part_length = 0
        value_string += decimal_places > 0 ? "." : ""
    }
    else {
        decimal_part_length = value_string.length - decimal_location - 1
    }
    var pad_total = decimal_places - decimal_part_length
    if (pad_total > 0) {
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }
    return value_string
}


/******************************
END CHECK NUMBER END
******************************/

function disablePage(bool){
		if(document.getElementById("disable_page")){
			document.getElementById("disable_page").style.display = (bool)? "block":"none";
		}
}


function toggleObj(id1,id2,id3,id4){
	
	//id1 & id3 shown, id2 & id4 hidden
	
	if(document.getElementById(id1)){
		dis = document.getElementById(id1).style.display;
		document.getElementById(id1).style.display = (dis == "none")?"block":"none";
		if(document.getElementById(id3)){
			document.getElementById(id3).style.display = (dis == "none")?"block":"none";
		}
		if(document.getElementById(id2)){
			document.getElementById(id2).style.display = (dis == "none")?"none":"block";
		}
		if(document.getElementById(id4)){
			document.getElementById(id4).style.display = (dis == "none")?"none":"block";
		}
	}
	
	try{
		resizePage();
	}catch(e){
	}
}

/***********************
Scroll Gallery Functions
************************/

var gallery_scroll_bar_offset_x = 0;
var gallery_containers = Array();
var current_scroll_timer = null;
var current_scroll_timer2 = null;
var gallery_start_l = 0;
var gallery_sb_start_l = 0;
var gallery_start_l = 0;
var gallery_img_inc = 1;
var auto_scroll_speed = 10;
var gallery_img_inc_speed = auto_scroll_speed;
var gallery_global_inc_speed =100; 
var gallery_can_scroll_img = 0;
var gallery_scroll = 0;
var gallery_sb_direction = "right";
var auto_scroll_g_x = 0;
var auto_scroll_inc = 1;
var gallery_firstload = 1;
//scroll gallery functions

function toggleGalleryHTML(img,id){
	
	if(document.getElementById(id)){
		dis = document.getElementById(id).style.display;
		document.getElementById(id).style.display = (dis == "block")?"none":"block";
		img.alt = (dis == "block")? "click here to show more information" : "click here to hide more information";
	}
	
}
function positionScrollBar(div1,div_container1,div2,div_container2,scroll_div,id,offset,scale,total_h){
	
	if((document.getElementById(div1)) && (document.getElementById(div_container1)) && (document.getElementById(div2)) && (document.getElementById(div_container2)) && (document.getElementById(scroll_div))){
			
			if(offset){
				gallery_scroll_bar_offset_x = offset;
			}
			main_w = parseInt(document.getElementById(div_container1).clientWidth);
			main_h = parseInt(document.getElementById(div_container1).clientHeight);
			main_img_w = parseInt(document.getElementById(div1).clientWidth);
			main_img_l = parseInt(document.getElementById(div1).style.left);
			scroll_bar = document.getElementById(scroll_div);
			
			scrollbar_h = parseInt(scroll_bar.style.height) - (parseInt(scroll_bar.style.borderWidth) * 2);
			ratio = main_w/main_h;
			scrollbar_w = Math.round((scrollbar_h) * ratio * scale) ;
			
			if((id)&&(!gallery_containers[id])){
				temp_arr = Array();
				temp_arr[0] = document.getElementById(div1);
				temp_arr[1] = document.getElementById(div_container1);
				temp_arr[2] = document.getElementById(div2);
				temp_arr[3] = document.getElementById(div_container2);
				temp_arr[4] = scroll_bar;
				temp_arr[5] = 0; //div1 offset
				gallery_containers[id] = temp_arr;
			}
			
			
			preview_w = parseInt(document.getElementById(div_container2).clientWidth);
			preview_h = parseInt(document.getElementById(div_container2).style.height);
			preview_img_w = parseInt(document.getElementById(div2).clientWidth);
			preview_img_l = parseInt(document.getElementById(div2).style.left);
			scroll_div_l = parseInt(scroll_bar.style.left);
			
			d = new Date();
			
			
			if(main_img_w < main_w){
				
					scroll_bar.style.display = "none";
					document.getElementById(div1).style.left = "0px";
					document.getElementById(div2).style.left = "0px";
				
			}else{
			
					//check image
					scale = main_img_w / preview_img_w;
					
					if(preview_img_l < 0){
						if((preview_img_w - Math.abs(preview_img_l)) < preview_w){
							new_l = preview_w - preview_img_w;
							document.getElementById(div2).style.left = new_l+ "px";					
							gallery_containers[id][5]= Math.round(new_l*scale);
							document.getElementById(div1).style.left = (0 - Math.round(scroll_div_l*scale) + Math.round(new_l*scale))+ "px";
							
							
						}
					}else if(preview_img_l > 0){
							new_l = 0;
							document.getElementById(div2).style.left = new_l+ "px";					
							gallery_containers[id][5]= Math.round(new_l*scale);
							document.getElementById(div1).style.left = (0 - Math.round(scroll_div_l*scale) + Math.round(new_l*scale))+ "px";
					}
					
					
					
					if(scroll_div_l > 0){
						
						max_x = (preview_img_w < preview_w) ? preview_img_w  :preview_w
						if(is_IE == 0){
							max_x -=2;
						}
						scroll_w = scroll_div_l+scrollbar_w;
						
						if(scroll_w > max_x){
							l =  max_x - scrollbar_w; 
							scroll_bar.style.left = l;
							document.getElementById(div1).style.left = (0 - Math.round(l*scale) + gallery_containers[id][5])+ "px";
							
						}
					}
					
					
					if(scroll_div_l < 0){
						l =  0; 
						scroll_bar.style.left = l;
						document.getElementById(div1).style.left = (0 - Math.round(l*scale) + gallery_containers[id][5])+ "px";
						
					}
					
					if(gallery_firstload == 1){
						sb_top_max = (main_h + preview_h + 10);
						var sb_h = parseInt(scroll_bar.style.height);
						var dif = total_h - main_h - sb_h ;
						if(dif < 0){
							sb_top  = main_h+10;
							scroll_bar.style.height = (scrollbar_h + dif ) + "px";
						}else{
							sb_top = main_h+dif;
							scroll_bar.style.height = (total_h - main_h - dif - (parseInt(scroll_bar.style.borderWidth) * 2) ) + "px";
						}
						
						scroll_bar.style.top =  sb_top + "px";
						gallery_firstload = 0;
					}
					
					scroll_bar.style.width = scrollbar_w + "px";
					scroll_bar.style.display = "block";
					
					startMouseMove();
			
			}
			
	}
	
	
}


function clearScrollDivBar(id,not_t1,not_t2){
	
	gallery_can_scroll_img = 0;
	gallery_scroll = 0;
	document.documentElement.style.cursor='default';
	
	if((current_scroll_timer)&&(!not_t1)){
		clearInterval(current_scroll_timer);
	}
	if((current_scroll_timer2)&&(!not_t2)){
		clearInterval(current_scroll_timer2);
	}
		
}

function checkGalleryScroll(id){
	if(gallery_scroll == 1){
		disablePage(true);
	}else{
		disablePage(false);
	}
}


function scrollDivImg(id,scale){
	//debug("scrollDivImg<br>",1);
	this_direction = (gallery_img_inc < 0) ? "right":"left";
	if((gallery_can_scroll_img == 1) &&(this_direction == gallery_sb_direction)){
		
		div1 = gallery_containers[id][0];
		div2 = gallery_containers[id][2];
		div_container2 = gallery_containers[id][3];
		this_l = parseInt(div2.style.left) + gallery_img_inc;
		preview_w = parseInt(div_container2.clientWidth);
		preview_img_w = parseInt(div2.clientWidth);
			
			
		//debug(this_l+",");
		//check this_l 
		if(gallery_img_inc < 0){
			if(this_l < (preview_w - preview_img_w)){
				this_l = (preview_w - preview_img_w);
				gallery_can_scroll_img = 0;
				gallery_img_inc = 0;
				stopGalleryAutoScroll(id)
			}
		}
		
		if(gallery_img_inc > 0){
			if(this_l > 0){
				this_l = 0;
				gallery_can_scroll_img = 0;
				gallery_img_inc = 0;
				stopGalleryAutoScroll(id)
			}
		}
		
		div2.style.left = this_l +"px";
		//debug("<br>"+div2.style.left);
		gallery_containers[id][5]= parseInt(gallery_containers[id][5]) + Math.round(gallery_img_inc*scale);
		
		
	}else{
		if(current_scroll_timer2){
			clearInterval(current_scroll_timer2);
		}
		stopGalleryAutoScroll(id);
	}
	
}


function stopGalleryAutoScroll(id){
	if(window["auto_scroll_g_"+id]){
		clearInterval(window["auto_scroll_g_"+id]);
	}
	
	gallery_img_inc_speed = gallery_global_inc_speed;
}
function startGalleryAutoScroll(id){
	if(gallery_containers[id]){	
		auto_scroll_g_x += auto_scroll_inc;
		x = auto_scroll_g_x
		scrollDivBar(id,null,x);
		clearScrollDivBar(id);
		window["auto_scroll_g_"+id] = setTimeout("startGalleryAutoScroll('"+id+"')",gallery_img_inc_speed);
	}
	
}
function galleryJumpTo(id){
	
	if(gallery_containers[id]){	
		x = tempX - gallery_scroll_bar_offset_x;
		scrollDivBar(id);
		clearScrollDivBar(id);
	}
}

function scrollDivBar(id,firstdown,x){
	
	
	gallery_scroll = 1;
	document.documentElement.style.cursor='move';
	
	if(!x){
		x = tempX - gallery_scroll_bar_offset_x;
	}
	//document.getElementById('background_header_div').innerHTML = x;
	if(document.getElementById('x_pos_'+id)){
		document.getElementById('x_pos_'+id).innerHTML = x;
	}
	y = tempY;
	
	if(gallery_containers[id]){	
				
		div1 = gallery_containers[id][0];
		div_container1 = gallery_containers[id][1];
		div2 = gallery_containers[id][2];
		div_container2 = gallery_containers[id][3];
		scroll_div = gallery_containers[id][4];
		
		
		l = parseInt(scroll_div.style.left);
		last_l = l;
		
		if(firstdown){
			gallery_start_l = x;
			gallery_sb_start_l = l;
		}
		
		main_w = parseInt(div_container1.clientWidth);
		main_h = parseInt(div_container1.style.height);
		main_img_w = parseInt(div1.style.width);// - gallery_scroll_bar_offset_x;
		main_img_l = parseInt(div1.style.left);
		
		preview_w = parseInt(div_container2.clientWidth);
		preview_h = parseInt(div_container2.style.height);
		preview_img_w = parseInt(div2.style.width);
		preview_img_l = parseInt(div2.style.left);
		
		scroll_div_w = parseInt(scroll_div.style.width);
		if(scroll_div.style.border){
			scroll_div_w+= (is_IE == 1)? parseInt(scroll_div.style.borderRightWidth)*2 : parseInt(scroll_div.style.borderRightWidth);
		}else if (is_IE != 1){
			scroll_div_w -= 2;
		}
		
		//set min_x and max_x
		min_x = 0;
		max_x = (preview_img_w < preview_w) ? preview_img_w  :preview_w;
		if(is_IE == 0){
			max_x -=2;
		}
		l = gallery_sb_start_l + (x - gallery_start_l);
		
		scale = main_img_w / preview_img_w;
		
		gallery_sb_direction = (l < last_l) ? "left":"right";
		
		if(l < min_x){
			l = min_x;
			if(preview_img_w > preview_w){
					gallery_can_scroll_img = 1;
					gallery_img_inc = 10;
					scrollDivImg(id,scale);
					//current_scroll_timer2 = setInterval("scrollDivImg('"+id+"',"+scale+")",gallery_img_inc_speed);
			}
		}
		
		if(( l+scroll_div_w) > max_x){
			l = max_x - scroll_div_w;
			
			if(preview_img_w > preview_w){
				gallery_can_scroll_img = 1;
				gallery_img_inc = -10;
				scrollDivImg(id,scale);
				//current_scroll_timer2 = setInterval("scrollDivImg('"+id+"',"+scale+")",gallery_img_inc_speed);
			}
			
		}
		scroll_div.style.left = l+ "px";
		
		div1_offset = parseInt(gallery_containers[id][5]);
		
		div1_l = (0 - Math.round((l+2)*scale) + div1_offset);
		div1_l_max = (0-main_img_w+main_w);
		
		debug(div1_l+","+div1_l_max,1);
		
		div1.style.left = (div1_l < div1_l_max)? div1_l_max+ "px" : div1_l+ "px";
		debug("<br>"+div1.style.left);
		if((l==0)&&(parseInt(div2.style.left) == 0)){
			div1.style.left = "0px";
		}
		if((div1) && (div_container1) && (div2) && (div_container2) && (scroll_div)){
			current_scroll_timer = setTimeout("scrollDivBar('"+id+"')",1);
		}
	
	}
	
}


/**************************
Thumbnail Gallery Functions
***************************/
var thumbnail_popups = Array();
var popup = null;
var thumbnail_popup_on = 0;

function setupThumbnailGallery(html,id,popup_on,border_color){
	
	thumbnail_popup_on = popup_on;
	if((document.getElementById('popup')) && (popup === null)){
		popup = document.getElementById('popup');
		if(html){
			popup.innerHTML = decode64(html);
			
		}
	}
	
	var j = 0;
	for (var i in thumbnail_popups[id])
	{		
		img = document.getElementById('img_'+j+'_'+id);
		if(img){
			img.className='alpha_100';
			var popup_html = thumbnail_popups[id][i]['popup'];
			if(popup_html != ""){
				img.onmouseover= function(){this.style.cursor='pointer';this.className='alpha_40';};
				img.onmouseout=function(){this.className='alpha_100';}
			}
		}
		j++;
	}
	
}


function loadPopUpHtml(id,n){
	
	var div = document.getElementById('popup_html');
	if((popup)&&(div)){
		
		var popup_html = thumbnail_popups[id][n]['popup'];
		if(popup_html != ""){
			popup_html = decode64(popup_html);
			div.innerHTML = popup_html ;
		}
		var bool = (popup_html != "") ? true:false;
		
		showHTMLPopUp(bool)
		
	}
	
}

function closeHTMLPopUp(){
	showHTMLPopUp(false);
}


function showHTMLPopUp(bool){
		if((popup)){
			popup.style.display = (bool) ? "block":"none";
			if(bool){
				centerPopUp();
			}
		}
}


function centerPopUp(){
	if(popup){
		var mcw =  parseInt(document.getElementById('main_page').clientWidth);
		var mch =  parseInt(document.getElementById('main_div').clientHeight);
		
		if((parseInt(document.documentElement.clientHeight) < mch) ){
			mch = parseInt(document.documentElement.clientHeight) + document.documentElement.scrollTop;
		}
		
		var lw = parseInt(popup.clientWidth);
		var lh = parseInt(popup.clientHeight) ;
		popup.style.left =  (Math.round((mcw-lw + parseInt(document.getElementById('left_content').clientWidth) )/2)+ "px") 
		popup.style.top = Math.round((mch-lh)/2) -parseInt(document.getElementById('header').clientHeight)  + "px";
	}
}

/******************************
END Thumbnail Gallery Functions
*******************************/

/******************
Light Box Functions
*******************/
var lightbox = null;
var lightbox_image = null;
var lightbox_back = null;
var lightbox_zoom_back = null;
var lightbox_zoom = null;
var lightbox_zoom_tool = null;
var lightbox_w = 0;
var lightbox_h = 0;
var lightbox_inc_x = 0;
var lightbox_inc_y = 0;
var lightbox_mtw = 0;
var lightbox_mth = 0;
var lightbox_speed = 100;
var lightbox_millisec = 1000;
var lightbox_moving = 0;
var lightbox_images = Array();
var lightbox_img_cache = Array();
var lightbox_mov_int = null;
var lightbox_y_offset = 0;
var lightbox_x_offset = 0;
var lightbox_zoom_scale = 1;
var lightbox_type = 1;
var lightbox_border = 0;

function setupLightBox(html,id,type,border_color){
	
	lightbox_type = type;
	if((document.getElementById('lightbox')) && (lightbox === null)){
		lightbox = document.getElementById('lightbox');
		if(html){
			lightbox.innerHTML = decode64(html);
			
		}
		if(document.getElementById('lightbox_image')){
			lightbox_image = document.getElementById('lightbox_image');
			if(border_color != ""){
				lightbox_image.style.border = "1px solid "+border_color;
				lightbox_border = 1;
			}
		}
		if(document.getElementById('lightbox_back')){
			lightbox_back = document.getElementById('lightbox_back');
			
		}
		if((document.getElementById('lightbox_zoom_'+id))&&(document.getElementById('lightbox_zoom_tool'))){
			lightbox_zoom = document.getElementById('lightbox_zoom_'+id);
			lightbox_zoom_tool = document.getElementById('lightbox_zoom_tool');
		}else{
			lightbox_zoom = null;
		}
		
		if(document.getElementById('lightbox_zoom_back_'+id)){
			lightbox_zoom_back = document.getElementById('lightbox_zoom_back_'+id);
		}else{
			lightbox_zoom_back = null;
		}
		
		loadLightBoxImages(id);
	}
	
}


function loadLightBoxImages(id) {
		
	var j = 0;

	for (var i in lightbox_images[id])
	{
		d = new Date();
		before = d.getTime();
		light_img = decode64(lightbox_images[id][i]['light']);
		image_img = decode64(lightbox_images[id][i]['image'])
		
		w = Math.abs(lightbox_images[id][i]['w']);
		h = Math.abs(lightbox_images[id][i]['h']);
		w2 = Math.abs(lightbox_images[id][i]['w2']);
		h2 = Math.abs(lightbox_images[id][i]['h2']);	
		n = Math.abs(lightbox_images[id][i]['n']);	
		
		lightbox_img_cache[id][j]= {light:null,image:null,w:w,h:h,w2:w2,h2:h2};
		
		lightbox_img_cache[id][j]['light'] = new Image();
		lightbox_img_cache[id][j]['light'] .src = light_img;
		lightbox_img_cache[id][j]['image']   = new Image();
		lightbox_img_cache[id][j]['image'].src = image_img;
		
		
		img = document.getElementById('img_'+j+'_'+id);
		if(img){
			img.className='alpha_100';
			img.onmouseover= function(){this.style.cursor='pointer';this.className='alpha_40';};
			img.onmouseout=function(){this.className='alpha_100';}
		}
		
		j++;
	}
		
}

function loadLightBoxImage(id,n){
		
	clearMoveLightBox();
	clearLightBoxFade();
	
	if(lightbox_img_cache[id][n]){
		img1 = lightbox_img_cache[id][n]['light'];
		img2 = lightbox_img_cache[id][n]['image'];
		w = Math.abs(lightbox_img_cache[id][n]['w']);
		h = Math.abs(lightbox_img_cache[id][n]['h']);
		w2 = Math.abs(lightbox_img_cache[id][n]['w2']);
		h2 = Math.abs(lightbox_img_cache[id][n]['h2']);
		
		lightbox_zoom_scale = w2/w;
		
		if(lightbox){
			if((lightbox_zoom_tool)&&(lightbox_zoom)){
				
				if(lightbox_type == 2){
					lightbox_zoom.style.height = (h) + "px";
					lightbox_zoom.style.top = "11px";
				}
				
				lightbox_zoom_tool.style.width = Math.round(parseInt(lightbox_zoom.style.width) / lightbox_zoom_scale) + "px";
				lightbox_zoom_tool.style.height = Math.round(parseInt(lightbox_zoom.style.height) / lightbox_zoom_scale) + "px";
			}
			
			
			showLightBoxImage(img1,w,h,img2,w2,h2,id);
			showLightBox(true);
			startMouseMove();
			lightbox_mov_int = setInterval("moveLightBoxZoom()",1);
			//centerLightBox();
		}
		
	}
}

function closeLightBox(){
	debug("<br>stopLightBoxZoom()<br>");
	stopLightBoxZoom();
	debug("<br>clearLightBoxFade()<br>");
	clearLightBoxFade();
	debug("<br>clearMoveLightBox()<br>");
	clearMoveLightBox();
	debug("<br>showLightBox(false)<br>");
	showLightBox(false);
	//resizeLightBox(50,50);
}

function showLightBoxImage(img,w,h,img2,w2,h2,id){
	
		if(lightbox_image){
			
			var plus = (lightbox_type == 2) ? 300 : 0;
			var l_style = (lightbox_border == 1)? "style='top:11px;'":"";
			lightbox_image.innerHTML= "<img id='lightbox_current_img' src='"+img.src+"' width='"+w+"' height='"+h+"' "+l_style+" onmouseover='javascript:startLightBoxZoom();'>";
			if(lightbox_type == 2){
				lightbox_image.innerHTML += "<div id=\"lightbox_txt\">Move your mouse over the image to view in more detail.</div>";
			}
			
			changeOpac(0, 'lightbox_current_img');
			if(lightbox_zoom){
				lightbox_zoom.innerHTML= "<img id='lightbox_zoom_img' src='"+img2.src+"' width='"+w2+"' height='"+h2+"'>";
			}
			
			lightbox_w = w+plus;
			lightbox_h = h;
			
			clearMoveLightBox();
			resizeLightBox(w+plus,h);
			
		}
	
}

function clearMoveLightBoxZoom(){
	if(lightbox_mov_int){
		clearInterval(lightbox_mov_int);
		lightbox_mov_int = null;
	}
}

function moveLightBoxZoom(){
	
	//if((lightbox_zoom_tool)&&(lightbox_zoom_tool.style.display=="block")){
		
		lightbox_y_offset = parseInt(lightbox.style.top) ;
		x = tempX - lightbox_x_offset- Math.round((parseInt(document.documentElement.clientWidth) - parseInt(document.getElementById('main_page').clientWidth))/2);
		y = tempY  - lightbox_y_offset - parseInt(document.getElementById('header').clientHeight);
				
		l = x - Math.round(parseInt(lightbox_zoom_tool.style.width)/2);
		t = y - Math.round(parseInt(lightbox_zoom_tool.style.height)/2);
		
		debug("tempY:"+tempY+"<br>y:"+y+"<br>lightbox_y_offset:"+lightbox_y_offset+"<br>top:"+t+"<br>"+document.documentElement.scrollTop,1);
		 
		min_x = 10;
		max_x = (lightbox_type == 2) ? parseInt(lightbox_image.style.width)-300 - parseInt(lightbox_zoom_tool.style.width) + 8 : parseInt(lightbox_image.style.width) - parseInt(lightbox_zoom_tool.style.width) + 8;
		   
		if(l < min_x){
			l = min_x;
		}
		if(l > max_x){
			l = max_x;
		}
		   
		min_y = 10;
		max_y = parseInt(lightbox_image.style.height) - parseInt(lightbox_zoom_tool.style.height) + 9;
		   
		if(t < min_y){
			t = min_y;
		}
		if(t > max_y){
			t = max_y;
		}
		   
		zoom_l = (10*lightbox_zoom_scale) - (l*lightbox_zoom_scale);
		zoom_t = (10*lightbox_zoom_scale) - (t*lightbox_zoom_scale);
		   
		lightbox_zoom_tool.style.left = l +"px";
		lightbox_zoom_tool.style.top = t +"px";
			
		if(document.getElementById('lightbox_zoom_img')){
			 document.getElementById('lightbox_zoom_img').style.left = zoom_l +"px";
			 document.getElementById('lightbox_zoom_img').style.top = zoom_t +"px";
		}
		
		var lb_max_x = (lightbox_type == 2) ? (parseInt(lightbox_image.style.width))+10 - 300 : (parseInt(lightbox_image.style.width))+10
	
		if( (x < 10)||(x > lb_max_x) || (y < 10)||(y > (parseInt(lightbox_image.style.height))+10) ){
			stopLightBoxZoom()
		}
								  
								  
		
	//}
	
}

function startLightBoxZoom(){
	
	if((lightbox_zoom)&&(lightbox_zoom_tool)){
		showLightBoxZoom(true);
	}
	
}

function stopLightBoxZoom(){
	
	if((lightbox_zoom)&&(lightbox_zoom_tool)){
		//clearMoveLightBoxZoom();
		showLightBoxZoom(false);	
	}
	
}

function showLightBoxZoom(bool){
	if(lightbox_zoom){
		lightbox_zoom.style.display = (bool) ? "block":"none";
	}
	if(lightbox_zoom_tool){
		lightbox_zoom_tool.style.display = (bool) ? "block":"none";
	}
	if(lightbox_zoom_back){
		lightbox_zoom_back.style.display = (bool) ? "block":"none";
	}
	
}

function showLightBox(bool){
	if(lightbox){
		if(bool){
			centerLightBox();
		}
		lightbox.style.display = (bool) ? "block":"none";
	}
}

function moveLightBox(){
	
		w = lightbox_w;
		h = lightbox_h;	
		
		mcw = (lightbox_type == 1)? parseInt(document.getElementById('main_content').clientWidth) : parseInt(document.getElementById('main_page').clientWidth);
		mch = (lightbox_type == 1)? parseInt(document.getElementById('main_content').clientHeight) : parseInt(document.getElementById('main_div').clientHeight);
		
		if((lightbox_type == 2) && (parseInt(document.documentElement.clientHeight) < mch)){
			mch = parseInt(document.documentElement.clientHeight) + (document.documentElement.scrollTop*2);
		}
		if((cw == lightbox_mtw)&&(ch == lightbox_mth)){
			clearMoveLightBox();
			return false;
		}
		
		if((lightbox_inc_x != 0)&&(cw != lightbox_mtw)){
			w = (cw +lightbox_inc_x);
			if(((lightbox_inc_x > 0) && (w > lightbox_mtw)) || ((lightbox_inc_x < 0) && (w < lightbox_mtw)) ){
					w = Math.abs(lightbox_mtw);
			}
			lightbox_image.style.width = w+"px";
			lightbox_back.style.width = (w+20)+"px";
			lightbox.style.left = (lightbox_type == 1)? (Math.round((mcw-(w+20))/2) + parseInt(document.getElementById('left_content').clientWidth) + "px") : (Math.round((mcw-(w+20))/2) + "px");
			lightbox_x_offset = parseInt(lightbox.style.left);
		}
		
		if((lightbox_inc_y != 0)&&(ch != lightbox_mth)){
			h = (ch +lightbox_inc_y);
			if(((lightbox_inc_y > 0) && (h > lightbox_mth)) || ((lightbox_inc_y < 0) && (h < lightbox_mth)) ){
					h = Math.abs(lightbox_mth);
			}
			lightbox_image.style.height = h+"px";
			lightbox_back.style.height = (h+20)+"px";
			lightbox.style.top = Math.round((mch-(h+20))/2)  + "px";
			
		}
		
	
}	

function clearLightBoxFade(){
	
	for(i = 0; i <= 100; i++) { 
		if(window['opt_lb_'+i]){
			clearTimeout(window['opt_lb_'+i]);
		}
	}
}


function clearMoveLightBox(){
	
	for(i = 0; i <= lightbox_speed; i++) { 
		if(window['move_lb_'+i]){
			clearTimeout(window['move_lb_'+i]);
		}
	}
	lightbox_moving  = 0;
}

function resizeLightBox(w,h){
		
		
		if((lightbox_back)&&(lightbox_image)){
			lightbox_mtw = w;
			lightbox_mth = h;
			
			var speed = Math.round(lightbox_millisec / lightbox_speed); 
			var timer = 0; 
						
			cw = parseInt(lightbox_image.style.width);
			ch = parseInt(lightbox_image.style.height);
			
			lightbox_inc_x = ((lightbox_mtw - cw));///lightbox_speed) ; 
			lightbox_inc_y = ((lightbox_mth - ch));///lightbox_speed) ; 
		
			
			if(lightbox_inc_x > 0){
				lightbox_inc_x += 1;
			}else if(lightbox_inc_x < 0){
				lightbox_inc_x -= 1;
			}
			
			if(lightbox_inc_y > 0){
				lightbox_inc_y += 1;
			}else if(lightbox_inc_y < 0){
				lightbox_inc_y -= 1;
			}
			
			lightbox_inc_x  = Math.round(lightbox_inc_x);
			lightbox_inc_y  = Math.round(lightbox_inc_y);
			
			
			
			lightbox_moving  = 1;
			//move image
			/*for(i = 0; i <= lightbox_speed; i++) { 
				window['move_lb_'+i] = setTimeout("moveLightBox()",(timer * speed)); 
				timer++; 
			}*/
			
			moveLightBox();
			
			
			
			debug("START<br>",1);
			
			/*for(i = 0; i <= 100; i++) { 
				window['opt_lb_'+i] = setTimeout("changeOpac("+i+", 'lightbox_current_img')",(i* speed));  
			}*/
			changeOpac(100, 'lightbox_current_img');
			
			
			
			
			
		}
	
}



function centerLightBox(){
	if((lightbox)){
		mcw =  parseInt(document.getElementById('main_page').clientWidth);
		mch = parseInt(document.getElementById('main_content').clientHeight);
		
		if((lightbox_type == 2) && (parseInt(document.documentElement.clientHeight) < mch)){
			mch = parseInt(document.documentElement.clientHeight) + (document.documentElement.scrollTop*2);
		}
		
		var lw = lightbox_w + 20;
		var lh = lightbox_h + 20;
		//alert(mcw+" > "+lw+"\r\n"+mch+" > "+lh);
		lightbox.style.left = (Math.round((mcw-lw)/2))  + "px";//(lightbox_type == 2)? (Math.round((mcw-lw)/2))  + "px" : (Math.round((mcw-lw)/2) + parseInt(document.getElementById('left_content').clientWidth) + "px") 
		lightbox.style.top = Math.round((mch-lh)/2) + "px";
	}
}

/******************
END Light Box Functions
*******************/

/*****************
START ROTATOR BOX
*****************/

var rotator_box_items = Array();
function rotateBox(key,delay){
	div = document.getElementById('pr_'+key);
	if((rotator_box_items[key])&&(div));{
		no_items = Math.abs(rotator_box_items[key]['no_items']);
		current_item = Math.abs(rotator_box_items[key]['current_item']);
		h = Math.abs(rotator_box_items[key]['h']);
		if(current_item >= no_items){
			current_item = 0;
		}
		rotator_box_items[key]['current_item'] = current_item + 1;
		try{
			div.style.top = (0- (current_item * h)) + "px";
			setTimeout("rotateBox('"+key+"',"+delay+")",delay);
		}catch(e){
		}
	}
	
}

/*****************
END ROTATOR BOX
*****************/
var selected_current_back_color = "";
var selected_current_font_color = "";
function changeTrans(field,bool){
	
	if(bool){
		selected_current_back_color = field.style.backgroundColor;
		selected_current_font_color = field.style.color;
	}
	
	field.style.backgroundColor = (bool) ? "#ffffff" : selected_current_back_color;
	field.style.color = (bool) ? "#333333" : selected_current_font_color;
	
}



function depth(obj){
		var level = 1;
		while(obj.parentNode.className != listClass){
			if (obj.tagName == "UL") level++;
			obj = obj.parentNode;
		};
		return level;
};	
	
var expandTo = 1;
var listClass = "bloglinks";
function toggleList(li){
	
	//alert(li);
	var elements = li.getElementsByTagName("ul");
	//alert(elements.length);
	
	//if(li.getElementsByTagName("ul").length > 0){
			
			//var ul = li.getElementsByTagName("ul")[0];
			//ul.style.display = (depth(ul) <= expandTo) ? "block" : "none";
			//li.className = (depth(ul) <= expandTo) ? "expanded" : "collapsed";
	
	//}	

}





/*****
DEBUG
*****/

function debug(str,replace_all){
	div = document.getElementById('debug')
	if(div){
		 div.innerHTML = (replace_all) ? str : div.innerHTML+str;
	}
}





// Flash Player Version Detection - Rev 1.6
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
			//alert("flashVer="+flashVer);
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "id":
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}








