$(function(){
	$("input.required, textarea.required").after("<font color='red'>&nbsp;*</font>")
	/*$("input.required").each(function(){
		var $required = $("<font color='red'>*</font>");
		$(this).parent().parent().find("label").append($required); 
	})
	
	$("textarea.required").each(function(){
		var $required = $("<font color='red'>*</font>");
		$(this).parent().parent().find("label").append($required); 
	})*/
})

function findJME() { //v4.0
  var p,i,x;
  if (document.jmeapplet)
	  return document.jmeapplet;
  var n = 'jmeapplet';
  if (document.embeds)
      x = document.embeds[n];
  if (x)
      return x;
  var d = document;
  if(!(x=d[n])&&d.all)
      x=d.all[n];
  for (i=0;!x&&i<d.forms.length;i++)
      x=d.forms[i][n];
  if(!x && document.getElementById)
      x=document.getElementById(n);
  return x;
}

function saveJMECookie() {
    var jme = findJME().jmeFile();
    document.cookie = "chemjme="+jme+";expires=Thu, 31 Dec 2020 00:00:00 GMT; path=/";
}

function readJMECookie() {
    var editor = findJME();
    if (editor.smiles().length > 0) return; // editing already started
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf("chemjme=") == 0) {
            var jme = c.substring("chemjme=".length,c.length);
            //alert("jme="+jme);
            editor.readMolecule(jme);
            return;
        }
    }
}

function show3d(id) {
		window.open(path+"/soso/product/mol3d/"+id, "newwindow", "height=430, width=430,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
				
}

function structureSearch() {
		window.location.href = path+"/advanced-search";
				
}

function register() {
		window.location.href = path+"/register";
				
}
	      	
function search(frm) {
		var key = $('#key').val();
		var keyword = $('#keyword').val();
		if(keyword == undefined || keyword == '') {
			  	alert($("#struchem_please_enter_keyword_title").val());
			  	return false;
		}
		window.location.href = path+"/products/"+key+"/"+keyword;
		return false;
}

function search2(frm) {
		var key = $('#key2').val();
		var keyword = $('#keyword2').val();
		if(keyword == undefined || keyword == '') {
			  	alert($("#struchem_please_enter_keyword_title").val());
			  	return false;
		}
		window.location.href = path+"/products/"+key+"/"+keyword;
		return false;
}
