document.onselectstart = function(){return false;}
document.oncontextmenu = function(){return false;}

function tab_select(o, n){
	var array_info = Array('products_information', 'product_support');
	var tab = document.getElementById('tab-box');
	var tabli = tab.getElementsByTagName('li');
	for($key in array_info){
		$o = document.getElementById(array_info[$key]);
		if($o != undefined) $o.style.display = 'none';
	}
	for($key in tabli){
		tabli[$key].className = '';		
	}
	if(o == 0){
		tabli[0].className = 'hover';	
	}else{
		o.className = 'hover';
	}
	$o = document.getElementById(n);
	if($o != undefined) $o.style.display = '';
}

function newwin(url,h,w) //default:[h=570;w=510;]; one: [h=670;w=610;];
{
	OpenWindow=window.open("", "newwin", "height=570, width=510,toolbar=no,scrollbars="+scroll+",menubar=no"); 
	OpenWindow.document.write("<html><title>www.bikenthings.com</title>") 
	OpenWindow.document.write ("<body>")
	OpenWindow.document.write("<img src="+url+" /><br />")  
	OpenWindow.document.write("<h6>All pictures are the property of  <a href='http://www.bikenthings.com' target='_blank'>www.bikenthings.com</a>. All rights reserved.")
	OpenWindow.document.write("Unauthorized use will result in legal action</h6>")
	OpenWindow.document.write("</body>") 
	OpenWindow.document.write("</html>") 
	OpenWindow.document.close() 
}

function $(o){return document.getElementById(o);}
function g_p(v){var ajaxs = new ajax();ajaxs.url = 'products_description.php?id='+v;ajaxs.callback = function(o){o_p.innerHTML = o.responseText;};ajaxs.send();}
/*
window.onload = function(){
	ulbox = document.getElementsByTagName('ul');
	for(i = 0; i < ulbox.length; i++){
		if(ulbox[i].className == 'smallimg'){
			imgbox = ulbox[i];
			break;
		}
	}
	libox = imgbox.getElementsByTagName('li');
	if(libox.length > 0){
		imgbox.style.width = (libox.length > 3) ? 194 * 3 + 'px' : libox.length * 192 + 'px';
	}
}*/

//for show big img 180x180 - 500x500
function show_big_img(img, bigImgName){
	bigIMG = document.getElementById(bigImgName);
	var body_w = document.body.clientWidth;
	var body_h = document.body.clientHeight+document.body.scrollTop;

    var   x   =   img.offsetLeft,   y   =   img.offsetTop;  
	var m = img;
    while(m=m.offsetParent)
    {
       x   +=   m.offsetLeft;  
       y   +=   m.offsetTop;
    }
	var w = img.offsetWidth;
	var h = img.offsetHeight;	
	var mw = img.style.borderWidth.replace(/px/, '');

		
	var edit_w = bigIMG.width;
	var edit_h = bigIMG.height;
	var edit_border_top_w = bigIMG.style.borderTopWidth.replace(/px/,'');
	var edit_border_bottom_w = bigIMG.style.borderBottomWidth.replace(/px/,'');
	var edit_border_left_w = bigIMG.style.borderLeftWidth.replace(/px/,'');
	var edit_border_right_w = bigIMG.style.borderRightWidth.replace(/px/,'');
	
	var new_x = (body_w-x > edit_w+w) ? x + w : x - edit_w - edit_border_left_w - edit_border_right_w;
	var new_y = (body_h-y > edit_h) ? y : y + h - edit_h - edit_border_top_w - edit_border_bottom_w;
	bigIMG.style.left = new_x+'px';
	bigIMG.style.top = new_y+'px';	

	if(img.src.search(/[0-9]+-s.jpg$/)>0){
		bigIMG.src = img.src.replace(/-s.jpg$/, '-l.jpg');
		bigIMG.style.display = '';
	}
	if(img.src.search(/[0-9]+_sm.jpg$/) > 0 ){
		bigIMG.src = img.src.replace(/_sm.jpg$/, '_lg.jpg');
		bigIMG.style.display = '';
	}
}

function close_big_img(bigImgName){
	bigIMG = document.getElementById(bigImgName);
	bigIMG.src = './images/loading.gif';
	bigIMG.style.display ='none';
}

function checkFormOfferPrice(o){
	o.value = 'offerprice' ;
	var form = o.form;
	var err = '';
	if(form['customer_email'].value == '' || form['customer_phone'].value == ''){
		err = 'You must have Email or Phone filled out.';
	}
	if(form['customer_name'].value == ''){
		err = 'Customer Name is needed.';
	}
	if(form['offer_price'].value == '' ){
		err = 'Offer price is invalid.';
	}
	if(err != ''){
		alert(err);
		return false;
	}
}
