function OpenWindow(myElement,site,width,height)
{
	window.open(site, 'EmpEditPop',
	'scrollbars,menubars,statusbars,resizable,width='+width+',height='+height);
	return false;
}

function SelectObject(myElement,formname,formfield,val_id,val_value)
{
        if(formname == "search_by_category")
        {
                if(formfield == "categories_name")
                {
						window.opener.search_by_category.categories_id.value=val_id;
                        window.opener.search_by_category.categories_name.value=val_value;
                        window.opener.search_by_category.categories_name_show.value=val_value;
                }
        }
        if(formname == "add_your_listing_form")
        {
                if(formfield == "categories_name1")
                {
                        window.opener.add_your_listing_form.categories_id1.value=val_id;
                        window.opener.add_your_listing_form.categories_name1.value=val_value;
                }
                if(formfield == "categories_name2")
                {
                        window.opener.add_your_listing_form.categories_id2.value=val_id;
                        window.opener.add_your_listing_form.categories_name2.value=val_value;
                }
                if(formfield == "categories_name3")
                {
                        window.opener.add_your_listing_form.categories_id3.value=val_id;
                        window.opener.add_your_listing_form.categories_name3.value=val_value;
                }
        }
        if(formname == "your_account_update_info")
        {
                if(formfield == "categories_name1")
                {
                        window.opener.your_account_update_info.categories_id1.value=val_id;
                        window.opener.your_account_update_info.categories_name1.value=val_value;
                }
                if(formfield == "categories_name2")
                {
                        window.opener.your_account_update_info.categories_id2.value=val_id;
                        window.opener.your_account_update_info.categories_name2.value=val_value;
                }
                if(formfield == "categories_name3")
                {
                        window.opener.your_account_update_info.categories_id3.value=val_id;
                        window.opener.your_account_update_info.categories_name3.value=val_value;
                }
        }


        window.close();
}

function formCheck(formobj,lang,form_cat){


	// Enter name of mandatory fields
	if(form_cat == "form_add_your_listing")
	{
		var fieldRequired = Array("company_name","email","descr_en","descr_es","address","city","categories_name1");
		// Enter field description to appear in the dialog box
		if(lang == "en")
		{
			var fieldDescription = Array("Company Name","E-mail","English Description","Spanish Description","Address","City","Category");
			var alertMsg = "Please complete the following fields:\n\n";
		}
		else
		{
			var fieldDescription = Array("Nombre de Compania","Correo Electronico","Descripcion Ingles","Descripcion Espanol","Direccion","Ciudad","Categoria");
			var alertMsg = "Falta la siguienta informacion obligatoria:\n\n";
		}
	}
	if(form_cat == "your_account_update_info")
	{
		var fieldRequired = Array("descr_en","descr_es","address","city","categories_name1");
		// Enter field description to appear in the dialog box
		if(lang == "en")
		{
			var fieldDescription = Array("English Description","Spanish Description","Address","City","Category");
			var alertMsg = "Please complete the following fields:\n\n";
		}
		else
		{
			var fieldDescription = Array("Descripcion Ingles","Descripcion Espanol","Direccion","Ciudad","Categoria");
			var alertMsg = "Falta la siguienta informacion obligatoria:\n\n";
		}
	}
	if(form_cat == "your_account_login")
	{
		var fieldRequired = Array("email");
		// Enter field description to appear in the dialog box
		if(lang == "en")
		{
			var fieldDescription = Array("E-mail");
			var alertMsg = "Please complete the following fields:\n\n";
		}
		else
		{
			var fieldDescription = Array("Correo Electronico");
			var alertMsg = "Falta la siguienta informacion obligatoria:\n\n";
		}
	}
	if(form_cat == "your_account_update_password")
	{

		var fieldRequired = Array("new_password");
		// Enter field description to appear in the dialog box
		if(lang == "en")
		{
			var fieldDescription = Array("New Password");
			var alertMsg = "Please complete the following fields:\n\n";
		}
		else
		{
			var fieldDescription = Array("Nueva Clave");
			var alertMsg = "Falta la siguienta informacion obligatoria:\n\n";
		}
	}
	if(form_cat == "form_newsletter")
	{
		var fieldRequired = Array("newsletter_email");
		// Enter field description to appear in the dialog box
		if(lang == "en")
		{
			var fieldDescription = Array("E-Mail");
			var alertMsg = "Please complete the following fields:\n\n";
		}
		else
		{
			var fieldDescription = Array("Correo Electronico");
			var alertMsg = "Falta la siguienta informacion obligatoria:\n\n";
		}
	}
	if(form_cat == "form_contact_us")
	{
		var fieldRequired = Array("name","email","subject");
		// Enter field description to appear in the dialog box
		if(lang == "en")
		{
			var fieldDescription = Array("Your Name","Your E-Mail","Subject");
			var alertMsg = "Please complete the following fields:\n\n";
		}
		else
		{
			var fieldDescription = Array("Su Nombre","Su Correo Electronico","Thema");
			var alertMsg = "Falta la siguienta informacion obligatoria:\n\n";
		}
	}
	// dialog message
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "password":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

function updateFields(radioObj) 
{ 
	//alert(radioObj.checked + " : " + radioObj.value);
 	var  isActive = radioObj.checked;
 	var item = radioObj.value;
 	vInvite = "hidden";
 	
//	if (isActive == true) 
//	{
    // event is coming from the meeting radio. It is checked so make the participants field visible
//    		if (item == "no" ) 
//		{
//      			vInvite = "visible";
//   	 	}
//    	} 
//	else 	
//	{
//      		if (item == "yes") 
//		{
    // event is coming from the appointment radio. It is no longer checked so hide the participants field
//        		vInvite = "visible";
//      		}
//   	 }
 // use the default value of vInvited = hidden when:
 // the event is coming from the meeting radio and it is not checked - hide the participants field
 // th event is coming from the appointment radio and it is not checked - hide the participants field
 
	if(item == "no")
	{
		vInvite = "hidden";
	}
	else
	{
		vInvite = "visible";
	}

	var upload = document.getElementById("upload");
 	if (upload != null) 
	{
  	 	upload.style.visibility = vInvite;
 	}
}
