var formExamples = {
	//p_name: "e.g. Fibolocator",
	product: "e.g. Fibolocator",
	p_namePR: "e.g. Fibolocator",
	
	company: "e.g. Photonic Sourcing",
	c_nameAdmin: "e.g. Photonic Sourcing",
	//c_nameEdit: "e.g. Photonic Sourcing",
	//qty: "e.g. 5",
	p_qtyPR: "e.g. 5",
	//unit: "e.g. each, feet, lbs, meters etc.",
	//p_unit: "e.g. each, feet, lbs, meters etc.",
	p_unitPR: "e.g. each, feet, lbs, meters etc.",
	//p_keywords: "Use maximum 250 characters.",
	keywords: "Use maximum 250 characters.",
	/*prodDesc: "Put a brief company description here",*/
	description: "Put a brief company description here",
	body: "Put a brief news description here",
	p_descriptionPR: "Put a brief Procurement Request description here",
	c_descr: "Put a brief company description here",
	web: "e.g. www.photonic-sourcing.com or blank",
	c_web: "e.g. www.photonic-sourcing.com or blank",
	c_webAdmin: "e.g. www.photonic-sourcing.com or blank",
	fname:"Use at least 4 characters",
	lname:"Use at least 4 characters",
	//phone: "e.g. +19786310233",
	//u_phone: "e.g. +19786310233",
	c_phone: "e.g. +19786310233",
	
	fax: "e.g. +19786310233",
	//u_fax: "e.g. +19786310233",
	//c_fax: "e.g. +19786310233",
	
	street: "Use at least 4 characters",
	//c_street: "Use at least 4 characters",
	
	city: "Use at least 3 characters",
	c_city: "Use at least 3 characters",
	c_cityAdmin: "Use at least 3 characters",
	c_cityAdminEdit: "Use at least 3 characters",
	
	state: "Use at least 2 characters or leave blank",
	c_state: "Use at least 2 characters or leave blank",
	
	name: "e.g. John Smith Use at least 4 characters",
	adminName: "Use at least 4 characters.  Use only letters and numbers",
	adminNameEdit: "Use at least 4 characters.  Use only letters and numbers",
	username_u: "Use at least 4 characters. Use only letters and numbers",
	u_usernameAdmin: "Use at least 4 characters. Use only letters and numbers",
	u_usernameEdit: "Use at least 4 characters. Use only letters and numbers",
	u_usernameMA: "Use at least 4 characters. Use only letters and numbers",
	email: "e.g. johnsmith@photonic-sourcing.com",
	//c_email: "e.g. johnsmith@photonic-sourcing.com",
	u_emailAdmin: "e.g. johnsmith@photonic-sourcing.com",
	u_emailEdit: "e.g. johnsmith@photonic-sourcing.com",
	u_emailMA: "e.g. johnsmith@photonic-sourcing.com",
	adminEmail: "e.g. johnsmith@photonic-sourcing.com",
	adminEmailEdit: "e.g. johnsmith@photonic-sourcing.com",
	//pass: "Use 6 to 32 characters, except spaces; case-sensitive.",
	u_password: "Use 6 to 32 characters, except spaces; case-sensitive.",
	adminPassword: "Use 6 to 32 characters, except spaces; case-sensitive.",
	captcha: "Type the code shown",
	
	namef: "e.g. John",
	firstName: "e.g. John",
	
	title: "Title",
	//p_price: "e.g 123.58",
	f_price: "e.g 123.58",
	pack_price : "e.g 123.58",
	f_price_description: "Price description",
	pack_price_description: "Price description",
	//u_name: "e.g John Smith",
	c_zip_add: "Zip, at least 4 characters",
	c_zip: "Zip, at least 4 characters",
	lastName: "e.g. Smith",
	lastNamef: "e.g. Smith",
	search1: "e.g. Photonic Sourcing",
	//'u_category[]': "Please select the categories of interest to you <br />in order to receive only targeted information.",
	department: 'e.g. Sales',
	country: 'e.g. United States',
	'subject1': 'Use at least 1 character',
	p_u_idAdmin: 'Please select a user for which to add the product',
	p_u_idAdminPR: 'Please select a user for which to add the procurement request',
	p_statusAdmin: 'Please select a status for the product',
	u_c_idAdmin: 'Please select a company for which to add the user',
	c_type_o: '',
	f_name : "Enter feature name",
	pack_name : "Enter package name",
	f_description: "Enter feature description",
	pack_description : "Enter package description",
	f_valability: "Valability of the feature (months)",
	pack_valability: "Valability of the package (months)",
	pack_discount: "Discount of the package (USD)",
	lang_company: "Please enter a news title",
	content: "Please enter the news content"
};

function initForm(form_name, form_type) {
	var form = document.forms[form_name];
	var fields;
	var j;
	fields = getFields(form_name,"name");
	
	for(j=0; j < fields.length; j++){
		if(fields[j].getAttribute('name')){
			var field_name = fields[j].getAttribute('name');
			if(fields[j].getAttribute('id'))
			    field_name = fields[j].getAttribute('id');
			var field_value = '';
			field_value = isset(formExamples[field_name]) ? formExamples[field_name] : '';
			if(fields[j].getAttribute('type') != 'hidden' && fields[j].getAttribute('type') != 'button' && fields[j].getAttribute('type') != 'checkbox') {
				if(form_type == 'add' && fields[j].getAttribute('type') == 'text'){
					if(fields[j].value == '') { 
						fields[j].value = field_value;
						fields[j].style.color = "#AAAAAA";
						fields[j].style.fontSize="11px";
					}
	     			addEvent(fields[j], 'focus', clearFields);
				} else if(form_type == 'edit' || fields[j].getAttribute('type') == 'file'  || fields[j].getAttribute('type') == 'password'){
                                    
$('#jsvalidator_'+field_name).html(field_value);
						$('#jsvalidator_'+field_name).css('color','#6E6E6E');
					
				}
			}
		}
	}
	
}
function addEvent(el, type, handler) {
     if (document.addEventListener) {
         el.addEventListener(type, handler, false);
     } else if (document.attachEvent) {
         el.attachEvent("on" + type, handler);
     } else {
         el.onclick = handler;
     }
}

function clearFields(e) {
    var e = e || window.event;
    if( e.target )
        var node = e.target;
    else
        var node = e.srcElement;
	
	var field_name = node.name;
	var field_value = isset(formExamples[field_name]) ? formExamples[field_name] : '';
	node.style.color = "#000";
	node.style.fontSize="12px";
	if(field_value == node.value) 
		node.value = '';
}
function getFields(formref,type){
	var els;
	if(type == "name"){
		els = document.forms[formref].elements;
	}
	if(type == "id"){
		els = Form.getElements(formref);
	}
	return els;
}
