var popUpWin=0;
function clearBox()
{
	//alert (document.SignUp.su_professionalSummary.value);
	//document.write(document.SignUp.su_professionalSummary.value);
	var is_summary=document.SignUp.su_professionalSummary.value.indexOf('-------------- REMOVE THIS LINE  ------------------');
	var is_summary1=document.SignUp.su_professionalSummary.value.indexOf('SAMPLE');
	if (is_summary != -1 || is_summary1 != -1)
	{
		document.SignUp.su_professionalSummary.value = "";
	}
}

function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin )
  {
	//  if (!popUpWin.closed)
	//alert('');
	    popUpWin.close();
  }
 popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  
}

function selOpt(OptionListName, ListVal)
{	
	
	for (i=0; i < OptionListName.length; i++)
	{
		if (OptionListName.options[i].value == ListVal)
		{			
			OptionListName.selectedIndex = i;
			break;
		}
	}
}

function SelectOption(OptionListName, ListVal)
{	
	
	for (i=0; i < OptionListName.length; i++)
	{
		if (OptionListName.options[i].value == ListVal)
		{			
			OptionListName.selectedIndex = i;
			break;
		}
	}
}

function SelectMultiOption(OptionListName, ListVal)
{	
	var valList = ListVal.split("##");
	
	for (j=0; j<valList.length; j++)
	{
	  newListVal = valList[j];
	  for (i=0; i < OptionListName.length; i++)
	  {
		if (OptionListName.options[i].value == newListVal)
		{
			OptionListName.selectedIndex = i;
		}
	  }
	}
}

function calcCharLeft(form,element){
		clipped = false
		maxLength = 600
	if (element != null)
	{
        if (element.value.length > maxLength) { 
	        element.value = element.value.substring(0,maxLength)
		    charleft = 0
		    clipped = true
        } else {
			charleft = maxLength - element.value.length
		}
	
        form.charsLeft.value = charleft
     }
	 return clipped
}

function textKey(form,element){
	supportsKeys = true
	calcCharLeft(form,element)
}


function calcCharLeft1(form,element,maxLength){
		clipped = false
	if (element != null)
	{
        if (element.value.length > maxLength) { 
	        element.value = element.value.substring(0,maxLength)
		    charleft = 0
		    clipped = true
        } else {
			charleft = maxLength - element.value.length
		}
	
        form.charsLeft.value = charleft
     }   
	 return clipped
}

function textKey1(form,element,maxlength){
	supportsKeys = true
	calcCharLeft1(form,element,maxlength)
}


function stickNote(message, divID, browser, domain)
{
	// message = Message to print inside Note
	// divID = Span where the note will display
	// browser = Users Browser
	var noteBox = "<table width='765' cellspacing='0' cellpadding='1'><tr><td><table width='765' cellpadding='1' cellspacing='0'><tr><td><table width='765' cellspacing='0' cellpadding='1'><tr><td bgcolor='#FF8A00'><table width='765' cellpadding='2' cellspacing='0' bgcolor='#FFF9CE'><tr><td width='748' align='left'>"+message+"</td><td width='10' align='right' valign='top'><a href='javascript:;' onClick=\"closeStickNote('"+divID+"', '"+browser+"', '"+domain+"');\"><img src='images/informationbar_iconclose.gif' width='13' height='13' border='0' /></a></td></tr></table></td></tr></table></td><td width='1' rowspan='2' bgcolor='#CCCCCC'></td></tr><tr><td height='2' bgcolor='#CCCCCC'></td></tr></table></td></tr><tr><td height='5'></td></tr></table>";
	document.getElementById(divID).innerHTML = noteBox;
	return; 
}
function stickNote1(message, divID, browser)
{
	// message = Message to print inside Note
	// divID = Span where the note will display
	// browser = Users Browser
	var noteBox = "<table width='100%' cellspacing='0' cellpadding='1'><tr><td height=5></td></tr><tr><td><table width='100%' cellpadding='1' cellspacing='0'><tr><td><table width='100%' cellspacing='0' cellpadding='1'><tr><td bgcolor='#FF8A00'><table width='100%' cellpadding='2' cellspacing='0' bgcolor='#FFF9CE'><tr><td width='99%' align='left'>"+message+"</td><td width='10' align='right' valign='top'></td></tr></table></td></tr></table></td><td width='1' rowspan='2' bgcolor='#CCCCCC'></td></tr><tr><td height='2' bgcolor='#CCCCCC'></td></tr></table></td></tr><tr><td height='5'></td></tr></table>";
	document.getElementById(divID).innerHTML = noteBox;
	return; 
}

