var blockFilterClicked = 'NO';
// jQuery.noConflict(); // NOTE: for mootools
// NOTE: always add jQuery(event) instead of $event
function toggle_me(div_id)
{
	jQuery.noConflict();
	// Self JQuery in SearchBox
	jQuery('#borderblue').hide;
	if (div_id != '#filterdropdown'){
		jQuery('#filterdropdown').hide();
	}
	if (div_id != '#filterdropdown2'){
		jQuery('#filterdropdown2').hide();
	}
	if (div_id != '#filterdropdown3'){
		jQuery('#filterdropdown3').hide();
	}
	if (div_id != '#filterdropdown4'){
		jQuery('#filterdropdown4').hide();
	}	
	jQuery(div_id).toggle('blind',{},500,chk_dottedborder());		
}

function chk_dottedborder(){		
	// get the element of each dropdown in searchbox
	var x = document.getElementById("filterdropdown");
	var x2 = document.getElementById("filterdropdown2");
	var x3 = document.getElementById("filterdropdown3");
	var x4 = document.getElementById("filterdropdown4");
	jQuery.noConflict();
	jQuery('#borderblue').show();
	if (x.style.display == "block" || x2.style.display == "block" || x3.style.display == "block" || x4.style.display == "block")
	{
		jQuery('#borderblue').hide();		
	}else{
		//blockFilterClose = 'YES';
	}	
}
function hidesearch(){	
	// hide the search box in body onclick
	jQuery.noConflict();
	if (blockFilterClicked == 'NO'){
		// FIltersearch.php
		jQuery('#borderblue').hide();
		jQuery('#filterdropdown').hide();
		jQuery('#filterdropdown2').hide();
		jQuery('#filterdropdown3').hide();
		jQuery('#filterdropdown4').hide();
		jQuery('#chooseitem_absolute').hide(); // collection overview in brand_view.php
		jQuery('#white1px').hide(); // collection overview in brand_view.php
	}
	
}
function chk_dottedborder1(){		
	jQuery.noConflict();
	var x = document.getElementById("chooseitem_absolute");
	jQuery('#white1px').show();
	if (x.style.display == "block")
	{
		jQuery('#white1px').hide();
	}

}
function toggle_me1(div_id)
{
	jQuery.noConflict();
	jQuery(div_id).toggle('blind',{},500,chk_dottedborder1());		
}
function blockclicked(){
	blockFilterClicked = 'YES';
}
function blocknotclicked(){
	blockFilterClicked = 'NO';
}
// use in Product.php onmouseover
function imagedetailhide(div_id)
{
	jQuery.noConflict();
	jQuery(div_id).toggle();	
}
function imagedetailhide1(div_id)
{
	jQuery.noConflict();
	jQuery(div_id).toggle('blind');	
}
function hide(div_id)
{
	jQuery.noConflict();
	jQuery(div_id).hide();		
}
function show(div_id)
{
	jQuery.noConflict();
	jQuery(div_id).show();		
}
function hide1(div_id)
{
	jQuery.noConflict();
	jQuery(div_id).hide('blind',500);		
}
function show1(div_id)
{
	jQuery.noConflict();
	jQuery(div_id).show('blind');		
}
function addclass(removeclass,add_class,class_name)
{
	jQuery.noConflict();
	jQuery(removeclass).removeClass(class_name);
	jQuery(add_class).addClass(class_name);
}
function add_twoclass(removeclass,add_class,class_name,removeclass2,add_class2,class_name2)
{
	jQuery.noConflict();
	jQuery(removeclass).removeClass(class_name);
	jQuery(add_class).addClass(class_name);
	
	jQuery(removeclass2).removeClass(class_name2);
	jQuery(add_class2).addClass(class_name2);
}

/* for search autocomplete used in filter search .php*/

	jQuery.noConflict();
 jQuery().ready(function() {
	function findValueCallback(event, data, formatted) {
		//$("<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result");
		if (!data)
		{
			// Submit it to our searchresult.php
			document.searchForm.submit();
		}else{
			// Submit it to our searchresult.php
			document.searchForm.keyword.value = formatted;
			document.searchForm.submit();
		}
	}
	jQuery("#searchField").result(findValueCallback).next().click(function() {
		jQuery(this).prev().search();
		});
			 jQuery("#searchField").autocomplete(searchdata,
				{
					max:15		
				}
			);  

  jQuery('#tfcdiv').show();  
  
});  

 
// url + "?"
function tbshow(title,url,width,height)
{
	if (width != '')
		rWidth = width;
	else
		rWidth = screen.width - 300;
	if (height != '')
		rHeight = height;
	else
		rHeight = screen.height - 350;
	tb_show(title,url + "?keepThis=true&TB_iframe=true&height=" + rHeight + "&width=" + rWidth);
}
// url + "&"
function tbshow1(title,url,width,height)
{
	if (width != '')
		rWidth = width;
	else
		rWidth = screen.width - 300;
	if (height != '')
		rHeight = height;
	else
		rHeight = screen.height - 300;
	tb_show(title,url + "&keepThis=true&TB_iframe=true&height=" + rHeight + "&width=" + rWidth);
}
// Remaining characters left
function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	// otherwise, update "characters left" counter
	else				
		cntfield.value = maxlimit - field.value.length;
}
