//Overwrite Validation Function in validation.js
Validation.addAllThese([
		['validate-cemail', 'Please make sure your emails match.', function(v) {
		        if ($('email')) {
		            var email = $('email');
		        }
		        else {
		            var email = $$('.validate-email').length ? $$('.validate-email')[0] : '';
		        }
		        var cemail = $('cemail') ? $('cemail') : $$('.validate-cemail')[0];
		            return (email.value == cemail.value);
		        }],
        ['validate-zip-ca', 'Please enter a valid zip code.', function(v) {
            return Validation.get('IsEmpty').test(v) || /^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$/.test(v);
            }],
		 ['validate-phoneUS', 'Please enter a valid number. <br>For example 1234567890 or 222 555 1212, 222-555-1212, (222) 555 1212, (222) 555-1212.', function(v) {
		        return Validation.get('IsEmpty').test(v) || /^(?:\([0-9]\d{2}\)\ ?|[0-9]\d{2}(?:\-?|\ ?))[0-9]\d{2}[- ]?\d{4}$/.test(v);
		}]
]);

function xstooltip_findPosX(obj) 
{
  var curleft = 0;
  if (obj.offsetParent) {
    while (obj.offsetParent) {
            curleft += obj.offsetLeft;
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function xstooltip_findPosY(obj) 
{
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop;
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

// Functions required to validate empty Space for endecasearch
function trim(value) {
	var exp = /^(\s*)(\S*)(\s*$)/;
	if (exp.test(value)) 
		value = value.replace(exp, '$2');
	return value;
}
function validateSearch() {
	var searchEmpty	= true;
	search_obj	= eval( "document"+"."+"getElementById(\"search\")" );
	searchval	= eval( "search_obj"+".value" );
	if( trim(searchval) != '' &&  trim(searchval) != 'Enter Product Name or Style No.') {
		searchEmpty	= false;
	}		
	if( searchEmpty ) {
		alert('Please enter Product Name or Style No.');
		search_obj.focus();
		return false;
	}
	return true;
}

function toggletext(no)
{
	k = 'content'+no;
	img = 'image'+no;
	if($(k)){
		$(k).style.display='';
		$(k).style.left = xstooltip_findPosX($('compliance-info')) + "px";
		$(k).style.top = xstooltip_findPosY($(img))  + 59 + "px";
	}
	for(var i=1; i<=16 ; i++)
	{
		if(no!=i){
			disableDiv = 'content'+i;
			if($(disableDiv)){
				$(disableDiv).style.display='none';
			}
		}
	}
}