function closeStickNote(divID, browser, domain)
{
	if (browser == "NOTIE")
		document.getElementById(divID).innerHTML = "";
	else
		document.getElementById(divID).style.display = "none";
		
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+1*24*60*60*1000);
	//Today.setTime(nomilli);
	UTCstring = Today.toUTCString();

	document.cookie = "stickNote=Off;expires="+UTCstring+";path=/; domain="+domain;
}

function closeMsgBoxes(divID)
{
		document.getElementById(divID).innerHTML = "";
}

function showProcessBar(spanID)
{
	document.getElementById(spanID).innerHTML = "<img src='images/working.gif' width='16' height='16' align='absmiddle' /> <span class='maroon10NB'> PROCESSING, PLEASE WAIT... </span>";
}

function hideProcessBar(spanID)
{
	document.getElementById(spanID).innerHTML = "";
}

function outputProcessing(){
	return "<table cellpadding='0' cellspacing='0' width='100%' border=0><tr><td height='20' colspan='2' align='left' width='100%'>&nbsp;<img src='images/working.gif' width='16' height='16' align='absmiddle' /> <span class='maroon10NB'> PROCESSING, PLEASE WAIT... </span></td></tr></table>";
}

function outputProcessing1(spanID)
{
	document.getElementById(spanID).innerHTML = "<img src='images/working.gif' width='16' height='16' align='absmiddle' /> <span class='maroon10NB'> PROCESSING... </span>";
}

function outputError(str){
	return "<table cellpadding='0' cellspacing='0' bgcolor='#b90000' width='100%'><tr><td height='20' colspan='2' align='left'   valign='top' width='3%'><img src='images/16_warn.gif' width='16' height='16' hspace=3 vspace=2 /></td><td class='white11' width='97%' align=left> "+str+"</td></tr></table>";
}

function outputMessage(str){
	return "<table cellpadding='0' cellspacing='0' bgcolor='#87BF00' width='100%'><tr><td height='20' colspan='2' align='left'   valign='top' width='3%'><img src='images/16_warn.gif' width='16' height='16' hspace=3 /></td><td class='black11' width='97%' align=left> "+str+"</td></tr></table>";
}

var nav = window.Event ? true : false;
function onKeyPressAllowEnter(e){
	if (nav) {
		  if (e.which == 13 &&  e.target.type == 'text') { 
			return true; 
		  }
		  	return false;
	} else {		  
		  if (event.keyCode == 13 && event.srcElement.type == 'text'){
			return true;
		  }
		  return false;
	}
}



 function trim(str)
{
 return str.replace(/^\s*|\s*$/g,"");
}

function number_format ( n, sSep ) {

	n = n.toString ( );

	var p1, p2, p3;
	var sSep = ( sSep == null ? ',' : sSep );

	n = n.split ( '.' );
	p1 = n [ 0 ];
	p2 = ( n [ 1 ] == null ? '' : '.' + n [ 1 ] );
	p3 = '';

	for ( var i = p1.length-1 ; i >= 0; i -- ) {
		p3 += p1.charAt ( p1.length - i - 1 );
		if ( i % 3 == 0 && i != 0 ) p3 += sSep;
	}

	return p3 + p2;

}

