var d = document;

google_ad_client    = "pub-0557047985484196";
google_ad_width     = 468;
google_ad_height    = 60;
google_ad_format    = "468x60_as";
google_color_border = "000000";
google_color_bg     = "000000";
google_color_link   = "FFFFFF";
google_color_url    = "CC0000";
google_color_text   = "999999";

startList = function()
{
    var nodes = d.getElementById("nav").getElementsByTagName("li");
    for(var i=0; i<nodes.length; i++)
    {
        nodes[i].onmouseover = function()
        {
            this.className += " over";
        }
        nodes[i].onmouseout = function()
        {
            this.className = this.className.replace(new RegExp(" over\\b"), "");
        }
    }
}
if(window.attachEvent) window.attachEvent("onload", startList);

startCart = function()
{
    var cart = d.getElementById("cartsmall");
	cart.onmouseover = function()
    {
    	this.className += " over";
	}
    cart.onmouseout = function()
    {
    	this.className = this.className.replace(new RegExp(" over\\b"), "");
    }
}
if(window.attachEvent) window.attachEvent("onload", startCart);

/// form validation
function frmRegisterSubmit()
{
    var alertmsg = "";
    f = d.getElementById("frmRegister");
    if(f.nick.value == "")
    {
        alertmsg = "Please provide your nickname";
    } else if(f.name.value == "")
    {
        alertmsg = "Please provide your realname";
    } else if(f.gender.options[0].selected)
    {
        alertmsg = "Please provide your gender";
    } else if(f.birthm.options[0].selected)
    {
        alertmsg = "Please provide month of your birthdate";
    } else if(f.birthd.options[0].selected)
    {
        alertmsg = "Please provide date of your birthdate";
    } else if(f.birthy.options[0].selected)
    {
        alertmsg = "Please provide year of your birthdate";
    } else if(f.heightf.options[0].selected)
    {
        alertmsg = "Please provide your height";
    } else if(f.ethnicity.options[0].selected)
    {
        alertmsg = "Please provide your ethnicity";
    } else if(f.denomination.options[0].selected)
    {
        alertmsg = "Please provide your denomination";
    }
    else if(f.city.value == "")
    {
        alertmsg = "Please provide your city";
    } else if((f.country.options[1].selected) && (f.state.options[0].selected ))
    {
        alertmsg = "Please provide your state";
    } else if(f.country.options[0].selected)
    {
        alertmsg = "Please provide your country";
    } else if(!validEmail(f.email.value))
    {
        alertmsg = "Please provide your e-mail";
    }
    else if(f.info.value == "")
    {
        alertmsg = "Please describe yourself";
    } else if(!f.agree.checked)
    {
        alertmsg = "Please agree with terms and conditions of disclamer";
    }
    if(alertmsg == "")
    {
        return true;
    } else
    {
        alert (alertmsg);
        return false;
    }
}

function frmProfileSubmit()
{
    var alertmsg = "";
    f = d.getElementById("frmProfile");
    if(f.nick.value == "")
    {
        alertmsg = "Please provide your nickname";
    } else if(f.name.value == "")
    {
        alertmsg = "Please provide your realname";
    } else if(f.city.value == "")
    {
        alertmsg = "Please provide your city";
    } else if(f.country.options[0].selected)
    {
        alertmsg = "Please provide your country";
    } else if((f.country.options[1].selected) && (f.state.options[0].selected ))
    {
        alertmsg = "Please provide your state";
    } else if(f.email.value == "")
    {
        alertmsg = "Please provide your e-mail";
    } else if(f.birthm.options[0].selected)
    {
        alertmsg = "Please provide month of your birthdate";
    } else if(f.birthd.options[0].selected)
    {
        alertmsg = "Please provide date of your birthdate";
    } else if(f.birthy.options[0].selected)
    {
        alertmsg = "Please provide year of your birthdate";
    }
    if(alertmsg == "")
    {
        return true;
    } else
    {
        alert (alertmsg);
        return false;
    }
}


function frmLoginSubmit()
{
    var alertmsg = "";
    f = d.getElementById("frmLogin");
    if(!validEmail(f.email.value))
    {
        alertmsg = "Please provide your email";
    } else if(f.password.value == "")
    {
        alertmsg = "Please provide your password";
    }
    if(alertmsg == "")
    {
        return true;
    } else
    {
        alert (alertmsg);
        return false;
    }
}

