function isBlank(val){
	if (val == null) return true;
	for (var i=0; i<val.length; i++) {
		if ((val.charAt(i)!=' ') && (val.charAt(i)!="\t") && (val.charAt(i)!="\n") && (val.charAt(i)!="\r")){
			return false;
		}
	}
	return true;
}

function allow2Proceed(cBox) {
	var button = document.getElementById("proceed1");
	button.disabled = !cBox.checked;
}

function convert2CamelCase(obj) {

	if (!isBlank(obj.value)) {
		var newValue = '';
		var parts = obj.value.split(" ");
		for (var i=0; i<parts.length; i++) {
			var part = parts[i];
			if (i > 0) newValue += ' ';
			newValue += part.charAt(0).toUpperCase() + part.substring(1);
		}
		
		obj.value = newValue;
	}
}

function area(obj){
        if(obj.value == "area" || obj.value == "phone" || obj.value == "mobile"){
                 obj.value = "";
        }
}

function default_val(obj){
        if(obj.value==""){
                if(obj.name=='areaCode'){
                        obj.value= "area";
                } else if(obj.name=='phoneNumber'){
                        obj.value= "phone";
                }else {
                        obj.value= "mobile";
                }
        } 
}

function chcolor(obj){
       obj.className = "phmnormal";
}

function checkHypen(obj){ 
	var objValue = obj.value;
	var i=0; 
	var values = objValue.split("-"); 
	var finalVal = ""; 
	for(;i<values.length;i++) { 
		finalVal += values[i]; 
	} 
	obj.value = finalVal; 
}

function checkUserName(e, obj) {
	var KeyCode = (e.keyCode) ? e.keyCode : e.which;
	if(obj.value ==''){
		if(KeyCode == 97)
			return true;
	}
   	return ((KeyCode == 8) // backspace
        || (KeyCode == 9) // tab
	|| (KeyCode == 32) // space
	|| (KeyCode == 44) // ,
	|| (KeyCode == 46) // .
	|| (KeyCode == 37 && (e.which == 0 || (Liferay.Browser.is_ie && e.which != undefined))) // left arrow
        || (KeyCode == 39 && (e.which == 0 || (Liferay.Browser.is_ie && e.which != undefined))) // right arrow
        || (KeyCode == 46 && (e.which == 0 || (Liferay.Browser.is_ie && e.which != undefined))) // delete
        || ((KeyCode > 96) && (KeyCode < 123)) // A - Z
	|| ((KeyCode > 64) && (KeyCode < 91))
   	);
}

function popupValidity() { 
	
	var popup = Liferay.Popup({title: "Terms & Conditions",modal:true,position:[100,5],width:800});
	jQuery(popup).load('/html/portlet/my_account/terms_of_use.html');
}

/*
 * written to replace @ ,numbers, more than 2 space , a word more than 20 character
 * 	and count for number of words typed
 */

function valid(obj){
	var r=/\d|@|[a-z]{20}|\s{2}$/gi;
	obj.value = obj.value.replace(r,'');
	var val = 1000-obj.value.length;
	if(obj.id == 'description'){
	  document.getElementById('count1').innerHTML= val;
    }else if(obj.id == 'expectation'){
    	 document.getElementById('count2').innerHTML= val;
    }	
}
 
function checkChar(evt, regExp) {
 	
 	evt = (evt)? evt : window.event;

 	var charCode = (evt.which)? evt.which : evt.keyCode;

 	if (charCode <= 13 || charCode == 46 || charCode == 37 || charCode == 39) { 
 	    return true;  
 	} else { 
 	    var keyChar = String.fromCharCode(charCode); 
 	    return regExp.test(keyChar); 
 	}
}

//Code Added for disabling right click on mouse
function clickIE4(){
	if (event.button==2){
		return false;
	}
}

function clickNS4(e){
	if (document.layers||document.getElementById&&!document.all){
		if (e.which==2||e.which==3){
			return false;
		}
	}
}

if (document.layers){
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
	document.onmousedown=clickIE4;
}
document.oncontextmenu = new Function("return false");