function randomString(strLen) {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = strLen;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

function msgWithBorder(id,str,msgType,marginTop,marginBottom,multiLineMsg){
	
	var row = ''
	var valignIcon = 'middle';
	
	if(msgType == 'error')
		var bgClr = '#b90000';
	else if(msgType == 'success')
		var bgClr = '#87BF00';
	
	if(multiLineMsg){
		row = '<tr><td height=4></td></tr>';
		valignIcon = 'top';
	}

	var str = "<table width='100%' cellpadding='2' cellspacing='0' style='border: 1px solid #cccccc;margin-top: "+marginTop+"px; margin-bottom: "+marginBottom+"px;'><tr><td><table cellpadding='0' cellspacing='0' bgcolor='"+bgClr+"' width='100%' >"+row+"<tr><td height='20' colspan='2' align='left'   valign='"+valignIcon+"' width='3%'><img src='images/16_warn.gif' width='16' height='16' hspace=3 /></td><td class='white11' width='94%' align=left> "+str+"</td><td width='3%' valign='"+valignIcon+"'><a href='javascript:;' onClick=\"document.getElementById('"+id+"').innerHTML=''\"><img src='images/informationbar_iconclose.gif' border='0' hspace=4 /></a></td></tr>"+row+"</table></td></tr></table>";
	document.getElementById(id).innerHTML = str;
}

function validEmail(emailVal){
	regex = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;

	if( !regex.test( emailVal ) )
		return false;
	
	return true;
}

function validURL(subDom,dom,minLen){
	urlRegex = /^http:\/\/[a-zA-Z0-9-]+$/;

	subDom = trim(subDom);
	dom = trim(dom);
	
	if(subDom=='' || dom=='')
		return 'empty';
	
	if(subDom.length<minLen)
		return 'lessSize';
	
	if( !urlRegex.test( subDom ) )	
		return 'invalid';

	return 'valid';
}

function checkBrowse(e)
{
	if (e.keyCode != '')	return false;
}

function validImgExt(val) {
        var isOK = false;
         if ((val != '') && (val > 1)) 
             isOK = true;
         else
            isOK = false;

        var fileName = val.toLowerCase();

        if((fileName.indexOf('.jpeg') != -1) ||            
            (fileName.indexOf('.jpg') != -1) ||
            (fileName.indexOf('.gif') != -1) ||
            (fileName.indexOf('.png') != -1) ) {
            isOK = true;
        }
        else            
            isOK = false;

         return isOK;
}

// simplePreload( '01.gif', '02.gif' );
function preImg(){ 
  var args = preImg.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++){
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

function preload(){ 
  var args = preload.arguments;
  document.imageArray = new Array(args.length);

  for(var i=0; i < args.length; i++){
    document.imageArray[i] = new Image();
    document.imageArray[i].src = args[i];
  }
}

function showHide(show,hide){

	show = show.split('#');
	hide = hide.split('#');
	
	if(hide!='null'){
		for(i=0; i<hide.length; i++){
			if(document.getElementById(hide[i]))
				document.getElementById(hide[i]).style.display = 'none';
			//else
				//alert('Unable to hide: '+hide[i]);
		}
	}
	if(show!='null'){
		for(i=0; i<show.length; i++){
			if(document.getElementById(show[i])){				
				if (show[i]=='pkH' || show[i]=='pkM')
					document.getElementById(show[i]).style.display = 'inline';
				else
					document.getElementById(show[i]).style.display = '';
			}
			//else
				//alert('Unable to show: '+show[i]);
		}
	}
}
//function showHide(show,hide){
//	
//	show = show.split('#');
//	hide = hide.split('#');
//	
//	
//	if(show!='null'){
//		for(i=0; i < show.length; i++)
//		{			
//			document.getElementById(show[i]).style.display = '';			
//		}
//	}
//	
//	if(hide!='null'){
//		for(i=0; i<hide.length; i++)
//			document.getElementById(hide[i]).style.display = 'none';
//	}
//}

function resetFieldF(obj,currentVal,valToCheck,valToSet)
{
	if( currentVal == valToCheck )
	obj.value=valToSet;
}

function resetFieldB(obj,currentVal,valToSet)
{
	if( currentVal == '' )
	obj.value=valToSet;
}