
function alertfun() {
	alert('alert called');
}
function isNumberKey(evt)
{

   var charCode = (evt.which) ? evt.which : event.keyCode
   if (charCode > 31 && (charCode < 48 || charCode > 57))
   {
      return false;
    }

   return true;
}
function alphanumeric(event)
{
	var val;
	val = window.event.keyCode;
	if(val>=48 && val<=57 || val>=65 && val<=90 || val>=97 && val<=122)
	{
		return true;
	}
	else if(val==8)
		return true;
		
	return false;
}	
function openNewWindow(url){
	window.open(url);
}
function toggle_docbox( box_name, sel_obj, docValues )
{

	var replaceString = (docValues.replace("[","")).replace("]","");
	var documentTypeArray = replaceString.split(",");
	for (var a=0 ; a<documentTypeArray.length ; a++){
		documentTypeArray[a] = documentTypeArray[a].replace(" ","");
	}		
	if (typeof sel_obj == 'string'){
		sel_Type = sel_obj;
		document.getElementById( box_name ).value = sel_obj;
	}else {
		sel_Type = sel_obj.value;
		document.getElementById( box_name ).value = sel_obj.value;
	}

    items = document.getElementById( box_name );
    len   = items.options.length;
    var defaultNotExists = "true";
    for (var k = 0; k < len; k++ )
    {
        other_type = items.options[k].value;
 
		if ( other_type == sel_Type )
        {
 			defaultNotExists = "true";
        		if(document.getElementById(box_name+'_'+other_type) != null){
		            document.getElementById(box_name+'_'+other_type).style.display = 'block';
        			defaultNotExists = "false" ;
				}else{
					if(document.getElementById(box_name+'_aen') != null){
						document.getElementById(box_name+'_aen').style.display = 'block';
						defaultNotExists = "false" ;
						if(document.getElementById(box_name+'_aen'+'_AlternateEnglish') != null)
							document.getElementById(box_name+'_aen'+'_AlternateEnglish').style.display = 'block';
					}else{
						if(document.getElementById(box_name+'_noEnglishNoPrefLang') != null)
							document.getElementById(box_name+'_noEnglishNoPrefLang').style.display = 'block';
						defaultNotExists = "true";
					}
				}
       }else{
				if(document.getElementById(box_name + '_'+ other_type) != null){
		            document.getElementById( box_name + '_'+ other_type).style.display = 'none';
		            if((document.getElementById(box_name+'_aen') != null) && (document.getElementById(box_name+'_aen'+'_AlternateEnglish') != null) && (document.getElementById(box_name+'_aen').style.display == 'none') && (document.getElementById(box_name+'_aen'+'_AlternateEnglish').style.display == 'block'))
		            	document.getElementById(box_name+'_aen'+'_AlternateEnglish').style.display = 'none';
				}else{
					if(document.getElementById(box_name+'_noEnglishNoPrefLang') != null)
						document.getElementById(box_name+'_noEnglishNoPrefLang').style.display = 'none';
				
				}
        }

        
    }
    
    if (defaultNotExists == "true"){
   		for (var m=0 ; m<documentTypeArray.length ; m++){
	    	   for (var l = 0; l < len; l++ )
	    		{
	        		other_type = items.options[l].value;
	        		if(document.getElementById(box_name+'_'+other_type) != null){
	        			document.getElementById(box_name+'_'+other_type).style.display = 'block';
	        			break;
	        		}
	        	}
       	}
    }

}
//temp
window.onload = function() 
{
       var x = document.getElementsByName("reTypeEmailText");
       if(x[0]){

			x[0].onkeyup = function () {
	
				if (this.value.length - parseInt(this.getAttribute("hiddenvalue")) < 5 ) 
				{ 
					this.setAttribute("hiddenvalue", this.value.length);
				} 
			}
			x[0].onblur = function () {
				
			      if (this.value.length > parseInt(this.getAttribute("hiddenvalue")))
			      {
			            this.value = "";
			            this.setAttribute("hiddenvalue", 0);
			            alert("Please \"type\" your email address instead of copy/paste");
			      }
			}
			x[0].setAttribute("hiddenvalue", 0);
		}
}

//page item popup window - for autochat

function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}