window.xpath = !!(document.evaluate);
if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true;
else if (document.childNodes && !document.all && !navigator.taintEnabled) window.webkit = window[window.xpath ? 'webkit420' : 'webkit419'] = true;
else if (document.getBoxObjectFor != null) window.gecko = true;

function setOpacity(el,opacity) {
	if (opacity==0){
		if (el.style.visibility!="hidden") el.style.visibility = "hidden";
	} else {
		if (el.style.visibility!="visible") el.style.visibility = "visible";
	}
	if (window.ie) el.style.filter = (opacity==1)?'':"alpha(opacity="+opacity*100+")";
	else el.style.opacity = opacity;
}

function isLogged2() {
	var isLogged = (getCookieValue("name") && getCookieValue("c"));
	return			isLogged;
}


function vTrim(str) {
	str						=	str.replace(/^\s+/,'');
	str						=	str.replace(/\s+$/,'');
	return						str;
}

function checkMail() {
	var f					= document.formFriend;
	var wrong				= true;
	var wrong1				= true;
	if(vTrim(f.name.value).length<2) {
							alert("Please input \"Your Name:\" ");
							return  false;
	}
	for(var n=0;n<6;n++) {
	var i		=	n?n:"";
	var v		=	vTrim(f["email"+i].value);
	if(!v)			continue;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filter.test(v)) {
			wrong	=	true;
						break;
	} else {
		if(n==0)wrong1	=	false;
		else	wrong	=	false;
	}
	}
	if(wrong1) {
		alert("You must fill \"Your Email\" address !");
		return false;
	}
	if(wrong) {
		alert("You must fill \"Friend's Email\" address !");
		return false;
	}
	gE("tableMail2").style.display	=	"";
	gE("tableMail").style.display	=	"none";

	return			true;
}

function ucwords(str) {
     return str.toLowerCase().replace(/\w+/g,function(s){
          return s.charAt(0).toUpperCase() + s.substr(1);
     })
}
	
	
function gE(e) { return	document.getElementById(e); }

/* [cookie] */
function GetCookie(sName)
{
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0])
			return unescape(aCrumb[1]);
	}
	return null;
}

function SetCookie(cN, cV, cE, cP)
{
	cV = escape(cV);
	
	if (cE == "")
	{
		var nowDate = new Date();
		nowDate.setHours(nowDate.getHours() + 12);
		cE = nowDate.toGMTString();
	}
	
	(cP != "") ? cP = ";Path=" + cP : cP = '/';
	
	document.cookie = cN + "=" + cV + ";expires=" + cE + cP;
}

function DeleteCookie(sName, path, domain)
{
	if (GetCookie(sName)) {
			document.cookie = sName + "=" + 
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT"
	}
}
	

function getCookieValue(sName) {
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++) {
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0])
			return unescape(aCrumb[1]);
	}
	return null;
}

var close = true;
var over = false;

function setVariant(s) 
{
	switch(s)
	{
		case 'any':
		  document.getElementById('label').innerHTML = 'Any instrument';
		  document.getElementById('_ftype').value = 'any';
		  break;    
		case 'guitar':
		  document.getElementById('label').innerHTML = 'Guitar only';
		  document.getElementById('_ftype').value = 'guitar';
		  break;
		case 'bass':
		  document.getElementById('label').innerHTML = 'Bass only';
		  document.getElementById('_ftype').value = 'bass';
		  break;
		case 'drum':
		  document.getElementById('label').innerHTML = 'Drum only';
		  document.getElementById('_ftype').value = 'drum';
		  break;
	}
	document.getElementById('searchselect').className = 'selopen dn';
	close = true;
	s_h();
}

function s_h() 
{
	if (close) {
		document.getElementById('searchselect').className = 'selopen';
		close = false;
	} else {
		close = true;
		document.getElementById('searchselect').className = 'selopen dn';
	}
}

document.onclick = function() 
{
	if (!over) {
		var search = document.getElementById('searchselect');
		if (search)
		{
			search.className = 'selopen dn';
			close = true;
		}
	}
}

function strip_tags(str)
	{ 
		return str.replace(/<\/?[^>]+>/gi, "");	
	}
	
function ChkInputData()
{
	var lengthStart;
	snd = document.frmSendMean.comment.value.toString();
	snd = vTrim(snd);
	lengthStart=snd.length;
	snd = strip_tags(snd);
	if( (snd.length!=lengthStart)&&(snd.length<50) )
	{
		alert("HTML tags aren't allowed!");
		document.frmSendMean.comment.focus();
		return false;
	}
	if(snd.length < 50)
	{
		alert("Your meaning should be 50 letters at least!");
		document.frmSendMean.comment.focus();
		return false;
	}
}