function frmRemindSubmit()
{
    var alertmsg = "";
    f = d.getElementById("frmRemind");
    if(!validEmail(f.email.value))
    {
        alertmsg = "Please provide your email";
    }
    if(alertmsg == "")
    {
        return true;
    } else
    {
        alert (alertmsg);
        return false;
    }
}

function frmEquipmentSubmit()
{
    var alertmsg = "";
    f = d.getElementById("frmEquipment");
	if (f.name.value == "")
	{
		alertmsg = "your forgot to enter your name";
	} else if (f.equipment.value == "")
	{
		alertmsg = "your forgot to enter your equipment";
	} else if (f.location.value == "")
	{
		alertmsg = "your forgot to enter your location";
	} else if (f.contact.value == "")
	{
		alertmsg = "your have to enter your phone number or your E-mail";
    } else if(f.message.value == "")
    {
        alertmsg = "your forgot to enter message";
    }
    if(alertmsg == "")
    {
        return true;
    } else
    {
        alert (alertmsg);
        return false;
    }
}

function frmMusicianSubmit()
{
    var alertmsg = "";
    f = d.getElementById("frmMusician");
    if(f.board.options[0].selected)
    {
		alertmsg = "Please select board";
    } else if (f.name.value == "")
	{
		alertmsg = "your forgot to enter your name";
	} else if (f.city.value == "")
	{
		alertmsg = "your forgot to enter your city";
	} else if(f.state.options[0].selected)
    {
		alertmsg = "Please select your state";
    } else if (f.phone.value == "")
	{
		alertmsg = "your forgot to enter your phone number";
	} else if (f.email.value == "")
	{
		alertmsg = "your have to enter your E-mail address";
    } else if(f.message.value == "")
    {
        alertmsg = "your forgot to enter message";
    }
    if(alertmsg == "")
    {
        return true;
    } else
    {
        alert (alertmsg);
        return false;
    }
}

function frmPhotoSubmit()
{
    var alertmsg = "";
    var myRegExp = /(.jpg|.jpeg)$/;
    f = d.getElementById("frmPhoto");
    var i = 0;
    for(i=1;i<=8;i++)
    {
//        if (f.photo[i].value != ""|| f.photo[i].value == null) { alertmsg = "Please select a file to upload";
//  } else if (!myRegExp.exec(f.photo[i].value.toLowerCase())) { alertmsg = " only JPG files are supported. Please try again";
//  }
    }
    if(alertmsg == "")
    {
        return true;
    } else
    {
        alert (alertmsg);
        return false;
    }
}

function frmPasswordSubmit()
{
    var alertmsg = "";
    f = d.getElementById("frmPassword");
    if(f.password.value  == "")
    {
        alertmsg = "Please provide current password";
    } else if(f.password1.value == "")
    {
        alertmsg = "Please provide new password";
    } else if(f.password2.value == "")
    {
        alertmsg = "Please confirm new password";
    } else if(f.password1.value != f.password2.value)
    {
        alertmsg = "Passwords do not match!";
    }
    if(alertmsg == "")
    {
        return true;
    } else
    {
        alert (alertmsg);
        return false;
    }
}

function frmFileSubmit()
{
    f = d.getElementById("frmFile");
    var alertmsg = "";
    var myRegExp = /(.avi|.mid|.mov|.mp3|.qt|.ra|.swf|.wma|.wmv)$/; // |.w2a|.w3a|.w2v|.w3v|.w2w|.w3w|.w7a|.w8a|.w7v|.w8v|.w7w|.w8w|.kmp|.ksc|.ksf
	if(f.groupid.options[0].selected)
    {
        alertmsg = "Please select a category";
    } else if(f.name.value == "")
    {
        alertmsg = "Please provide name";
    } else if(f.id.value == 0)
    {
        if(f.file.value == ""|| f.file.value == null)
        {
            alertmsg = "Please select a file to upload";
/*
        } else if(f.groupid.options[1].selected && !myRegExp.exec(f.file.value.toLowerCase()))
        {
            alertmsg = "This file is not a recognizable Audio or Video File.\n"+ 
            	" only following media files are supported:\n"+ 
            	"AVI, AIFF, .MID, MOV, MP3, QT, RA, SWF, WMA, WMV\n"+ 
            	"Please try again";
*/
        }
    }
    if(alertmsg == "")
    {
        return true;
    } else
    {
        alert (alertmsg);
        return false;
    }
}

function frmSubscribeSubmit()
{
    var alertmsg = "";
    f = d.getElementById("frmSubscribe");
    if(!validEmail(f.email.value))
    {
        alert ("Please provide your e-mail");
        f.email.focus();
        return false;
    } else
    {
        return true;
    }
}

