function changechild(parent_name,child_name)
{
	cat_id = document.getElementById(parent_name).value;
     //de-activate all dropdowns
	  var intIndex = 0;
	  // Loop through all the options
	  for( intIndex = 0; intIndex < document.getElementById(parent_name).options.length; intIndex++ )
	  {
	  	i = document.getElementById(parent_name).options[intIndex].value;
		if (document.getElementById('testing')) { document.getElementById('testing').value=intIndex; }
        if (document.getElementById(child_name+i))
        {
			document.getElementById(child_name+i).style.display = "none";
			//de-activate all grand childen also
			for( intIndex2 = 0; intIndex2 < document.getElementById(child_name+i).options.length; intIndex2++ )
			  {
	  			k = document.getElementById(child_name+i).options[intIndex2].value;
				if (document.getElementById('Style'+k)) {	document.getElementById('Style'+k).style.display = "none"; }
				if (document.getElementById('Size'+k)) {	document.getElementById('Size'+k).style.display = "none"; }
				if (document.getElementById('Brand'+k)) {	document.getElementById('Brand'+k).style.display = "none"; }
				if (document.getElementById('Condition'+k)) {	document.getElementById('Condition'+k).style.display = "none"; }
				if (document.getElementById('Fabric'+k)) {	document.getElementById('Fabric'+k).style.display = "none"; }
				if (document.getElementById('Color'+k)) {	document.getElementById('Color'+k).style.display = "none"; }
				if (document.getElementById('GarmentCare'+k)) {	document.getElementById('GarmentCare'+k).style.display = "none"; }

			  }
					 
			//**********************************
        }
	  }
        //activate the selected category's sub-category list
	document.getElementById(child_name+cat_id).style.display = "";
	
	return 0;
}
function changechildren(parent_id,child1,child2,child3,child4,child5,child6,child7,child8,child9,child10,rubish)
{
	cat_id = document.getElementById(parent_id).value;
	var children=new Array(10);
		children[1]=child1;
		children[2]=child2; 
		children[3]=child3; 	
		children[4]=child4;
		children[5]=child5; 	
		children[6]=child6; 
		children[7]=child7; 
		children[8]=child8; 
		children[9]=child9; 	
		children[10]=child10;
		
	var intIndex = 0;
	
	for (counter=1;counter<=10;counter++)	
	{
		 //de-activate all dropdowns
		if (children[counter]!='')
		{
			for( intIndex = 0; intIndex < document.getElementById(parent_id).options.length; intIndex++ )
			{
				i = document.getElementById(parent_id).options[intIndex].value;
				//alert(children[counter]+i);			
				if (document.getElementById(children[counter]+''+i))
				{
				   document.getElementById(children[counter]+''+i).style.display = "none";
				}
			}
				//activate the selected category's sub-category list
			if (document.getElementById(children[counter]+''+cat_id))
			{
				document.getElementById(children[counter]+''+cat_id).style.display = "";
			}
		}
	}

}
function confirmDelete(delUrl)
{
	if (confirm("Are you sure you want to delete this item?"))
	{
		document.location = delUrl;
	}
}
var swapglob = 0;
function custom_swap_add_item(listing_id,listing_descr)
{
	if (swapglob<10)
	{
		document.getElementById('swapbutton').disabled = false;
		document.getElementById('my_item_box'+listing_id).style.display = 'none';
		document.getElementById('swap_noitem').style.display = 'none';
		
		if (document.getElementById('choice'+listing_id+'_div'))
		{
			document.getElementById('choice'+listing_id+'_div').style.display = '';
			$flag = true;
			$counter = 0;
			while ($flag)
			{
				$counter = $counter + 1;
				if (document.getElementById('choice'+$counter+'_descr'))
				{
					if (document.getElementById('choice'+$counter+'_descr').value=='')
					{
						document.getElementById('choice'+$counter+'_descr').value = listing_descr;
						document.getElementById('choice'+$counter+'_id').value = listing_id;
						$flag = false;
						swapglob = swapglob + 1;
					}
				}
				
				if ($counter==11) { $flag = false;}
			}		
		}
	}
	else
	{
		alert("Maximum number of 10 items per swap reached.");
	}
}

function custom_hideDIV(targetDIV)
{
	if (document.getElementById(targetDIV))
	{
	    document.getElementById(targetDIV).style.display="none";
	}
}
function custom_showDIV(targetDIV)
{
	if (document.getElementById(targetDIV))
	{
		document.getElementById(targetDIV).style.display="";
	}
}
function custom_showHIDEDIV(ownDIV,targetDIV)
{
	if (document.getElementById(ownDIV,targetDIV))
	{
		if (document.getElementById(targetDIV).style.display=="none")
		{ 
		document.getElementById(targetDIV).style.display=""; 
		document.getElementById(ownDIV).style.display="none";
		}
		else if (document.getElementById(ownDIV).style.display=="none")
		{ 
		document.getElementById(ownDIV).style.display=""; 
		document.getElementById(targetDIV).style.display="none";
		}

	}
}

