function change_class(element){
element.className='cs_nav_ova'
}

function change_class2(element){
element.className=''
}


function border_class(element){
document.getElementById('button_'+element+'1').style.backgroundColor='#bd712d'
document.getElementById('button_'+element+'2').style.backgroundColor='#25190d'
document.getElementById('button_'+element+'2').style.color='#fff'
document.getElementById('button_'+element+'2').style.fontWeight='bold'
}

function border_class2(element){
document.getElementById('button_'+element+'1').style.backgroundColor=''
document.getElementById('button_'+element+'2').style.backgroundColor=''
document.getElementById('button_'+element+'2').style.color='#dcc8b6'
document.getElementById('button_'+element+'2').style.fontWeight='normal'
}

function border_class_2(element){
if(document.getElementById('nav_'+element)){
document.getElementById('nav_'+element).className='border_class'}
}



function border_class2_2(element){
if(document.getElementById('nav_'+element)){
document.getElementById('nav_'+element).className=''
}
}


function display_dd(the_div){
if (document.getElementById('DD_'+the_div)){
document.getElementById('DD_'+the_div).style.visibility='visible';
}}

function hide_dd(the_div){
if (document.getElementById('DD_'+the_div)){
document.getElementById('DD_'+the_div).style.visibility='hidden';
}
}

function switch_prods(product_id, color_id){
document.getElementById('update_image_info').contentWindow.location.replace('http://www.ghurka.com/prod_image_updater.asp?product_id='+product_id+'&color_id='+color_id)

//document.getElementById('update_image_info').src='prod_image_updater.asp?product_id='+product_id+'&color_id='+color_id
}

function switch_prods2(product_id){
the_color_id = document.getElementById('add_multi_variant_'+product_id).value
document.getElementById('update_image_info').contentWindow.location.replace('http://www.ghurka.com/prod_image_updater.asp?product_id='+product_id+'&variant_id='+the_color_id)

//document.getElementById('update_image_info').src='prod_image_updater.asp?product_id='+product_id+'&variant_id='+the_color_id
}

function display_color_dd(){
document.getElementById('color_drop_down').style.visibility='visible';
}


function hide_color_dd(){
document.getElementById('color_drop_down').style.visibility='hidden';
}


function display_price_dd(){
document.getElementById('price_drop_down').style.visibility='visible';
}


function hide_price_dd(){
document.getElementById('price_drop_down').style.visibility='hidden';
}



function filter_color(color_id)
{
var the_dept;
var num_to_show;
var the_prices;
var colors;

	the_dept = document.getElementById('the_dept').value
	num_to_show = document.getElementById('num_to_show').value
	the_prices = document.getElementById('prices').value
	if(document.getElementById('colors').value.indexOf(color_id)<0){
	document.getElementById('colors').value = color_id+','+document.getElementById('colors').value
	}
	colors = document.getElementById('colors').value
	
	document.getElementById('update_listing').src='update_listing.asp?prices='+the_prices+'&color_id='+colors+'&dept_id='+the_dept+'&num_to_show='+num_to_show
}


function filter_color_search(color_id)
{
var the_dept;
var num_to_show;
var the_prices;
var colors;
	
	search_key  = document.getElementById('search_key').value
	the_dept = document.getElementById('the_dept').value
	num_to_show = document.getElementById('num_to_show').value
	the_prices = document.getElementById('prices').value
	if(document.getElementById('colors').value.indexOf(color_id)<0){
	document.getElementById('colors').value = color_id+','+document.getElementById('colors').value
	}
	colors = document.getElementById('colors').value
	
	document.getElementById('update_listing').src='update_search.asp?search_input='+search_key+'&prices='+the_prices+'&color_id='+colors+'&dept_id='+the_dept+'&num_to_show='+num_to_show
}


function remove_color(color_id)
{
the_dept    = document.getElementById('the_dept').value
	colors = document.getElementById('colors').value
	the_colors = colors.replace(color_id+",","")
 	the_prices = document.getElementById('prices').value
	document.getElementById('colors').value  = the_colors
	document.getElementById('update_listing').src='update_listing.asp?prices='+the_prices+'&color_id='+the_colors+'&dept_id='+the_dept+'&num_to_show='+num_to_show

}




function filter_price(price_range)
{

var the_dept;
var num_to_show;
var prices;
var colors;


	the_dept    = document.getElementById('the_dept').value
	num_to_show = document.getElementById('num_to_show').value
	colors      = document.getElementById('colors').value

	
	if(document.getElementById('prices').value.indexOf(price_range)<0){
	document.getElementById('prices').value = price_range+','+document.getElementById('prices').value
	}
	prices = document.getElementById('prices').value
	

	document.getElementById('update_listing').src='update_listing.asp?prices='+prices+'&color_id='+colors+'&dept_id='+the_dept+'&num_to_show='+num_to_show
}