function frmShippingSubmit()
{
    var alertmsg = "";
    f = d.getElementById("frmShipping");

	if (f.shpcountry.options[0].selected)
	{
		alertmsg = "please select a country of destinaton";
	}

    if(alertmsg == "")
    {
        return true;
    } else
    {
        alert (alertmsg);
        return false;
    }
}

function frmCheckoutSubmit()
{
    var alertmsg = "";
    f = d.getElementById("frmCheckout");

	if (f.shpfirstname.value == "")
	{
		alertmsg = "your forgot to enter your first name";
	} else if (f.shplastname.value == "")
	{
		alertmsg = "your forgot to enter your last name";
	} else if (f.shpaddress1.value == "")
	{
		alertmsg = "your forgot to enter your address";
	} else if (f.shpcity.value == "")
	{
		alertmsg = "your forgot to enter your city";
	} else if (f.shpstate.value == "")
	{
		alertmsg = "your forgot to enter your state/region";
	} else if(f.shpzip.value == "")
    {
		alertmsg = "Please select your ZIP/Postal code";
    } else if(f.shpcountry.value == "")
    {
		alertmsg = "Please select your country";
    } else if (f.ccemail.value == "")
	{
		alertmsg = "your have to enter your E-mail address";
    } else if (f.ccphone.value == "")
	{
		alertmsg = "your forgot to enter your phone number";
	}
    if(alertmsg == "")
    {
        return true;
    } else
    {
        alert (alertmsg);
        return false;
    }
}

/// misc

function askme()
{
    return confirm("Are you sure?");
}

function validEmail(email)
{
	if (email == "") return false;
    var myRegExp = /^([^\.\-])?[\w\.\-\_]+([^\.\-])\@[^\.\-\_]([\.\-]?([a-z0-9])+([\.\-]*([a-z0-9])+)?)+(\.[a-z]{2,3})$/;
    return myRegExp.exec(email.toLowerCase());
}

function openWindow(url,nam,sw,sh)
{
    if(nam == "") nam = "stda";
    if(sw == 0) sw = 666;
    if(sh == 0) sh = 470;
    window.open(url,nam,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+sw+',height='+sh+'');
}

function showbig(id,member) 
{
	window.open('/community/fullsize.php?id='+id+'&m='+member,'picture','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,top=100,left=100,width=400,height=400');
	return false;
}


/* instant messaging */

function msg_close(id)
{
// myDate =+ 31557600;
	d = document;
	m = d.getElementById("imessage");
	m.style.visibility = "hidden";
	if (id > 0)
	{
		setCookie('lastim', id, 365);
	}
	return false;
}

function msg_submit(id)
{
	d = document;
	m = d.getElementById("imsgreplybody");
// m.value = trim(m.value);
	var msgl = m.value.length;
	if (msgl == 0)
	{
		return false;
	}
	if (id > 0)
	{
		setCookie('lastim', id, 365);
	}
	m = d.getElementById("msg");
	m.submit();
}

function msg_reply(id)
{
	openWindow("/member/msg_reply.php?id="+id,"reply",500,400);
}

function msg_countChars()
{
	d = document;
	var maxchar = 250;
	m = d.getElementById("imsgreplybody");
	var msgl = m.value.length;
	if (msgl > maxchar)
	{
		m.value = m.value.substr(0, maxchar);
		msgl = m.value.length;
	}
	l = d.getElementById("imsglength");
	l.innerHTML = msgl.toString() + " of " + maxchar;
}

// functions by Martin Honnen
function setCookie(cookieName, cookieValue, expires, path, domain, secure)
{
	var date = new Date();
	date.setTime(date.getTime() + (expires*24*60*60*1000));
	var t = date.toUTCString();
	document.cookie = escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; EXPIRES=' + t : '')
		+ (path    ? '; PATH='    + path : '')
		+ (domain  ? '; DOMAIN='  + domain : '')
		+ (secure  ? '; SECURE' : '');
}

function getCookie(cookieName)
{
	var cookieValue = null;
	var posName = document.cookie.indexOf(escape(cookieName) + '=');
	if (posName != -1)
	{
		var posValue = posName + (escape(cookieName) + '=').length;
		var endPos = document.cookie.indexOf(';', posValue);
		if (endPos != -1)
		{
			cookieValue = unescape(document.cookie.substring(posValue, endPos));
		} else
		{
			cookieValue = unescape(document.cookie.substring(posValue));
		}
	}
	return cookieValue;
}
// functions by Martin Honnen (end)