function custom_clearinput(targetDIV)
{
	if (document.getElementById(targetDIV))
	{
	    document.getElementById(targetDIV).value="";
	}
}
function custom_clearinput_swap($lisitng_id)
{
	for (counter=1;counter < 11;counter++)
	{
		if (document.getElementById('choice'+counter+'_descr'))
		{
			if (document.getElementById('choice'+counter+'_id').value==$lisitng_id)
				{
					document.getElementById('choice'+counter+'_descr').value='';
					document.getElementById('choice'+counter+'_id').value = '0';
				}
		}
	}
}
function SelectOptionInList( lstSelectList, intID )
{
	try
	{
		  var intIndex = 0;
		  // Loop through all the options
		  for( intIndex = 0; intIndex < lstSelectList.options.length; intIndex++ )
		  {
				// Is this the ID we are looking for?
				if( lstSelectList.options[intIndex].value == intID )
				{
					  // Select it
					  lstSelectList.selectedIndex = intIndex;
					  // Yes, so stop searching
					  break;
				}
		  }
	}
	catch( expError )
	{
		  alert( "ClientUtilities1.js::SelectOptionInList( ).\n" +
					  "Error:" + expError.number + ", " + expError.description );
	}
} // SelectOptionInList

function custom_change_inbox_bg(hrefid)
{
	document.getElementById('href_inbox').style.backgroundPosition = '0px -30px';
	document.getElementById('href_inbox').style.color = '#1F638A';
	document.getElementById('href_offers_received').style.backgroundPosition = '0px -30px';
	document.getElementById('href_offers_received').style.color = '#1F638A';
	document.getElementById('href_offers_made').style.backgroundPosition = '0px -30px';
	document.getElementById('href_offers_made').style.color = '#1F638A';
	document.getElementById('href_offers_won').style.backgroundPosition = '0px -30px';
	document.getElementById('href_offers_won').style.color = '#1F638A';
	document.getElementById('href_offers_lost').style.backgroundPosition = '0px -30px';
	document.getElementById('href_offers_lost').style.color = '#1F638A';
	
	document.getElementById(hrefid).style.backgroundPosition = '0px 0px';
	document.getElementById(hrefid).style.color = '#000';
}
function custom_change_menu_bg(hrefid)
{
	document.getElementById('menu_feedback_good').style.backgroundPosition = '0px -30px';
	document.getElementById('menu_feedback_good').style.color = '#1F638A';
	document.getElementById('menu_feedback_bad').style.backgroundPosition = '0px -30px';
	document.getElementById('menu_feedback_bad').style.color = '#1F638A';
	
	document.getElementById(hrefid).style.backgroundPosition = '0px 0px';
	document.getElementById(hrefid).style.color = '#000';
}

/****************************************/
function custom_movedivtomouse(e,targetDIV){
    //if (!e) e = window.event;

    var IE = document.all?true:false;
    if (!IE) document.captureEvents(Event.MOUSEMOVE)
    //document.onmousemove = getMouseXY;
    var tempX = 0;
    var tempY = 0;
    
    if (IE)
    { // grab the x-y pos.s if browser is IE
        tempX = event.clientX + document.body.scrollLeft;
        tempY = event.clientY + document.documentElement.scrollTop;
    }
    else
    {  // grab the x-y pos.s if browser is NS
        tempX = e.pageX;
        tempY = e.pageY;
    }
	
    if (tempX < 0){tempX = 0;}
    if (tempY < 0){tempY = 0;}

    document.getElementById(targetDIV).style.left = tempX+"px";
    document.getElementById(targetDIV).style.top = tempY+"px";
    
//    document.getElementById('parentY').value = document.documentElement.scrollTop;
}

function custom_populatelistingtool(divid,htmltext)
{
	htmltext = htmltext.replace('|','"');
	htmltext = htmltext.replace('|','"'); //have to do it for each |
	document.getElementById(divid).style.display = '';
	document.getElementById(divid).innerHTML = htmltext;
    //document.getElementById('tooltip_img').src = document.getElementById('input_tooltip_image_'+listingcount).title;
}
function custom_clearistingtool(divid)
{
	document.getElementById(divid).innerHTML = '';

}
function custom_showDIVmove(targetDIV)
{
    document.getElementById(targetDIV).style.display = '';
}
function custom_pre_swap_message()
{
	alertmsg = "WARNING: By proceeding you are entering into a legal agreement with another iswish.co.nz member. Failure to honour this agreement may result in your membership being withdrawn. Please only proceed if you intend to honour this agreement.";
	var agree=confirm(alertmsg);
	if (agree)
		return true ;
	else
		return false ;
}
/****************************************/
