/*
# # # # # # #
# 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.goodandtillotson.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 = 500;
var site_float = 2;
var site_width = 0;
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 = 300;
var right_menu_width = 300;
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 = 2;
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 = '#ffffff';
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 = 170;
var header_type = 1;
var can_get_basket = 0;
var footer_bar_height = 100;
var print_header = "<div style=\"width: 100%; position: relative\" align=\"center\"><div style=\"position: relative; height: 100px; text-align: right\" align=\"right\"><img height=\"100\" alt=\"Good & Tillotson Architects\" width=\"288\" border=\"0\" src=\"/uploads/image/header_logos/print_logo.gif\" /></div><div style=\"overflow: hidden; width: 100%; border-bottom: #5bc9e3 1px solid; position: relative; height: 50px; text-align: left\">&nbsp;</div><div style=\"left: 0px; position: absolute; top: 0px; text-align: left\"><div><strong>good and tillotson</strong><br />2 the studios<br />318 chorley old road<br />bolton<br />BL1 4JU</div><div>&nbsp;</div><div>t. <strong>01204 497700</strong><br />f. 01204 497776</div><div>e. info@goodandtillotson.co.uk</div></div></div>";
var gallery_background_random = 0;

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 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){
	
	if(window[id]){
		clearTimeout(window[id]);
	}
	
}

function scrollDiv(id){
	
	if(window[id]){
		clearTimeout(window[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";
				}
				
				window[id] = setTimeout("scrollDiv('"+id+"')",60);
		
			}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){
	
	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')){
		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=/";
		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
		//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 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(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;padding-top:40px;\">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(){
	
	
	window.location.href = global_url;
	
}


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];
			}
				
			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);
							}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);
							
						}
						
						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 loadSWF(f,fs,width,height,path){
	//alert(f);
	//alert(fs);
	
	if((!path)||(path == "")){
		path = global_url+'flash/';
	}
	if(!width){
		width = "100%";
	}
	if(!height){
		height = "100%";
	}
	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="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="noscale" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="'+path+fs+'" loop="false" menu="false" quality="high"  scale="noscale" wmode="transparent" bgcolor="#ffffff" width="'+width+'" height="'+height+'" 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){
	//alert("draw flash");
	//alert(fs);
	document.write(loadSWF(f,fs,w,h,path));
}

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" /><param name="bgcolor" value="#ffffff" /><embed src="'+global_url+'flash/flash_header.swf?global_url='+global_url+'" loop="false" menu="false" quality="high" scale="noscale" wmode="transparent" salign="t" bgcolor="#ffffff" 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(!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" /><param name="bgcolor" value="#ffffff" /><embed src="'+global_url+'flash/flash_header_mc.swf?global_url='+global_url+'" loop="false" menu="false" quality="high" scale="noscale" wmode="transparent" bgcolor="#ffffff" 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>');
	
}



function toggleBackStyle(field,tog){
	
	field.style.backgroundColor = (tog == 1) ? "#ffffff":"transparent";
	field.style.color = (tog == 1) ? "#000000": top_bar_font_color;
	
	
}

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

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 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 #5bc9e3";
		  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 #5bc9e3";
				  
		  }
		  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";
	
}




function resizePage(){
		
		//return false;
		h = parseInt(document.documentElement.clientHeight);
		w = parseInt(document.documentElement.clientWidth);
		
		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";
				}
				
				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)+2;
					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-2) > 100) ? (w-left_w-right_w-2) : 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{
			
				/*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 ;
				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);
					
					 
				}
				
				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);
				}
				
				if(document.getElementById('right_content')){
					 option_y = parseInt(document.getElementById('right_content').clientHeight);
				}
				
				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 = (0-t_y- footer_h-4) +"px";
								}
								
								if(document.getElementById('main_page_back')){
									document.getElementById('main_page_back').style.height = (t_y  + header_h + header_menu_h + footer_h+ 4) +"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 = (0- (h - header_menu_h-header_h)) +"px";
								}
								
								if(document.getElementById('main_page_back')){
									document.getElementById('main_page_back').style.height = (h) +"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){
									
										
										
										if(document.getElementById('main_content')){
											document.getElementById('main_content').style.top  = (flash_h>0) ? flash_h+"px" : "1px";
											//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  =  "1px";
											//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 =  "1px";
											//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 = (0- (h-2)) +"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" : "1px";
											//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  = "1px";
											//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 =  "2px";
											//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) +"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){
		}
	
		
		

}


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(){
	
	showLoading()
	document.getElementById('main_frame').src = global_url+"scripts/checkout.php";
	
	load_side_only = 1;
	
}

function viewBasket(){
	
	showLoading()
	document.getElementById('main_frame').src = global_url+"scripts/pages.php?view_basket";


}

function memberLogin(type,details,reload_page,is_member,is_logged_in){
	
	//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();
			}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 != ""){
						document.getElementById('main_frame').src = global_url+current_page.substr(1);
					}
				}
			}else{
				memberStatus(0,0,'');
				if(Math.abs(reload_page) == 1){
					if(current_page != ""){
						document.getElementById('main_frame').src = global_url+current_page.substr(1);
					}
				}
			}
			
		}
		
		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 Account";

function memberStatus(is_member,is_logged_in,member_name){
	
	if(mem_allow_logon == 1){
		
		txt = "";
		if(is_member == 1){
			txt = "Welcome "+member_name;
		}
		if(is_logged_in == 0){
			txt += "<a onmouseover=\"javascript:this.style.cursor='pointer';\" onclick=\"javascript:memberLogin(1);\"  style=\"color:"+top_bar_font_color+"\">";
			txt += (is_member == 1)? "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;"+mem_logon_text : mem_logon_text;
			txt += "</a>";
		}else if(is_member == 1){
			txt += "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a onmouseover=\"javascript:this.style.cursor='pointer';\" onclick=\"javascript:memberLogin(4);\"  style=\"color:"+top_bar_font_color+"\">"+mem_logon_text+"</a>";
			txt += "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a onmouseover=\"javascript:this.style.cursor='pointer';\" onclick=\"javascript:memberLogin(0,'',1);\"  style=\"color:"+top_bar_font_color+"\">Log&nbsp;Out</a>";
		}
		
		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(){
	
	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 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(member_p,non_member_p){
	
	logged_on = 0;
	theCookie=""+document.cookie;
	cookieName = "is_member";
	show_calendar = 1;
		
	ind=theCookie.indexOf(cookieName);
		
 	if (ind==-1 || cookieName=="") {
			logged_on = 0;
	}else{
			ind1=theCookie.indexOf(';',ind);
			if (ind1==-1) {
				ind1=theCookie.length; 
			}
			val =  unescape(theCookie.substring(ind+cookieName.length+1,ind1));
			if(val == '1'){
					logged_on = 1;
			}else{
					logged_on = 0;
			}
			
	}
	
	closeAllMenus();
	
	if((logged_on == 0) && (non_member_p)){
			document.getElementById('main_frame').src = global_url+"scripts/pages.php?p="+non_member_p;
	}
	
	if((logged_on == 1) && (member_p)){
			document.getElementById('main_frame').src = global_url+"scripts/pages.php?p="+member_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;
								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];	
		
									
							//if(menu_can_move == 0){
		
		
										if(height > 15){
		
													h = height;
		
													//work out left
													l = parseInt(document.getElementById('main_menu').style.left) + dropdown_menu_left_offset;
													for(b=1;b<(num);b++){
														this_w = parseInt(document.getElementById("main_btn_"+num).clientWidth) //+ (1);
														l +=this_w;
													}
		
													//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;
													
													//alert(l+"\r\n"+w+"\r\n"+avail+"\r\n"+w);
		
													if(avail < w){
														document.getElementById('menu_'+m).style.left = (l - (w - avail) - 1) + "px";
													}else{
														document.getElementById('menu_'+m).style.left = (l) + "px";
													}
													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=0;i<total_menus;i++){
			this_m = "menu_"+(i+1);
			if(document.getElementById(this_m)){
					
					if((menu) && (menu == i)){
					}else if(current_menu == (i+1)){
					}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)){
			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)){
		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;
	
}



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() {
	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);
	}
	//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]);
		}
	}
	changeOpac(0, imageid);
	document.getElementById(imageid).src = current_image_url;
	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;
	}
	
	//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) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")";
	
	if(document.getElementById('debug_txt')){
		document.getElementById('debug_txt').innerHTML += 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";
		}
}


/***********************
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;
//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){
	
	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).style.height);
			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);
			
			scale = main_w/main_h;
			
			scrollbar_w = Math.round((scrollbar_h-10) * 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";
						
					}
					
						
					scroll_bar.style.top =  (main_h + 3) + "px";
					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){
	
	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);
			
		//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";
		
		gallery_containers[id][5]= parseInt(gallery_containers[id][5]) + Math.round(gallery_img_inc*scale);
		
		current_scroll_timer2 = setTimeout("scrollDivImg('"+id+"',"+scale+")",gallery_img_inc_speed);
	}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];
		div1_offset = parseInt(gallery_containers[id][5]);
		
		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);
		scroll_div_w+= (is_IE == 1)? parseInt(scroll_div.style.borderRightWidth)*2 : parseInt(scroll_div.style.borderRightWidth);
		
		
		//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 = 1;
					scrollDivImg(id,scale);
			}
		}
		
		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 = -1;
				scrollDivImg(id,scale);
			}
			
		}
		scroll_div.style.left = l+ "px";
		div1.style.left = (0 - Math.round((l+2)*scale) + div1_offset)+ "px";
		
		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);
		}
	
	}
	
}


/******************
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;

function setupLightBox(html,id){
	
	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(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 = decode64(lightbox_images[id][i]['image']);
		lightbox_img_cache[id][j]['image']   = new Image();
		lightbox_img_cache[id][j]['image'].src = decode64(lightbox_images[id][i]['image']);
		
		
		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)){
				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);
			//centerLightBox();
		}
		
	}
}

function closeLightBox(){
	stopLightBoxZoom();
	clearLightBoxFade();
	clearMoveLightBox();
	showLightBox(false);
	resizeLightBox(50,50);
}

function showLightBoxImage(img,w,h,img2,w2,h2,id){
	
		if(lightbox_image){
			lightbox_image.innerHTML= "<img id='lightbox_current_img' src='"+img.src+"' class='alpha_0' width='"+w+"' height='"+h+"' onmouseover='javascript:startLightBoxZoom();'>";
			changeOpac(0, 'lightbox_current_img');
			if(lightbox_zoom){
				lightbox_zoom.innerHTML= "<img id='lightbox_zoom_img' src='"+img2.src+"' width='"+w2+"' height='"+h2+"'>";
			}
			clearMoveLightBox();
			resizeLightBox(w,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")){
			
		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);
		   
		min_x = 10;
		max_x = 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) + 8;
		   
		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";
		}
		
		if( (x < 10)||(x > (parseInt(lightbox_image.style.width))+10) || (y < 10)||(y > (parseInt(lightbox_image.style.height))+10) ){
			stopLightBoxZoom()
		}
								  
								  
		
	}
	
}

function startLightBoxZoom(){
	
	if((lightbox_zoom)&&(lightbox_zoom_tool)){
		startMouseMove();
		lightbox_mov_int = setInterval("moveLightBoxZoom()",1);
		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){
		lightbox.style.display = (bool) ? "block":"none";
	}
}

function moveLightBox(){
	
		cw = parseInt(lightbox_image.style.width);
		ch = parseInt(lightbox_image.style.height);	
		
		mcw = parseInt(document.getElementById('main_content').clientWidth);
		mch = parseInt(document.getElementById('main_content').clientHeight);
		
		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 = Math.round((mcw-(w+20))/2) + parseInt(document.getElementById('left_content').clientWidth) + "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";
			lightbox_y_offset = parseInt(lightbox.style.top);
		}
		
		
		
		
	
	
}	

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++; 
			}
			
			
			
			for(i = 0; i <= 100; i++) { 
				window['opt_lb_'+i] = setTimeout("changeOpac("+i+", 'lightbox_current_img')",(i* speed));  
			}
			
			
		}
	
}



function centerLightBox(){
	
	if((lightbox)&&(lightbox.style.display=='block')){
		mcw = parseInt(document.getElementById('main_content').clientWidth);
		mch = parseInt(document.getElementById('main_content').clientHeight);
		lw = parseInt(lightbox.clientWidth);
		lh = parseInt(lightbox.clientHeight);
		
		lightbox.style.left = Math.round((mcw-lw)/2) + parseInt(document.getElementById('left_content').clientWidth) + "px";
		lightbox.style.top = Math.round((mch-lh)/2) + "px";
	}
	
}





