function filter_price_search(price_range)
{

var the_dept;
var num_to_show;
var prices;
var colors;


	the_dept    = document.getElementById('the_dept').value
	num_to_show = document.getElementById('num_to_show').value
	colors      = document.getElementById('colors').value
	search_key  = document.getElementById('search_key').value
	
	if(document.getElementById('prices').value.indexOf(price_range)<0){
	document.getElementById('prices').value = price_range+','+document.getElementById('prices').value
	}
	prices = document.getElementById('prices').value
	

	document.getElementById('update_listing').src='update_search.asp?search_input='+search_key+'&prices='+prices+'&color_id='+colors+'&dept_id='+the_dept+'&num_to_show='+num_to_show
}


function remove_price(price)
{
var the_prices;
var prices;
var colors;
var the_dept;

	the_dept    = document.getElementById('the_dept').value
	prices = document.getElementById('prices').value
	
	colors  = document.getElementById('colors').value
	the_prices = prices.replace(price+",","")
 	

	
	document.getElementById('prices').value  = the_prices
	
	
	document.getElementById('update_listing').src='update_listing.asp?prices='+the_prices+'&color_id='+colors+'&dept_id='+the_dept+'&num_to_show='+num_to_show

}



function remove_price_search(price)
{
var the_prices;
var prices;
var colors;
var the_dept;

	the_dept    = document.getElementById('the_dept').value
	prices = document.getElementById('prices').value
		search_key  = document.getElementById('search_key').value
	colors  = document.getElementById('colors').value
	the_prices = prices.replace(price+",","")
 	

	
	document.getElementById('prices').value  = the_prices
	
	
	document.getElementById('update_listing').src='update_search.asp?prices='+the_prices+'&color_id='+colors+'&dept_id='+the_dept+'&num_to_show='+num_to_show

}


/**************************************************************************************
The below functions fix the onmouseover and onmouseout events.
For ex: if I have a main div container then I mouse between elements in
that div such as <li>'s or a table, etc then the onmouseout event and onmouseover
events are triggering.
onmouseenter and onmouseleave is a MS solution in IE 5.5+ but that does us no good
since won't work in FF

so....use functions below as follows
<div 
onmouseover="if (checkMouseEnter(this, event)) {over();}" 
onmouseout="if (checkMouseLeave(this, event)) {out();}"
style="top:100px">

***************************************************************************************/

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

function checkMouseEnter (element, evt) {
  if (element.contains && evt.fromElement) {
    return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}


function swapimages(the_image)
{document.getElementById('product_image_z').src='images/gallery_large/'+the_image}


function open_pd(product_id,the_image,the_color){
window.open('product_image.asp?product_id='+product_id+'&theImg='+the_image+'&color_id='+the_color,'upwin','width=600,height=900,directories=no,location=no,menubar=yes,scrollbars=no,status=no,toolbar=no,resizable=no')
}

function update_main(the_image)
{
document.getElementById('product_image_zoom').href='images/gallery_huge/'+the_image
document.getElementById('pi_large').src='images/gallery_large/'+the_image
}




function add_to_cart(product_id)
{	
	
qty         = document.getElementById('prod_qty_'+product_id).value
color_id    = document.getElementById('add_multi_variant_'+product_id).value
document.getElementById("AddProd").src="http://www.ghurka.com/addtocart.asp?product_id="+product_id+'&vars='+color_id+'&qty='+qty

//the_left = 0 
the_left2 = document.getElementById('container').offsetLeft;
the_left2 = the_left2 + 812
document.getElementById('cart_contents').style.left = the_left2+'px' 
	
slidedown2('cart_contents')	

window.scroll(0,0);

setTimeout("slideup('cart_contents')",4000)
 						
}



function clear_field(the_text,the_element){
	if (document.getElementById(the_element).value==the_text)
		{
			document.getElementById(the_element).value=''
		}
}


function submit_shipping_change(){
document.getElementById('update_shipping').value='1'
document.purchase_order_form.submit()
}


function update_product_color(product_id,swatch_image){
//document.getElementById('update_listing').src="update_product_swatches.asp?product_id="+product_id+"&sm="+swatch_image
document.getElementById('update_listing').contentWindow.location.replace("update_product_swatches.asp?product_id="+product_id+"&sm="+swatch_image)

}
