function createShortcut(serverName) {
	if (!window.google || !google.gears) { location.href = "http://gears.google.com/?action=install&amp;return="+location.href; }
	var desktop = google.gears.factory.create("beta.desktop");
	var description = "";
	var icons = { "128x128": "http://www.sexrev.org/images/sexrev-icon.png" };
	desktop.createShortcut("SexRev.org","http://"+serverName,icons,description);
}

function SendToFriend(page) {
	MOOdalBox.open(page,'',"500 288");
}

function bHover(element) {
	bDiv = 'blog-'+element.parentNode.id
	document.getElementById(bDiv).style.backgroundPosition = 'center';
}

function bRestore(element) {
	bDiv = 'blog-'+element.parentNode.id
	document.getElementById(bDiv).style.backgroundPosition = 'center top';
}

function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}

function isValidEmail(email) {
	if (removeSpaces(email) == '') { return false 
	} else {
   		return (email.indexOf(".") > 2) && (email.indexOf("@") > 0);
   }
}

function checkform() {
	
	var error = '';
	
	var radio_gender = false;
	var radio_status = false;
	
	// check gender
	for (counter = 0; counter < document.chastity_frm.gender.length; counter++) {
		if (document.chastity_frm.gender[counter].checked)
			radio_gender = true; 
	}
	
	if (!radio_gender) {
		error = 1;
	}
	
	// check status
	for (counter = 0; counter < document.chastity_frm.status.length; counter++) {
		if (document.chastity_frm.status[counter].checked)
			radio_status = true; 
	}
	
	if (!radio_status) {
		error = 1;
	}
	
	var age = document.getElementById('cage').value;
	var email = document.getElementById('cemail').value;
	
	// check age and email
	if (removeSpaces(age) == '' || removeSpaces(age) < 12 || isValidEmail(email) == false) {
		error = 1;
	}
	
	if (error == 1) {
		alert("Please select a gender, status and fill in age and e-mail. No children under 12 are allowed.");
		return false;
	} else {
		return true;
	}
}

function showTab(tab) {
    var tabdivs = document.getElementById('mp-tabs').getElementsByTagName('div');
      for (var i = 0; i < tabdivs.length; i++) {
        tabdivs[i].style.display = 'none';
      }

      var tablinks = document.getElementById('mp-titles').getElementsByTagName('a');
      for (i = 0; i < tablinks.length; i++) {
        tablinks[i].className = '';
      }

    document.getElementById(tab.id.substring(4)).style.display = 'block';
    tab.className = 'active-tab';

}
